Lecture Operating system principles - Chapter 5: Concurrency: Mutual exclusion and synchronization

After studying this chapter, you should be able to: Discuss basic concepts related to concurrency, such as race conditions, OS concerns, and mutual exclusion requirements; understand hardware approaches to supporting mutual exclusion; define and explain semaphores; define and explain monitors. | Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem Multiple Processes Central to the design of modern Operating Systems is managing multiple processes Multiprogramming Multiprocessing Distributed Processing Big Issue is Concurrency Managing the interaction of all of these processes Interleaving and Overlapping Processes Earlier (Ch2) we saw that processes may be interleaved on uniprocessors Interleaving and Overlapping Processes And not only interleaved but overlapped on multi-processors Both interleaving and overlapping present the same problems in concurrent processing One Difficulty of Concurrency Sharing of global resources can be problematic A Simple Example void echo() { // send a keyboard-input character to display chin = getchar(); chout = chin; putchar(chout); } What would happen if P1 is interrupted here by P2? Suppose echo is a shared procedure and P1 . | Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem Multiple Processes Central to the design of modern Operating Systems is managing multiple processes Multiprogramming Multiprocessing Distributed Processing Big Issue is Concurrency Managing the interaction of all of these processes Interleaving and Overlapping Processes Earlier (Ch2) we saw that processes may be interleaved on uniprocessors Interleaving and Overlapping Processes And not only interleaved but overlapped on multi-processors Both interleaving and overlapping present the same problems in concurrent processing One Difficulty of Concurrency Sharing of global resources can be problematic A Simple Example void echo() { // send a keyboard-input character to display chin = getchar(); chout = chin; putchar(chout); } What would happen if P1 is interrupted here by P2? Suppose echo is a shared procedure and P1 echoes ‘x’ and P2 echoes ‘y’ What would happen if only one process is permitted at a time to be in the procedure? A Simple Example: On a Multiprocessor Process P1 Process P2 . . chin = getchar(); . . chin = getchar(); chout = chin; chout = chin; putchar(chout); . . putchar(chout); . . Enforce Single Access If we enforce a rule that only one process may enter the function at a time then: P1 & P2 run on separate processors P1 enters echo first, P2 tries to enter but is blocked P1 completes execution P2 resumes and executes echo Solution: Control access to shared resource Competition among Processes for Resources Three main control problems: Need for Mutual Exclusion Only one program at a time be allowed in its critical section. Critical resource: nonsharable resource, ., printer Critical section: portion of the program that uses a critical resource Deadlock Starvation Requirements for Mutual Exclusion Only one process at a time is allowed in the critical section for a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
96    400    2    29-04-2024
Đã 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.