Ignore:
Timestamp:
2023-02-11T19:13:44Z (19 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4777e02
Parents:
76e17d7c
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:46:39)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-11 19:13:44)
Message:

Reimplement waitq using thread_wait/wakeup

This adds a few functions to the thread API which can be
summarized as "stop running until woken up by others".
The ordering and context-switching concerns are thus yeeted
to this abstraction and waitq only deals with maintaining
the queues. Overall, this makes the control flow in waitq
much easier to navigate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/time/timeout.h

    r76e17d7c r111b9b9  
    4242typedef void (*timeout_handler_t)(void *arg);
    4343
     44typedef uint64_t deadline_t;
     45#define DEADLINE_NEVER ((deadline_t) UINT64_MAX)
     46
    4447typedef struct {
    4548        /** Link to the list of active timeouts on timeout->cpu */
    4649        link_t link;
    4750        /** Timeout will be activated when current clock tick reaches this value. */
    48         uint64_t deadline;
     51        deadline_t deadline;
    4952        /** Function that will be called on timeout activation. */
    5053        timeout_handler_t handler;
     
    5962#define us2ticks(us)  ((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
    6063
     64extern deadline_t timeout_deadline_in_usec(uint32_t us);
     65
    6166extern void timeout_init(void);
    6267extern void timeout_initialize(timeout_t *);
    6368extern void timeout_register(timeout_t *, uint64_t, timeout_handler_t, void *);
     69extern void timeout_register_deadline(timeout_t *, deadline_t, timeout_handler_t, void *);
    6470extern bool timeout_unregister(timeout_t *);
    6571
Note: See TracChangeset for help on using the changeset viewer.