TAILIEUCHUNG - Lecture Operating system concepts - Chapter 7: Process synchronization

Chapter 7 is concerned with the topic of process synchronization among concurrently executing processes. Concurrency is generally very hard for students to deal with correctly, and so we have tried to introduce it and its problems with the classic process coordination problems: mutual exclusion, bounded-buffer, readers/writers, and so on. An understanding of these problems and their solutions is part of current operating-system theory and development. | Chapter 7: Process Synchronization I Background I The Critical-Section Problem I Synchronization Hardware I Semaphores I Classical Problems of Synchronization I Critical Regions I Monitors I Synchronization in Solaris 2 & Windows 2000 Operating System Concepts Silberschatz, Galvin and Gagne 2002 Background I Concurrent access to shared data may result in data inconsistency. I Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes. I 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 Silberschatz, Galvin and Gagne 2002 Bounded-Buffer I Shared data #define BUFFER_SIZE 10 typedef struct { . } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; int counter = 0; Operating System Concepts Silberschatz, Galvin and Gagne 2002 Bounded-Buffer I Producer process item nextProduced; while (1) { while (counter == BUFFER_SIZE) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; counter++; } Operating System Concepts Silberschatz, Galvin and Gagne 2002 Bounded-Buffer I Consumer process item nextConsumed; while (1) { while (counter == 0) ; /* do nothing */ nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; } Operating System Concepts Silberschatz, Galvin and Gagne 2002 Bounded Buffer I The statements counter++; counter--; must be performed atomically. I Atomic operation means an operation that completes in its entirety without interruption. Operating System Concepts Silberschatz, Galvin and Gagne 2002 Bounded Buffer I The statement “count++” may be implemented in machine language as: register1 = counter register1 = .

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.