kernel: events: prevent k_event_init() from being called in an ISR

Most kernel objects should be initialized well before being
manipulated in ISR context.

Event objects are no exception. Initializing a k_event object in
ISR context would implicitly be racey and introduce an element of
non-determinism.

Assert that k_event_init() is not called from ISR context.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2025-04-28 13:52:25 -04:00 committed by Benjamin Cabé
commit 36c44045a0

View file

@ -51,6 +51,8 @@ static struct k_obj_type obj_type_event;
void z_impl_k_event_init(struct k_event *event)
{
__ASSERT_NO_MSG(!arch_is_in_isr());
event->events = 0;
event->lock = (struct k_spinlock) {};