To guard against the race condition mentioned

This preview shows page 4 - 7 out of 39 pages.

! To guard against the race condition mentioned previously, we need to ensure that only one process at a time can be manipulating the variable counter . ! Race conditions occur frequently in operating systems. " Clearly, we want the resulting changes not to interfere with one another. " In this chapter, we talk about process synchronization and coordination. 8 The Critical-Section Problem ! Critical section: " A segment of code where a process may be changing common (shared) variables, updating a table, writing a file, and so on. ! Consider a system consisting of n processes: " Each process has a critical section. " Clearly, when one process is executing in its critical section, no other process is to be allowed to execute in its critical section. ! The critical-section problem is to design a protocol that the processes can use to cooperate. " That is, no two processes are executing in their critical sections at the same time.
Image of page 4

Subscribe to view the full document.

Synchronization 5 9 The Critical-Section Problem (cont’d) ! For a critical-section problem solution: " Each process must request permission to enter its critical section. $ The section of code implementing this request is the entry section . " The critical section may be followed by an exit section . " The remainder code is the remainder section . do { entry section critical section exit section remainder section } while (TRUE); 10 The Critical-Section Problem (cont’d) ! A solution to the critical-section problem must satisfy the following three requirements: 1. Mutual exclusion: " If process P i is executing in its critical section " Then no other processes can be executing in their critical sections. 2. Progress: " If no process is executing in its critical section " And there exist some processes that wish to enter their critical section " Then only those processes that are not executing in their remainder sections can participate in the decision on which will enter its critical section. " The selection cannot be postponed indefinitely. 3. Bounded Waiting: " A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
Image of page 5
Synchronization 6 11 The Critical-Section Problem (cont’d) ! The code implementing an operating system (kernel code) is subject to several possible race conditions. " For instance: $ A kernel data structure that maintains a list of all open files in the system. $ If two processes were to open files simultaneously, the updates to this list could result in a race condition. " Other kernel data structures: structures for maintaining memory allocation, for maintaining process lists … ! The kernel developers have to ensure that the operating system is free from such race conditions. 12 The Critical-Section Problem (cont’d) !
Image of page 6

Subscribe to view the full document.

Image of page 7
You've reached the end of this preview.
  • Spring '12
  • GwangS.Jung
  • producer, monitor

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern