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
3
votes
1 answer

How to prove that a concurrent object is linearizable?

Is there a method to prove if an object is linearizable? For example for the code below. How can I prove that the counter is linearizable? here is the algorithm of the shared counter: CompareAndSet R = new CompareAndSet(0); increment() { Boolean…
Sydney.Ka
  • 175
  • 7
3
votes
1 answer

Can a mutex be used instead of a critical section when using stream buffers in FreeRTOS?

I am looking into using a stream buffer in FreeRTOS to transfer CAN frames from multiple tasks to an ISR, which puts them into a CAN transmit buffer as soon as it's ready. The manual here explains that a stream buffer should only be used by one…
3
votes
4 answers

Why the name "monitor"?

I'm referring to monitors as described here: http://en.wikipedia.org/wiki/Monitor_(synchronization) None of the definitions here seem apropos: http://www.thefreedictionary.com/monitor So why are they called that? == Update == Thank you for the…
3
votes
1 answer

argparse and mutually exclusive groups, each with their own required setting

I have a program that needs to have an option to either test a list of server ids OR issue a command against the server. This means, if I issue --test, then nothing else is required. It runs the whole gamut of tests against each server and prints…
UtahJarhead
  • 2,091
  • 1
  • 14
  • 21
3
votes
0 answers

Nested Critical Sections in scheduling

I'm studying scheduling and in particular the real time scheduling implemented in C. Now i'm stuck with a question about nested critical sections. The slides i'm studying use the assumption that if a task use a nested critical section, it always…
Qwerto
  • 265
  • 2
  • 10
3
votes
2 answers

Exit critical region

Consider several threads executing concurrently the following code: long gf = 0;// global variable or class member //... if (InterlockedCompareExchange(&gf, 1, 0)==0) // lock cmpxchg { // some exclusive code - must not execute in concurrent …
3
votes
3 answers

What prevents a race condition when checking a semaphore value?

I'm studying multithreading and trying to understand the concept of semaphores and mutual exclusion. Most of the examples I find online use some sort of library (e.g. pthread) to implement the semaphore or mutex, but I'm more interested in the…
Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
3
votes
3 answers

Mutually exclusive random sampling from a list

input = ['beleriand','mordor','hithlum','eol','morgoth','melian','thingol'] I'm having trouble creating X number of lists of size Y without repeating any elements. What I have been doing is using: x = 3 y = 2 import random output =…
O.rka
  • 29,847
  • 68
  • 194
  • 309
3
votes
1 answer

Mutex in rails API among several client request

I face a problem with mutual exclusion in my rails API. I have some Event object in my database which contain the number of person who will attend the event. Consider my Event method which add a person to the event : class Event def add_person …
Jérôme Boé
  • 2,752
  • 4
  • 21
  • 32
3
votes
5 answers

C++ hand-made mutex

I've made a hand-made mutex for my project, but I doubt if it is thread safe... bool blocked; while ( blocked ) { } blocked = true; ... blocked = false; Lets say, thread A passes the while loop and doesn't block the…
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
2
votes
2 answers

Does CFRETURN in a CFLOCK properly release the lock?

I am writing some code with CFLOCK tags, and am at a point where my code would return somewhere within a CFLOCK. Example: ... do some processing ...
jzimmerman2011
  • 1,806
  • 2
  • 24
  • 37
2
votes
3 answers

Creating Python class with mutually exclusive arguments using attrs

I have a class that has two mutually exclusive arguments (prices and returns). That is, they must not be both provided in order to instantiate an object. However, the class needs both for internal computations. So I want to compute the missing…
Andi
  • 3,196
  • 2
  • 24
  • 44
2
votes
3 answers

problem in peterson's lock in shared memory

I have implemented peterson' algorithm for mutual exclusion in shared memory. I am using shared memory between a c++ and a java process(using jni) for communication. The problem is that I am still seeing a race condition somehow. If I try to debug…
Neal
  • 3,119
  • 4
  • 27
  • 32
2
votes
0 answers

Posix semaphore equivelent of Pthread mutex lock for mutual exclusion in C

Using this section of code below as an example (courtesy of https://www.geeksforgeeks.org/condition-wait-signal-multi-threading/) what would be the method of converting a pthread_mutex_lock() and pthread_mutex_unlock() to POSIX and achieve mutual…
Aka-Samu
  • 21
  • 2
2
votes
0 answers

Mutual exclusion problem

The following solution to the mutual exclusion problem, discussed earlier, published in 1966 by H. Hyman in the Communications of the ACM. It was listed, in pseudo Algol, as follows. 1 Boolean array b(0;1) integer k, i, 2 comment process i, with…
edgarmtze
  • 24,683
  • 80
  • 235
  • 386