sched/wqueue: Add work_timeleft macro to get the left time to start

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-05-19 01:09:34 +08:00 committed by Petro Karashchenko
parent 5b0b4bd586
commit 9d2dae2fd8
1 changed files with 23 additions and 0 deletions

View File

@ -421,6 +421,29 @@ void work_foreach(int qid, work_foreach_t handler, FAR void *arg);
#define work_available(work) ((work)->worker == NULL)
/****************************************************************************
* Name: work_timeleft
*
* Description:
* This function returns the time remaining before the specified work
* start.
*
* Input Parameters:
* work - The work queue structure to check.
*
* Returned Value:
* The time in system ticks remaining until the work start.
* Zero means either that work is not valid or that work has already
* started.
*
****************************************************************************/
#ifdef __KERNEL__
# define work_timeleft(work) wd_gettime(&((work)->u.timer))
#else
# define work_timeleft(work) ((sclock_t)((work)->u.s.qtime - clock()))
#endif
/****************************************************************************
* Name: lpwork_boostpriority
*