LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Linux kernel module programming(Signal and semaphore) (https://www.linuxquestions.org/questions/programming-9/linux-kernel-module-programming-signal-and-semaphore-146674/)

eshwar_ind 02-16-2004 06:16 AM

Linux kernel module programming(Signal and semaphore)
 
Hi!
I have a doubt regarding signals and semaphores.
When a process is executing in kernel mode it takes a semaphore1 and waiting for another semaphore2. It enters into pended state. At that instant another process sends a signal to it and terminates the process1.

What about the semaphore 1?
Is it reclaimed automatically? or Is it possible to terminate a process waiting for a kernel resource in kernel mode?
Please reply me.
Thanks
bye,
Eshwar

infamous41md 02-16-2004 12:10 PM

remember that when u take a semaphore, you use one of these:
down(&sem);
down_interruptible(&sem);

the difference being that the 2nd can be interrupted by a signal. it returns 1 if interrupted, 0 otherwise. hence you always do this:
if(down_interruptible(&sem)){
//then we were interrupted by a signal, so let go of the first semaphore
up(&sem1);
return -ERESTARTSYS;
}

it is completely up to you to deal with all this.


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