Module 20: Multi-core Computing Multi-processor Scheduling
  Lecture 40: Multi-core Computing Synchronization
 


Race Conditions

  • Situation when several concurrent processes operate on the same variable and the result of the computation depends upon the order in which they execut.
  • In the preceding example, the value of count could be 4, 5 or 6.
    • C1,P1,P2,P3,C2,C3 final value 4
    • C1,C2,C3,P1,P2,P3 final value 5
    • P1,C1,C2,C3,P2,P3 final value 6

Critical Section Problem

  • We model the problem using the notion of Critical Sections.
    • Critical sections are with respect to the shared data.
  • There are n processes, each sharing some common resource.
    • Each wants to modify the common resource.
  • For each process, define the region of code where it accesses a shared piece of data as a critical section.
  • In a correct system of multiple cooperating processes,
    • Only one process must be inside its critical section.

Problem Abstraction

  • Processes execute code similar to the following.
while (1) {
Non critical code
Entry code
Critical Section Code
Exit Code
Non Critical Code
}