semaphore - Why a mutex cannot be released from an ISR -


vxworks states mutual exculsion semaphores : cannot given inside isr, while condition vaild binary , counting semaphore.

i not able understand reason out same.

thanks, zaks.

remember mutex must first acquired/taken then released/given. in addition, task acquires mutex owns it. prevents task releasing mutex doesn't own.

with being case, becomes clear since isr cannot acquire mutex (or semaphore matter - it's blocking operation), follows can't give mutex.

it quite possible isr give binary or counting semaphore signal task happens. mutexes take/give pair.

to clarify point. in vxworks, isr context not same context of task!
following scenario invalid:

   task            isr   semtake(mutex)    ....                     semgive(mutex) 

task owns mutex. when isr runs, executes in totaly different context. current processors have separate isr stack. since task owns mutex, how isr give up? in fact, guarantee have isr fire while has mutex.
assuming "could" give mutex in isr, how handle following scenario:

  task                       task b                 isr   semtake(mutex)   ...   <context switch happens>                               <b runs>                                                   semgive(mutex) 

task gets switched out due call unrelated mutex, , task b runs. isr executes while b running. still valid isr given?

regardless of this, simple fact mutex used in pair of get/set. fail see use case have isolated semgive.

is there specific situation have in mind require semgive isr context?


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -