Browse Source

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>
pull/89381/head
Chris Friedt 2 months ago committed by Benjamin Cabé
parent
commit
36c44045a0
  1. 2
      kernel/events.c

2
kernel/events.c

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

Loading…
Cancel
Save