RE: counting semaphore question

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

 



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@xxxxxxxxx>
보낸 날짜 : 2016-02-15 15:47:57 ( +09:00 )
받는 사람 : kernelnewbies <kernelnewbies@xxxxxxxxxxxxxxxxx>
참조 : 
제목 : 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. 
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[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