osal_clear_event() doesn't work if the target task ID is the task ID making the call. Suppose you have two events scheduled for your app layer and you want one to cancel the other. osal_clear_event() seems like it would do this, but it won't due to the way osal_run_system() is written.:
events = tasksEvents[idx]; tasksEvents[idx] = 0; // Clear the Events for this task. HAL_EXIT_CRITICAL_SECTION(intState); activeTaskID = idx; events = (tasksArr[idx])( idx, events ); activeTaskID = TASK_NO_TASK; HAL_ENTER_CRITICAL_SECTION(intState); tasksEvents[idx] |= events; // Add back unprocessed events to the current task.
All the bit-masked events are temporarily stored in the dynamic variable "events". It is impossible for osal_clear_event() to do anything to the current taskID's events.