We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,820 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

default value of a mutex

I have 2 doubts

1)what is the default value of a mutex ?
Is it 0 or 1?

2)Why cant we have a code like, this to solve the Concurrency issues. I mean, i know its not possible, but this was asked to me at an interview ...

if(pid == 1)
{
  /* give CS to Process1 */
  set pid =2;
}

else
{
 /* give CS to Process2 */
 set pid=1;
}
2
Contributors
3
Replies
2 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
tubby123
Junior Poster in Training
98 posts since May 2011
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 0

Check this: http://www.merriam-webster.com/dictionary/doubt?show=0&t=1312659545

You need atomic test and set. I do not know what you mean with default value of mutex. Usually I would think critical block is not locked at beginning, meaning value 0.

pyTony
pyMod
Moderator
6,301 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26

thanks for the reply ,
default value - what i meant was, say, the Producer-consumer Problem , where Producer puts something into the queue until the limit of the queue(n) and the Consumer consumes from it until 0.
So, initially does the queue have anything in it ??
That is, can the consumer consume anything initially ???

tubby123
Junior Poster in Training
98 posts since May 2011
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 0

Can you eat any bread if no bread have been produced?

pyTony
pyMod
Moderator
6,301 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0729 seconds using 2.68MB