Re: semaphore ownership

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

 



>> > Hello All,
>> >
>> >           Is it possible to take semaphore in one thread and release it
>> > in
>> > another thread?

Yes, because AFAIK a semaphore do not have a concept of owner.
[...]
>
>         Actually I was reading about synchronization mechanism in Linux ans
> Windows. So same case is applicable to mutex as well. I mean it possible to
> take mutex one thread and release it in another thread. But in Windows there
> is mutex ownership concept, meaning thread which takes mutex has to release
> it. So if some thread release mutex, which is held by another thread then
> there wont be mutual exclusive access to shared data  protected by mutex in
> that thread.

Mutex itself implies an ownership. A sempahore which has ownership
awareness is very close to mutex.
May I suggest using Mutex instead of semaphore, unless absolutely necessary.
Advantages - Easy to debug, once who takes the lock releases it etc etc.

CMIIW.

Thanks,
   --Pradeep
>
>
> Sorry for silly question :).
>
>
> Thanks
> Shyam
>
>
>
> Thanks
>     Shyam
>



-- 
Pradeep

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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