Messages in this thread | | | Date | Thu, 21 Nov 1996 00:20:38 -1000 (HST) | From | Bo Liu <> | Subject | Behavior of semaphore's down/up functions (2.0.24) |
| |
Hi, any experts there willing to help:
I am a new grad learning to write linux device drivers and want to understand some kernel codes related to driver programming.
I have a question on the behavior of semaphore's down/up functions..... :
----------------------------------------------------------------------- Running several processes with the same testing program which calls this piece of code inside driver:
static struct semaphore sem = MUTEX/*global variable initialized as {1,0,NULL}*/ ... /* printk indicating that down is about to called with the preocess identifier (local variable copied from user space varible, the address of which is passed as one argument of ioctl() ). */ down(&sem); /* printk indicating this process coming out of down and holding the device. /* sleep for a while */ up(&sem); /* printk indicating up is called */ scheduler(); ...
giving the result in /var/adm/syslog:
process 0 down process 0 got device process 1 down process 0 up process 0 down process 0 got device
while what is expected on the last line is "precess 1 got device" because precess 1 did the down before process 0 did it the second time.
Thanks in advance.
Best regards.
Bo
| |