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;

 /* give CS to Process2 */
 set pid=1;

Recommended Answers

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, …

Jump to Post

All 3 Replies

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 ???

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.