Mutual exclusion means that processes must always execute critical sections in time intervals that do not overlap. The mutual exclusion requirement is one of the most basic in an operating system; without it the OS cannot share resources safely.
Questions tagged [mutual-exclusion]
261 questions
2
votes
3 answers
Does my solution satisfy mutual exclusion requirements?
I found a solution to the mutual-exclusion problem online that has two processes P0 and P1. (Assume that the variable turn is initialized to 0)
volatile int turn;
Process P0:
/* Other code */
while (turn != 0) { } /* Do nothing and wait. */
…

Tia
- 27
- 3
2
votes
1 answer
basic logic of lock - mutual exclusion
I'm struggling with the logic of lock for mutual exclusion; Here Im checking if the key is taken or not, if not we take it and when done release it; but could you please help me how I can have a loop to check the key until it becomes…

user385729
- 1,924
- 9
- 29
- 42
2
votes
2 answers
Why this program runs in infinite loop? Mutual exclusion
Below is the java program with which i started learning about mutual exclusion.
class MutexVar{
public static int Turn = 1;
}
class CriticalSection{
private static int modelNumber =0;
public static void setModelNumber(int number){
…

overexchange
- 15,768
- 30
- 152
- 347
2
votes
1 answer
what is the reason that semaphores mus be atomic
Im learning about semaphores: sem_wait and sem_signal.
Resources say that semaphores must be atomic to for implementing mutual exclusion
I can't understand why they must be atomic?! what happens if they are not?!

Kadaj13
- 1,423
- 3
- 17
- 41
2
votes
1 answer
All combinations of 2D array with mutual exclusivity
I have an array that looks like this:
$i[0] = ['a', 'b', 'c'];
$i[1] = ['d', 'e'];
$i[2] = ['a', 'b', 'c'];
$i[3] = ['d', 'e'];
$i[4] = ['f', 'g', 'h'];
I want to get all the possible permutations or combinations of this array, but without using…

Emil
- 7,220
- 17
- 76
- 135
2
votes
3 answers
Two Process Solution Algorithm 1
Here is the two process solution algorithm 1:
turn = 0;
i = 0, j = 1;
do
{
while (turn != i) ; //if not i's turn , wait indefinitely
// critical section
turn = j; //after i leaves critical section, lets j in
//remainder section
}…

Figen Güngör
- 12,169
- 14
- 66
- 108
2
votes
1 answer
Dekker algorithm
I know how looks dekker algorithm but why something like that would not work?
static void Enter(int i)
{
int j = 1 - i;
flags[i] = true;
if(flags[j])
{
while (turn!=i)
{ …

user2204936
- 21
- 2
2
votes
1 answer
Python: how to have mutually exclusive groups in subparser using argparse?
I am writing a program like:
import argparse
def task1(args):
print "running task 1"
def task2(args):
print "running task 2"
if __name__=="__main__":
parser=argparse.ArgumentParser(description="How can I have mutually exclusive…

lucacerone
- 9,859
- 13
- 52
- 80
2
votes
1 answer
Read/write synchronization
I have a data structure whose operations can be categorized as read operations (e.g. lookup) and write operations (e.g. insertion, removal). These operations should be synchronized so that:
Read operations can't execute while a write operation is…
Sause
1
vote
2 answers
Monitors and mutual exclusion
Just wanted to know if mutual exclusion in monitors is at a procedure/method level or if it is at a monitor level.
I mean, in the first case, there might be 2 threads accessing the monitor, but they would be running in different procedures. In the…

Mosty Mostacho
- 42,742
- 16
- 96
- 123
1
vote
1 answer
Peterson's solution just use one variable
For Pi:
do {
turn = i; // prepare enter section
while(turn==j);
//critical section
turn = j; //exit section.
} while(true);
For Pj:
do {
turn = j; // prepare enter section
while(turn==i);
//critical section
…

RichardFan
- 25
- 1
- 5
1
vote
0 answers
What is the minimum hardware support required for mutual exclusion of competing threads from a critical section?
When several threads share common data, to avoid race conditions when it is being modified, mutual exclusion is required. These can be implemented if the hardware supports atomic test-and-set instruction.
But can we go even simpler? By having just…

Sourav Kannantha B
- 2,860
- 1
- 11
- 35
1
vote
1 answer
Does std::tr1::shared_ptr do mutual exclusion?
I have a class which contains a BYTE*, a reference counter and a CRITICAL_SECTION which protects both of them from concurrent access.
I wanna replace all that with a std::tr1::shared_ptr. The MSDN says that:
Multiple threads can read and…

dario_ramos
- 7,118
- 9
- 61
- 108
1
vote
2 answers
violating mutual exclusion with non atomic wait(s) - Semaphores
I'm doing an 'operating systems' topic and I can't get my head around this:
We have been asked to demonstrate how mutual exclusion can be violated if wait(s) is not handled atomically. (semaphore implementation)
Now, I see how this may cause an…

Peter
- 11
- 3
1
vote
1 answer
C++ std::scoped_lock: What happens if the lock blocks?
I am interested to know more about how the std::scoped_lock operates.
I am making some modifications to some thread-unsafe code by adding a mutex around a critical section.
I am using a std::scoped_lock to do this.
There are two possible things…

FreelanceConsultant
- 13,167
- 27
- 115
- 225