Questions tagged [mutual-exclusion]

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.

261 questions
2
votes
0 answers

How is this One-Lane Bridge problem solution not starvation-free?

I have here a one-lane bridge problem solution. I was wondering how this solution is not starvation-free? The problem is that cars coming from the north and the south arrive at a one-lane bridge. Cars heading in the same direction can cross the…
2
votes
1 answer

Need help understanding implementation of mutex with test_and_set

The book Operating System Principles by Silberschatz, Galvin, and Gagne has the following implementation for atomic operations of test_and_set boolean test_and_set(boolean *target) { boolean rv = *target; *target = true; return…
2
votes
3 answers

Mutual Exclusion Conditions

I was reading about Mutual Exclusion Conditions, which are as follows No two processes may at the same moment inside their critical sections. No assumptions are made about relative speeds of processes or number of CPUs. No process should outside…
2
votes
2 answers

Mutual exclusion Vs Atomic variable

Atomic operation - An action that effectively happens all at once or not at all Ex: java.util.concurrent.atomic.AtomicInteger Mutual exclusion - Prevents simultaneous access to a shared resource Ex: synchronized With mutual exclusion approach,…
overexchange
  • 15,768
  • 30
  • 152
  • 347
2
votes
0 answers

Mutual Exclusion in MPI (critical section)

I am learning MPI and I am making a program in C to run with four processes. Each process has access to an index (n), then it adds one to that index (update) and each process must know the last calculated value of n. If a process is accessing the…
LucíaLP
  • 21
  • 4
2
votes
1 answer

For Linux RCU, during the grace period, is it possible that a new writer update the new data?

I am new to Linux and studying RCU section. I saw there is a grace period during operation. Just want to know if some new writer want to update the data during a grace period, is it possible? I guess there are two ways: During a grace period, it…
2
votes
1 answer

Consistency of MPI_Fetch_and_op

I am trying to understand the MPI-Function `MPI_Fetch_and_op() through a small example and ran into a strange behaviour I would like to understand. In the example the process with rank 0 is waiting till the processes 1..4 have each incremented the…
nando
  • 41
  • 7
2
votes
1 answer

Simple C mutual exclusion implementation in a dual core AMP system

I am working with the Zynq-7000 SoC - developing a dual core (CPU0, CPU1) application. I want to use the shared on-chip memory (OCM) with cache disabled for bidirectional data exchanging between the cores. My idea is to set the data sharing in the…
Steven
  • 21
  • 1
2
votes
1 answer

Does this uphold Mutual Exclusion: Concurrent programming?

1/ Does the algorithm uphold Mutual Exclusion? 2/ Is the algorithm free from deadlock and is starvation possible? I can't seem to get my head around deadlock. I do believe there is no mutual exclusion as any client can enter the critical section?…
2
votes
1 answer

Promela SPIN unreached in proctype error

I'm pretty new to SPIN and Promela and I came across this error when I'm trying to verify the liveness property in my models. Error code: unreached in proctype P (0 of 29 states) unreached in proctype monitor mutex_assert.pml:39,…
firearian
  • 65
  • 1
  • 7
2
votes
0 answers

How to analyze a mutual exclusion algorithm with two atomic test-and-set calls

Someone has posted on this site a simple mutual exclusion algorithm for two threads. bool locks[2]; thread_function() { bool id = get_id(); while(1) { if (!tset(&locks[id])) { if (!tset(&locks[!id])) { x++; // critical…
Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76
2
votes
1 answer

MPI: Ensure an exclusive access to a shared memory (RMA)

I would like to know which is the best way to ensure an exclusive access to a shared resource (such as memory window) among n processes in MPI. I've tried MPI_Win_lock & MPI_Win_fence but they don't seem to work as expected, i.e: I can see that…
Reda94
  • 331
  • 4
  • 12
2
votes
1 answer

Verify Dekker's mutual exclusion algorithm by NuSMV

I use NuSMV to verify the Dekker algorithm, and my code is as below: MODULE main VAR b1 : {true, false}; b2 : {true, false}; k : {1, 2}; pr1 : process proc(k, b1, b2, 1); pr2 : process proc(k, b2, b1, 2); ASSIGN init(b1) := false; init(b2) :=…
2
votes
0 answers

Can I use a dummy lock file for PHP to implement mutual exclusion?

I was wondering whether this is a good way to implement mutual exclusion on PHP: You use PHP flock() and a dummy lock file. Because flock() only allows one process to access a file. $file = fopen("dummyLockFile"); flock($file, LOCK_EX) //Critical…
Long Le
  • 404
  • 5
  • 18
2
votes
1 answer

Java - How can I ensure I run a single instance of a process in a clustered environment

I have a jvm process that wakes a thread every X minutes. If a condition is true -> it starts a job (JobA). Another jvm process does almost the same but if the condition is true - it throws a message to a message broker which triggers the job…
Bick
  • 17,833
  • 52
  • 146
  • 251