LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-07-2011, 07:56 AM   #1
tgvlcw
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Rep: Reputation: 0
Why the interactivity of semaphore is better than mutual lock???


Please look at the code:
Code:
for(i = 0; i < 100; i++) {
        mutex_lock();
        ...
        mutex_unlock();
}
If a process A into the critical region 100 times, at this time, process B also into the critical region, now the B will be sleep until the A execute 100 times loop.

If I use the semaphore instead of the mutex_lock, it will never happen, the B will get the semaphore when the A isn't execute 100 times loop.

Does this the mutex feature??

Can anybody tell me, why it is??
 
Old 03-07-2011, 09:23 AM   #2
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate of:
http://www.linuxquestions.org/questi...2/#post4281467

Pending closure of this threads by the mods assigned to this forum, please post all replies there.


tgvlcw,

Welcome to LQ. Hope you get the help you need here.
BTW, please review the LQ Rules & try not to cross post again. It's against the rules for a good reason -- it dilutes the discussion.
Thank you for your co-operation.

Last edited by archtoad6; 03-07-2011 at 09:24 AM. Reason: typo
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to think of a way to ssh without interactivity and not using the publickey... trist007 Linux - Newbie 3 07-30-2010 08:26 AM
LXer: More fun with Zenity: shell script/GUI interactivity LXer Syndicated Linux News 0 02-18-2009 07:40 PM
pthreads and I/O mutual exclusion oulevon Programming 6 04-29-2006 09:33 PM
What Traffic Shaping Approach for Interactivity? tvynr Linux - Networking 5 10-15-2005 08:28 AM
gnome 2.8 desktop with limited interactivity wiseNoob Fedora 14 11-26-2004 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration