The `need_switch` flag was not initialized in `event_post()`. Since it is
a local variable, it could contain a random non-zero value, leading to
incorrect behavior.
In addition, this patch also fixes an issue where the event clearing
operation in `event_post()` was not performed correctly.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
The current event implementation relies on a dedicated wait object,
which introduces several issues:
1. Increases memory usage
2. Complicates the event logic
3. Makes the API design less clean, as it requires a separate
nxevent_tickwait_wait() function
This patch removes the event’s dependency on the wait object
and eliminates the nxevent_tickwait_wait() API accordingly.
BREAKING CHANGE: this commit removed the nxevent_tickwait_wait function
so the related docs should be updated accordingly
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
If the thread is blocked waiting on a event, then the
thread must be unblocked from the evnet to handle
the task cancellation.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
The current event implementation uses semaphores for wait and post
operations. Since semaphores are relatively heavy-weight and intended
for resource-based synchronization, this is suboptimal.
So this patch replaced the semaphore-based mechanism with direct
scheduler operations to improve performance and reduce memory footprint.
This patch also introduce a new task state TSTATE_WAIT_EVENT to indicate
the task is waiting for a event.
BREAKING CHANGE: This commit introduced a new task state TSTATE_WAIT_EVENT
so apps/nshlib/, procfs/ and tools/pynuttx/nxgdb/ are needed to be updated accordingly.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
Restore the use of critical sections to provide mutual exclusion
between event wait and post operations. This allows replacing the
heavier semaphore-based mechanism with direct scheduler operations
for synchronization.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
In certain cases, when the event-wait thread is awakened,
it needs to know the specific mask bit that triggered it,
so that it can branch to different paths accordingly.
This patch introduces the nxevent_getmask function to address this requirement.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Change:
Replace list_delete_init() with list_delete() in nxevent_post.
Reason:
PR 16933 removed list_delete() in nxevent_wait() and allow other task
to preempt event-wait thread after list_add_tail() option, the even-post thread
can preempt it at this time and do list_delete_init().
The problem is that list_delete_init() will make list_in_list() return true, so
DEBUGASSERT(!list_in_list(&(wait->node))); will fail in nxevent_wait() after the event-wait thread
returns.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
There are cases that users do not want the event wait object to be allocated automatically
in the stack as a temporary varialbe in nxevent_tickwait, since multiple threads will
access the varialbe, they want to allocate the object as a global variable for safety
control or easy debug. To solve this problem, this patch add a new function nxevent_tickwait_wait
implementation to give user the chance to pass the global wait object to it.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
nxevent_tickwait() will remove the node in failure case(EINTR). If the node
has been deleted in the nxevent_post(), NULL pointer reference will
be triggered after semaphore wait.
Signed-off-by: chao an <anchao@lixiang.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
enable the scheduler may cause the context to switch to a high-priority task,
which will failure to clear pending events correctly.
Signed-off-by: chao an <anchao@lixiang.com>
Events groups are synchronization primitives that allow tasks to wait
for multiple conditions to be met before proceeding. They are particularly
useful in scenarios where a task needs to wait for several events to occur
simultaneously.
Signed-off-by: chao an <anchao@lixiang.com>