This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

osal_clear_event() issue

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.

  • Hello Peter,

    Interesting observation.

    Without having the code in front of me to verify, I believe that when you make the call to osal_clear_event() it would be called each time it appears in your function. That would mean that the current task id would be updated and stored using the |= statement.

    I could be mixing up the clear event procedure with the timer event start and stop which I have not seen any problems with.

    Thanks,