LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Question on spinlock??? (https://www.linuxquestions.org/questions/programming-9/question-on-spinlock-716996/)

linqu 04-05-2009 10:58 AM

Question on spinlock???
 
Im an Embedded Systems engineer but a newbie to Linux Device Drivers programming and so trying to get a understanding of Linux Device Drivers by reading "Linux Device Drivers, 3rd Edition". My question is in chapter 5 where the spinlock is introduced the author explains that In Single processor system if pre-emption is disabled and if some thread tried to acquire spinlock, and if nobody releases that spinlock, then processor would spin forever in that thread which I think is understandable and so there are implementation changes on spinlock for non-preemtible kernel. But subsequently the author again mentions that pre-emption should be disabled while holding the spinlock on a pre-emptible kernel to take care of the situation where the thread which acquired the spinlock shouldnt release the processor to any other thread. So now the situation is almost similar to the problem which the author explained above. If I acquired a spinlock but if I try to acquire another spinlock then again the processor is stuck in that thread because pre-emption is again disabled. Is this true and something needs to be taken care by the programmer?


All times are GMT -5. The time now is 05:05 PM.