tailieunhanh - Lecture Operating system concepts - Module 6
In this chapter, you will learn to: To describe the basic organization of computer systems, to provide a grand tour of the major components of operating systems, to give an overview of the many types of computing environments, to explore several open-source operating systems. | Module 6: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris 2 Atomic Transactions Operating System Concepts Background Concurrent access to shared data may result in data inconsistency. Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. Shared-memory solution to bounded-butter problem (Chapter 4) allows at most n – 1 items in buffer at the same time. A solution, where all N buffers are used is not simple. Suppose that we modify the producer-consumer code by adding a variable counter, initialized to 0 and incremented each time a new item is added to the buffer Operating System Concepts Bounded-Buffer Shared data type item = ; var buffer array [0n-1] of item; in, out: 0n-1; counter: 0n; in, out, counter := 0; Producer process repeat produce an item in nextp while counter = n do . | Module 6: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris 2 Atomic Transactions Operating System Concepts Background Concurrent access to shared data may result in data inconsistency. Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. Shared-memory solution to bounded-butter problem (Chapter 4) allows at most n – 1 items in buffer at the same time. A solution, where all N buffers are used is not simple. Suppose that we modify the producer-consumer code by adding a variable counter, initialized to 0 and incremented each time a new item is added to the buffer Operating System Concepts Bounded-Buffer Shared data type item = ; var buffer array [0n-1] of item; in, out: 0n-1; counter: 0n; in, out, counter := 0; Producer process repeat produce an item in nextp while counter = n do no-op; buffer [in] := nextp; in := in + 1 mod n; counter := counter +1; until false; Operating System Concepts Bounded-Buffer (Cont.) Consumer process repeat while counter = 0 do no-op; nextc := buffer [out]; out := out + 1 mod n; counter := counter – 1; consume the item in nextc until false; The statements: counter := counter + 1; counter := counter - 1; must be executed atomically. Operating System Concepts The Critical-Section Problem n processes all competing to use some shared data Each process has a code segment, called critical section, in which the shared data is accessed. Problem – ensure that when one process is executing in its critical section, no other process is allowed to execute in its critical section. Structure of process Pi repeat entry section critical section exit section reminder section until false; Operating System Concepts Solution to Critical-Section Problem 1. Mutual Exclusion. If process Pi is executing in its critical section, then no other processes can .
đang nạp các trang xem trước