Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Remember that a Mutex <strong>must</strong> first be acquired/taken <strong>then</strong> released/given. In addition, the task that acquires the mutex <strong>owns</strong> it. This prevents another task from releasing a mutex it doesn't own.</p> <p>With that being the case, it becomes clear that since an ISR cannot acquire a mutex (or any semaphore for that matter - it's a blocking operation), then it follows that it can't give the mutex.</p> <p>It is quite possible for an ISR to do give a Binary or Counting semaphore to signal a task that something happens. But mutexes are always a take/give pair.</p> <p>To clarify a point. In VxWorks, the ISR context is <strong>not</strong> the same as the context of a task!<br> The following scenario is invalid:</p> <pre> Task A ISR semTake(mutex) .... semGive(mutex) </pre> <p>Task A <strong>owns</strong> the mutex. When the ISR runs, it executes in a totaly different context. Most current processors have a separate ISR stack. Since Task A owns the mutex, how could the ISR give it up? In fact, what guarantee do you have that the ISR will fire while A has the mutex.<br> Even assuming you "could" give a mutex in an ISR, how would you handle the following scenario:</p> <pre> Task A Task B ISR semTake(mutex) ... &lt;context switch happens> &lt;B runs> semGive(mutex) </pre> <p>Task A gets switched out due to a call unrelated to the mutex, and Task B runs. The ISR now executes while B was running. Would it still be valid for the ISR to be given?</p> <p>Regardless of all this, the simple fact is that a mutex is always used in a pair of Get/Set. I fail to see a use case where you would have an isolated semGive.</p> <p>Is there a specific situation you have in mind that would require a semGive from an ISR context?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload