RE: semaphore down/up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you misunderstood it. scull_read() function  is using "goto  out" whenever there is some errors in function and function needs to return, in this case before returning it releases the semaphore by going to out label. In case nothing goes wrong in function and it goes well it will still go to "out" label sequencially. So in any case control will go thru "out" label and will releasing the semaphore before returning. These things are made clear in any basic book on C Language, try to refer them.

Labels are not only traversed by using "goto" statements, they are also traversed sequencially.

Regards,
Gaurav


-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Hinko Kocevar
Sent: Tuesday, July 20, 2004 9:57 PM
To: kernelnewbies@xxxxxxxxxxxx
Subject: semaphore down/up

Hi,

Looking at scull_read() in LDD2 how is semaphore released if the read
operation succeeds ? I mean, up is invoked only if error occours so
lines after out: label are called. As I understand this example, out:
label could be reached if doing multiple scull_read() in a loop, and
it would fail if either EOF is reached or no data is available in
private_data.

It puzzles me because it is stated on a page before that claimed
semaphore must be released as well (that makes sense).

regards,
h
-- 

hinko<dot>kocevar<at>
iskramedical<dot>si
Hinko Kocevar, developer		"Aì rén"
Iskra Medical d.o.o.				[Analects XII:22]
Stegne 23, 1k LJ, SLO-EU

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux