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;
}

Recommended Answers

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.