* counting semaphore question
@ 2016-02-15 6:47 Shiva Shankar
2016-02-15 8:56 ` Chan Kim
0 siblings, 1 reply; 2+ messages in thread
From: Shiva Shankar @ 2016-02-15 6:47 UTC (permalink / raw
To: kernelnewbies
Hi all,
Can you anyone tell me what is the exact use of counting semaphore in
kernel ?
When should we use it ? what is the practical usage of counting semaphores
in
Linux kernel ?
I have seen only mutex (Binary semaphore)is used for synchronization not
the counting semaphore(count >1).
Any sugguestions would be appreciated
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160215/bf46bf71/attachment.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* counting semaphore question
2016-02-15 6:47 counting semaphore question Shiva Shankar
@ 2016-02-15 8:56 ` Chan Kim
0 siblings, 0 replies; 2+ messages in thread
From: Chan Kim @ 2016-02-15 8:56 UTC (permalink / raw
To: kernelnewbies
Hi,
I'm not a proper person to reply to this question but at least I know what it is for.
see below (from http://www.makelinux.net/books/lkd2/ch09lev1sec4)
Alternatively, the count can be initialized to a nonzero value greater than one. In this case, the semaphore is called a counting semaphore, and it allows at most count holders of the lock at a time. Counting semaphores are not used to enforce mutual exclusion because they allow multiple threads of execution in the critical region at once. Instead, they are used to enforce limits in certain code. They are not used much in the kernel. If you use a semaphore, you almost assuredly want to use a mutex (a semaphore with a count of one).
I don't know in what circumstances the number of resource holders should be limitted. Maybe for a subsystem handling synchronization itself but the number of users should be limited? Hope to hear from somebody with good examples.
regards,
Chan
?? ?? : "Shiva Shankar" <klshiva4a4@gmail.com>
?? ?? : 2016-02-15 15:47:57 ( +09:00 )
?? ?? : kernelnewbies <kernelnewbies@kernelnewbies.org>
?? :
?? : counting semaphore question
Hi all,
Can you anyone tell me what is the exact use of counting semaphore in kernel ?
When should we use it ? what is the practical usage of counting semaphores in
Linux kernel ?
I have seen only mutex (Binary semaphore)is used for synchronization not the counting semaphore(count >1).
Any sugguestions would be appreciated
Thanks in advance.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-15 8:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 6:47 counting semaphore question Shiva Shankar
2016-02-15 8:56 ` Chan Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.