kernel: New timeout implementation
Now that the API has been fixed up, replace the existing timeout queue with a much smaller version. The basic algorithm is unchanged: timeouts are stored in a sorted dlist with each node nolding a delta time from the previous node in the list; the announce call just walks this list pulling off the heads as needed. Advantages: * Properly spinlocked and SMP-aware. The earlier timer implementation relied on only CPU 0 doing timeout work, and on an irq_lock() being taken before entry (something that was violated in a few spots). Now any CPU can wake up for an event (or all of them) and everything works correctly. * The *_thread_timeout() API is now expressible as a clean wrapping (just one liners) around the lower-level interface based on function pointer callbacks. As a result the timeout objects no longer need to store backpointers to the thread and wait_q and have shrunk by 33%. * MUCH smaller, to the tune of hundreds of lines of code removed. * Future proof, in that all operations on the queue are now fronted by just two entry points (_add_timeout() and z_clock_announce()) which can easily be augmented with fancier data structures. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
52e444bc05
commit
987c0e5fc1
11 changed files with 315 additions and 637 deletions
|
@ -199,14 +199,10 @@ u32_t z_tick_get_32(void);
|
|||
*/
|
||||
s64_t z_tick_get(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Sets the current system tick count
|
||||
*
|
||||
* @param ticks Ticks since system start
|
||||
*
|
||||
*/
|
||||
void z_tick_set(s64_t ticks);
|
||||
#ifndef CONFIG_SYS_CLOCK_EXISTS
|
||||
#define z_tick_get() (0)
|
||||
#define z_tick_get_32() (0)
|
||||
#endif
|
||||
|
||||
/* timeouts */
|
||||
|
||||
|
@ -215,9 +211,8 @@ typedef void (*_timeout_func_t)(struct _timeout *t);
|
|||
|
||||
struct _timeout {
|
||||
sys_dnode_t node;
|
||||
struct k_thread *thread;
|
||||
s32_t delta_ticks_from_prev;
|
||||
_timeout_func_t func;
|
||||
s32_t dticks;
|
||||
_timeout_func_t fn;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue