TAILIEUCHUNG - Operating System Concepts (6)

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. Silberschatz and Galvin 1999 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. Silberschatz and Galvin 1999 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;. Silberschatz and Galvin 1999 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 Silberschatz and Galvin 1999 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; Silberschatz and Galvin 1999 Solution to Critical-Section . Mutual Exclusion. If process Pi is executing in its critical. section, then no other processes can be executing in their critical. sections2. Progress. If no process is executing in its critical section and. there exist some processes that wish to enter their critical. section, then the selection of the processes that will enter the. critical section next cannot be postponed indefinitely3. 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 Assume that each process executes at a nonzero speed. No assumption concerning relative speed of the n. processes Silberschatz and Galvin 1999 Initial Attempts to Solve Problem.• Only 2 processes, P0 and P1• General structur

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.