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
11
votes
7 answers
How do I make a Python function with mutually exclusive arguments?
I have a Python class which needs to accept one of two mutually exclusive arguments. If the arguments are not exclusive, (ie: if both or neither are given), an error should be raised.
class OrgLocation:
__init__(self, location_num=None,…

Stevoisiak
- 23,794
- 27
- 122
- 225
11
votes
4 answers
Why empty critical section within netfilter hooks, occurs `BUG: scheduling while atomic error`?
I've written this hook:
#include
#include
#include
#include
#include
#include
static struct nf_hook_ops nfho;
static struct mutex…

Milad Khajavi
- 2,769
- 9
- 41
- 66
10
votes
2 answers
Spin unreached in proctype "-end-"
I'm pretty new at spin model checking and wanted to know what this error means:
unreached in proctype P1
ex2.pml:16, state 11, "-end-"
(1 of 11 states)
unreached in proctype P2
ex2.pml:29, state 11, "-end-"
(1 of 11 states)
here is…

Javi
- 889
- 1
- 16
- 41
9
votes
4 answers
Handling mutual exclusion in C++11
I have a class representing a finite-state machine, which should run in a forever loop and check it's current state. In each state machine will set it's next state and either fall into idle state or do some work. I would like to allow another thread…

sorush-r
- 10,490
- 17
- 89
- 173
9
votes
2 answers
C++ atomics: how to allow only a single thread to access a function?
I'd like to write a function that is accessible only by a single thread at a time. I don't need busy waits, a brutal 'rejection' is enough if another thread is already running it. This is what I have come up with so far:
std::atomic busy…

Ignorant
- 2,411
- 4
- 31
- 48
8
votes
4 answers
Cassandra mutual exclusion locking (synchronization)
Is there anyway to synchronise client using cassandra built in functions?
I need to perform some operations and those operations need to be synchronized with all other clients (mutual exclusion).
In RDBMS I can lock entire table or prepare special…

Daimon
- 3,703
- 2
- 28
- 30
8
votes
7 answers
How to prevent two instances of an application from doing the same thing at the same time?
If you have two threads within an application, and you don't want them to run a certain piece of code simultaneously, you can just put a lock around the piece of code, like this:
lock (someObject) {
// ... some code
}
But how do you do the same…

Timwi
- 65,159
- 33
- 165
- 230
8
votes
3 answers
Critical Section in JavaScript or jQuery
I have a webpage, in which a certain Ajax event is triggered asynchronously. This Ajax section could be called once or more than once. I do not have control over the number of times this event is triggered, nor the timing.
Also, there is a certain…

Greeso
- 7,544
- 9
- 51
- 77
7
votes
3 answers
What's the best linux kernel locking mechanism for a specific scenario
I need to solve a locking problem for this scenario:
A multi CPU system.
All of the CPU's use a common (software) resource.
Read only access to the resource is very common. (Processing of incoming network packets)
Write access is a lot less…

Nir
- 1,406
- 2
- 13
- 20
7
votes
1 answer
Making pthread_rwlock_wrlock recursive
I have a problem regarding the behaviour of the pthread function pthread_rwlock_wrlock. The specification linked above states that when one thread has locked the lock for writing and the same thread locks it again, it results in undefined behaviour…

pmf
- 7,619
- 4
- 47
- 77
7
votes
1 answer
Bounded-waiting Mutual Exclusion with test and set
I am reading the famous Operating System Concepts book of (Avi Silberschatz, Peter Baer Galvin, Greg Gagne) edition 9: http://codex.cs.yale.edu/avi/os-book/OS9/
In the process synchronization chapter, there is an algorithm for "Bounded-waiting…

Rami
- 8,044
- 18
- 66
- 108
7
votes
2 answers
Can Test and Set be implemented in software without hardware support?
Here's the Test and Set written in software:
boolean TestAndSet(boolean *target) {
boolean rv = *target;
*target = TRUE;
return rv;
}
and
do {
while(TestAndSetLock(&lock))
; // do nothing
// critical section
lock…

Arjun Sreedharan
- 11,003
- 2
- 26
- 34
7
votes
1 answer
What will happen if we reorder the commands in Peterson's algorithm for mutual exclusion?
I have read this for Peterson's algorithm for mutual exclusion.Then there was the question what will happen if we reorder the first and second command in the do...while loop? I cannot see something happening if we do that...Can someone tell me what…

Saraki
- 297
- 1
- 7
- 21
6
votes
1 answer
If mutual exclusion is guaranteed, say with semaphores, is a program deadlock-free?
I define mutual exclusion and deadlock as below, respectively:
The mutual exclusion condition exists if at every moment, each shared resource is either assigned to exactly one process, or available.
A set of processes is deadlocked if each process…

Danny Rancher
- 1,923
- 3
- 24
- 43
5
votes
5 answers
Why all the interrupts must be disabled during semaphore operations?
I am reading Operating System Concepts by Galvin. In the semaphore section it says that all the interrupts to the processor must be disabled while modifying the value of semaphore.
Why it is required?

Sanketssj5
- 655
- 5
- 17