Key Concepts

Review core concepts you need to learn to master this subject

Critical Section

Threads or processes may require shared access to certain resources. Areas of the program where these resources exist are called critical sections.

Synchronization
Lesson 1 of 1
  1. 1
    In this lesson, we will learn about synchronization which ensures that threads in a multi-threaded program use shared resources safely. Recall that the power of multi-threading comes from the a…
  2. 2
    If an outcome is deterministic, then that outcome is not in any way dependent on chance. The heads-or-tails outcome of flipping a coin where both sides are heads is deterministic because we know …
  3. 3
    Consider the following problem. Given a number,x, which has been initialized with the value 0, create a program that increments x one-hundred times so that when the program is finished executing, x…
  4. 4
    Recall that a program is synchronized when each critical section satisfies the mutual exclusion, progress, and bounded waiting conditions. Our program from the last exercise failed because multip…
  5. 5
    Consider the following example: two people work at a guitar store. One person makes guitars while the other sells them, but both keep track of their inventory number as they create and sell the gui…
  6. 6
    Recall the increment-a-number problem. In the no-locks solution, the race condition arose because the x = x + 1 operation actually takes place in three atomic steps. If two threads try to complete …
  7. 7
    One of the classic problems in synchronization is the producer-consumer problem (also known as the bounded buffer problem). We can think about the problem like this: let us return to our guitar sto…
  8. 8
    Congratulations on completing this lesson on synchronization! Multi-threading is the backbone of any complex computer program, and synchronization is what allows us to multi-thread our programs saf…

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo