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
1
vote
1 answer
Modifying Peterson algorithm
I know that the default implementation of Peterson Algo. provides me - Mutual exclusion, Progress and Bounded Waiting.
The normal Peterson algo is below.
bool flag[0] = false;
bool flag[1] = false;
int turn;
P0: flag[0] = true;
turn = 1;
…

Vishal R
- 1,026
- 1
- 7
- 21
1
vote
2 answers
SELECT limiting to only results based on a CSV list from a separate table
So I have a list of CSVs in one table. (EG: 1,3,19 )
I want to search out all of the usernames from the other table where the ids match any of those.
I feel like I should be able to do something like:
$query = "SELECT player_ids FROM cast_list…

aslum
- 11,774
- 16
- 49
- 70
1
vote
1 answer
How do three semaphores work in a synchronised execution of three threads?
In a certain system, the execution of three threads is synchronised using three semaphores, S1, S2 and S3, as shown below. Semaphores S1 and S2 are initialised to zero, while semaphore S3 is initialised to 1. All three semaphores are used only in…

Edoardo Moreni
- 408
- 2
- 10
- 24
1
vote
1 answer
Why CompareAndSwap is more of a powerful instruction than TestAndSet?
Please consider the following piece of code for CompareAndSwap and let me know why this atomic instruction is more powerful than atomic TestAndSet for being a mutual exclusion primitive?
char CompareAndSwap(int *ptr, int old, int new) {
unsigned…

Mona Jalal
- 34,860
- 64
- 239
- 408
1
vote
3 answers
Fine grained locking in C
I have this code for swapping elements:
atomic{
int temp = a[i];
a[i] =a[j];
a[j] = temp;
}
How would I implement this using fine-grained locking to achieve the same effect?

user2035796
- 67
- 2
- 7
- 14
1
vote
1 answer
Implementing a stock exchange using monitors
I am trying to implement a stock exchange using Hoare's monitors.
It has two functions buy() and sell() as follow:
buy(procid, ticker, nshares, limit)
sell(procid, ticker, nshares, limit)
And should print information on buyer id, seller id, ticker,…

ratsimihah
- 1,010
- 1
- 11
- 22
1
vote
1 answer
Meaning of "slice" in the context of mutual exclusion problems
What does "slice" mean in the following statement:
p0 tests lock (now, slice before actually setting lock)
The author is trying to show mutex is not met for this program.
It's from http://www.mcs.csueastbay.edu/~billard/os/mutex.txt
Thanks.

ratsimihah
- 1,010
- 1
- 11
- 22
1
vote
1 answer
Mutual Exclusion(Peterson's Algorithm)
I am looking at Peterson's Algorithm(mutual exclusion for 2 processes) My question is what if no processes has entered a critical section yet and P0 wants to enter a critical section for the first time, then P1's Flag would be false, so how does P0…

user2122810
- 93
- 1
- 3
- 11
1
vote
3 answers
mutual exclusion in joomla
I created an extension for joomla using:
$id=$database->insertid();
I just covered that if two users are logged on to the site will fit together perform two records in the database and then this statement will return in both cases the same…

iacoposk8
- 11
- 6
1
vote
1 answer
Can I lock the resource using the resource itself as monitor?
I have a multithread running context. I want one resource (let's say Object r) to be mutual exclusive. Can I use the resource itself as its monitor object?
e.g.
lock(r)
{
// do something...
}

Roy
- 81
- 3
- 10
1
vote
1 answer
Synchronized Not Entering
Note: I'm not looking for workarounds; I'm sure I can find other methods if necessary. I simply feel like I'm missing something fundamental or quirky and I want to know what I'm missing. Or if there is a way to use the debugger to get more info that…

CodeMonkey
- 1,795
- 3
- 16
- 46
1
vote
0 answers
Peterson-2 mutual algorithm
The contention-free complexity of the Peterson's 2-proccess algorithm is 4 (performs 3 two accesses to shared-registers memory in the entry code and and one in the exit code ) .
How can I modify the Peterson's 2-proccess algorithm so that its…

user1821244
- 11
- 1
0
votes
1 answer
Mutually Exclusive Access in ASP.net + C#.net
Currently I am facing a problem which I am unable to solve after a lot of work and search, I asked a similar question before but didn't got any reply maybe because I didn't asked it correctly so I deleted that question.
Ok I am downloading emails…

Ahmed
- 645
- 4
- 13
- 24
0
votes
1 answer
Sharing object and controlling thread execution from main thread
I am trying to solve quite easy problem. I have a main thread, which draws a frame and another thread(FrameThread) that prepares this frame every time. Both threads should share same MyFrame object. I want to control FrameThread from the main…

Kael
- 25
- 1
- 5
0
votes
2 answers
Mutual exclusion and C Sockets
I am maintaining an existing system where previous developers on each operation is performed on the socket, to which multiple threads are required to read and write to, the previous developers have performed the io operations under the control and a…

biosFF
- 223
- 2
- 9