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.

[Sys/Bios] Resetting an Event Object

Expert 2430 points

What's the best (or proper or safest) way to clear/reset an event object?  The event object will have several (but not all, obviously) bits set in its AND mask.  The event is also using an OR mask (it's what I use to "abort").  So without posting this abort event, how can I clear the event object?

My first thought is/was to just call Event_pend() with no timeout, i.e., BIOS_NO_WAIT, but the help documentation hints that this approach would be bad since it will be another task calling this Event_pend().  (It states that only one task can pend on an event, or something along those lines.)

  • So there's no way to reset an event object?

  • Try using Event_construct(Event_Object *evt, NULL);

    This will re-initialize the Event object passed to it.

    Alan

  • Thanks!  I'll give it a shot.

  • Two things.

    Wouldn't I acutally need to call it like Event_construct( Event_struct(evt), NULL )?  Or are event handles and event structure pointers aliases for the same thing?

    Also, I was not explicitly clear about this--though it could be inferred--but at the time of the event object reset, a task will be pending on it. Will calling Event_construct() unlink the event to the pending task making the task forever suspended?

  • Yes, you are correct that you have to use the Event_struct() to convert the handle to the proper struct type.

    And yes, there is a big problem using this when a task is currently pending on the Event object. The task will remain forever blocked.

    I'm confused why the task is blocked on the Event object if the events its waiting for have already been posted?

    Alan

  • Numerous events occur throughout the system.  If at any stage the system determines it needs to abort, that leaves numerous upstream tasks pending on some but not all events (depending how far the data got through the system).

    This is why I am using a bit in the OR mask to signal the other events that the current process has been aborted, but that doesn't seem to be consuming the AND bits.  (Besides, given the task is idle, it's a waste of cycles and adds to system complexity just to wake it up to tell it to go back to sleep! :-) )

    This is why I need a way to reset the event object WITHOUT waking up the pending task.

  • When the task returns from Event_pend() due to the event in its OR mask being posted, I think it could clear out the posted events before pending again by doing this:

    {

     ...

      /* here after returning from OR mask match */

      Event_pend(evt, 0, 0xffffffff, BIOS_NO_WAIT);

     ...

    }

    This should consume ALL posted events and NOT block in the process.

    Alan

  • Okay, but I really wish were a way to clear the event object without posting to it.  Maybe in a future SYS/BIOS version...

     

    Thanks!