Notifications
Notifications are concept that can be used to notify other threads implicitly without knowing their identity. The identity of notified thread is established based on the match of the object notified and waited for.
Thread which is waiting for notification can install a kernel-space callback that gets called before the thread is resumed.
Function-like Macros
void cb_syscall_notify_object(const void *object, Thread_t thread, int sleeper, Event_t event)
This callback is not executed within the context of the notified thread, rather in the context of notifying thread. The state of notified thread is largely pre-notification at this point.notify_object
Enumeration
Unknown member type EventTypes
Functions
void os_notify_init()
Initialize the notification structure This will initialize internal notification buffers to the default unused state.
int os_notify_thread(Thread_t thread_id, int candidate_timer, Event_t event)
- thread_id ID of thread notification has to be delivered to
- event event the thread is notified of
Returns E_OK if thread was notified and no further action is needed; E_NOTAVAIL if thread is not waiting for any
int os_notify_object(const void *object, Event_t event, uint32_t flags)
This function will find one single thread which is waiting for this particular object. If more than one thread is waiting for this object, then the thread with the highest priority will be resumed.
object address of the object that is notified
event event that is signalled to the object E_OK if any thread was waiting for this object and was woken up The object address is mostly meaningless. It allows threads to synchronize on any objects both externally from the userspace and internally in the kernel.
- object address of the object that is notified
- event event that is signalled to the object
Returns E_OK if any thread was waiting for this object and was woken up
int os_wait_for_object(const void *object, WaitHandler_t callback, uint32_t flags)
This function will block thread until some other thread notifies the object. Threads are being woken up based on their priorities. Highest priority first.
object address of the object that is being waited for
callback address of the callback function that handles wakeup
flags optional flags affecting function behavior E_OK if thread is capable of waiting, E_BUSY if thread is already waiting for something, E_INVALID if callback is a NULL pointer
- object address of the object that is being waited for
- callback address of the callback function that handles wakeup
- flags optional flags affecting function behavior
Returns E_OK if thread is capable of waiting, E_BUSY if thread is already waiting for something, E_INVALID if callback is a NULL pointer
int os_initialize_waitable_object(const void *object)
Call to this function will initialize clean state: no one is waiting, no one had notified this particular object. If any notifications were pending for this object they will be deleted.
object address of the object for which notifications are being initialized
- object address of the object for which notifications are being initialized
int os_sys_notify_object(const void *object)
This is a wrapper around os_notify_object system call. It does some additional checking on arguments. See notify_objectos_notify_object
int os_sys_notify_object2(const void *object, uint32_t flags)
This is a wrapper around os_notify_object system call. It does some additional checking on arguments.
object address of the object that is being waited for
flags optional flags affecting function behavior See notify_objectos_notify_object
- object address of the object that is being waited for
- flags optional flags affecting function behavior See
int os_sys_wait_for_object(const void *object, uint32_t timeout)
This is a wrapper around os_wait_for_object system call. It does some additional checking on arguments. See wait_for_objectos_wait_for_object
int os_sys_wait_for_object_value(uint8_t *object, uint8_t value, uint32_t timeout, uint32_t flags)
This is a wrapper around os_wait_for_object system call. It does some additional checking on arguments. See wait_for_objectos_wait_for_object