Questions tagged [synchronization]

Questions about techniques for enforcing an agreed order of events between several concurrently executing threads. Specific synchronization mechanisms include mutexes (locks), condition variables, semaphores and monitors.

122 questions
54
votes
3 answers

Contrasting Peterson’s and Dekker’s algorithms

I am trying to understand the algorithms by Peterson and Dekker which are very similar and display a lot of symmetries. I tried to formulate the algorithms in informal language like follows: Peterson's: "I want to enter." …
gbag
  • 719
  • 1
  • 6
  • 9
19
votes
1 answer

Are there hardware lock implementations without test-and-set or swap?

Locks are usually implemented thru test-and-set and swap machine-level instructions. Are there other implementations that do not use these? Also, can we say that all hardware level solutions to the critical section problem can be categorized into…
13
votes
2 answers

Difference between Lamport timestamps and Vector clocks

Lamport timestamps and vector clocks sound like almost the same thing. Both are used to determine the order of events in a distributed system. What are their key differences?
bkoodaa
  • 377
  • 2
  • 3
  • 13
11
votes
3 answers

Why are most mutex implementations unfair?

My understanding is that most popular implementations of a mutex (e.g. std::mutex in C++) do not guarantee fairness -- that is, they do not guarantee that in instances of contention, the lock will be acquired by threads in the order that they called…
Jeremy Friesner
  • 267
  • 2
  • 7
11
votes
3 answers

Why would you use a monitor instead of a semaphore?

I am currently attending the concurrent programming course in my university and we recently started talking about the concept of a monitor. While I understand the necessity of mutual exclusion, I do not understand why I would use a monitor for that.…
Dennis Hein
  • 316
  • 2
  • 11
9
votes
1 answer

What does "monotonicity" mean in the context of mutability

I'm reading The Rust Programming Language and found the following passage: Remember that writing to a struct is not an atomic operation, and many functions like vec.push() can reallocate internally and cause unsafe behavior, so even…
xji
  • 277
  • 1
  • 6
8
votes
1 answer

What is a linearization point?

With respect concurrent programming, what is a linearization point? They seem to occur at a compare-and-swap instruction apparently. The best definition I could find is here. All function calls have a linearization point at some instant between…
nfaughnan
  • 81
  • 1
  • 4
8
votes
1 answer

Vector clocks: Why is it necessary to increment my clock on receiving a message?

Assume I have a distributed system of entities, each with a replica of the same data object that can be modified by broadcasting the changes and I'm using vector clocks to know how to order changes. In this scenario, Why would I need to increment my…
Marcel Klehr
  • 229
  • 1
  • 4
7
votes
3 answers

Bounded waiting and starvation free in critical section problem

I have 4 questions regarding relation between starvation and bounded waiting. 1.Does starvation-freedom imply deadlock-freedom? My Answer: From here, definition of starvation free is Freedom from Starvation -:Every thread that attempts to acquire…
laura
  • 337
  • 1
  • 3
  • 12
7
votes
6 answers

Does Deadlock imply Starvation

If there is a deadlock between the processes does that mean that there is starvation also? My Thinking: deadlock is no process using that resources , but starvation is like not giving chance to only that process so there is progress in starvation…
7
votes
2 answers

Understanding N process Peterson's algorithm

The intuitive informal description of two process Peterson's algorithm for process 0 can be given as follows: flag[0]=true; //I am ready to enter my critical region turn=1; //but you may take your turn to…
7
votes
3 answers

Solutions to synchronization problem need to be executed in critical section

I was reading about synchronization problems for cooperating processes and i learned that only hardware solutions like test_and_wait() and compare_and_set() are performed atomically at the hardware level and in all other software solutions like…
6
votes
1 answer

Why $e(C_i) = D_i$ is correct assumption? (FLP Impossibility 1985 - Lemma 3)

Please bear with my unhelpful typesetting. My question is regarding well known FLP paper Impossibility of Distributed Consensus with One Faulty Process by Fischer, Lynch and Patterson While discussing Lemma 3, in 4th paragraph, authors make an…
6
votes
2 answers

Minimum number of processes for the deadlock?

A system has 6 identical resources and $N$ processes competing for them. Each process can request at most two requests. Which one of the following values of $N$ could lead to a deadlock? 1 2 3 4 My attempt: Deadlock free condition is: $R \geq…
6
votes
1 answer

Mutex implementation on top of a minimalistic preemptive scheduler

In this question, I'm implementing some synchronization primitives in the standard library of an operating system. Specifically, I want to implement mutexes and condition variables. This is on top of a microkernel with a preemptive scheduler (a…
1
2 3
8 9