Subj : mutex&threads To : comp.programming.threads From : Valerio Bardelli Date : Sat Mar 19 2005 04:13 pm Dear all, I've a big problem with a porting of linux on a mips board (based on IDT R4K). The problem is about mutex, threads and scheduling. I've a routine that is waked up by a my device driver that cought a special interrupt each 2.7ms. This routine (A) has priority 99 and I use the SHED_FIFO policy. To test the scheduling with mutex I've created another thread with priority 98 (B) that locks a mutex (FAST mutex), performs a for cycle (1000) and unlock the mutex. After this performs a nanosleep of 100ms. The thread at priority 99 (A) locks the same mutex, performs a for cycle (10000) and unlocks the mutex. I've monitored the duration of my routine at priority 99 (A) (attached to the interrupt via device driver) and I'm very surpriesed to see that, sometimes, but often, my routine duration is about 20ms. Normally my routine duration is about 100us (micro sec). I don't understand this problem about linux scheduling, because I think that when my thread at priority 99 (A) preempts the thread at priority 98 (B) after mutex lock then treads A stops on mutex, then starts the thread B that unlocks the mutex and, I hope, the scheduler runs again my thread A at priority 99... so, after this, I should have the dalay of the for cycle of 1000 in the thread B that is around few micro seconds, not tens of ms. Is this correct? I don't understand the dalay of 20ms that is so huge for my application. I have to guarantee that my routine attached to the interrupt via device driver is finished in 1.5ms at maximum... Can you help me? Thanks a lot for your valuable help. Ciao, Valerio. (barde.vale@libero.it) .