Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy
|
|
- Norman Cain
- 6 years ago
- Views:
Transcription
1 Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com eaymanelshenawy@yahoo.com Reference Operating System Concepts, ABRAHAM SILBERSCHATZ
2 Chapter 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization Examples Atomic Transactions
3 Background Independent Process: Cannot affect /affected by the other executing processes in the system Does not share data with any other process. Cooperative Process: can affect /affected by the other executing processes in the system: Shares data with other processes. Require an Inter-Process Communication (IPC) mechanism to exchange Information. IPC Models (Shared memory or Message passing). Concurrent access to shared data may result in data inconsistency problem (consumer-producer problem). Solution: A mechanisms to ensure the orderly execution of cooperating processes. A solution to the consumer-producer problem that fills all the buffers. Having an integer count to keep track of the number of full buffers (Initially, count = 0). It is incremented / decremented by the producer after it produces/consumes a buffer.
4 Producer-consumer The producer and consumer routines are correct separately. They may not function correctly when executed concurrently. Let count = 5 and the producer and consumer processes execute the statements ++count and --count concurrently. Count may be 4, 5, or 6! And correct count == 5.
5 implemented in machine language counter++ register1 = counter register1 = register1 + 1 counter = register1 counter register2 = counter register2 = register2-1 count = register2 Consider this execution interleaving with count = 5 initially: We would arrive at this incorrect state because we allowed both processes to manipulate the variable counter concurrently. S0: producer execute register1 = counter {register1 = 5} S1: producer execute register1 = register1 + 1 {register1 = 6} S2: consumer execute register2 = counter {register2 = 5} S3: consumer execute register2 = register2-1 {register2 = 4} S4: producer execute counter = register1 {count = 6 } S5: consumer execute counter = register2 {count = 4 } If S4 and S5 are reserved
6 Race Condition: Several processes access and manipulate the same data concurrently and the output depends on the particular order. Ensure that only one process at a time can be manipulating the variable counter. Processes must be synchronized in some way. Different parts of the system manipulate resources. With the growth of multicore systems, multithreaded applications. Any changes that result from such activities not to interfere with one another
7 Critical Section Problem Consider a system consisting of N processes {P 0, P 1,..., P N 1 }. Each process has a segment of code, called a critical section. Critical section: is the segment of code of process used for changing common variables, updating table, writing file, etc. What is required? When one process is executing in its critical section, no other process is allowed to execute in its critical section. The critical-section problem is to design a protocol that the processes can use to cooperate. Each process must request permission to enter its critical section (execute section of code called the entry section). The critical section may be followed by executing section of code exit section. The remaining code (remainder section).
8 Critical Section Problem A solution to the critical-section problem must satisfy the following 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 some processes wish to enter their critical sections Those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely. 3. Bounded waiting. There exists a bound, or limit, 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.
9 Critical Section Problem
10 Critical Section Problem Does the operating system is free from such race conditions? An operating system (kernel code) is subject to several possible race conditions. Example 1: a kernel data structure that maintains a list of all open files in the system. This list must be modified when a new file is opened or closed (adding the file to the list or removing it from the list). If two processes were to open files simultaneously, the separate updates to this list could result in a race condition. Example 2: Structures for maintaining memory allocation, process lists and interrupt handling. Solution: Two general approaches are used to handle critical sections in OS: Preemptive kernels: Allows a process to be preempted while it is running in kernel mode. Must be carefully designed to ensure that shared kernel data are free from race conditions A non-preemptive kernel: does not allow a process running in kernel mode to be preempted; (only one process is active in the kernel at a time) No Race conditions.
11 Peterson s Solution Two process solution P1, P2 The two processes share two variables: int turn; Turn = i then process Pi is allowed to execute in its critical section Boolean flag[2] flag[i] = true implies that process P i is ready to enter its critical section. Each Pi enters its critical section only if either flag[j] = false or turn = i. if both processes can be executing in their critical sections at the same time, then flag[0] = flag[1] = true. And the value of turn can be either 0 or 1 but cannot be both.
12 Peterson s Solution
13 Synchronization Hardware Hardware features can make any programming task easier and improve system efficiency. Many systems provide hardware support for critical section code Uniprocessors could disable interrupts Currently running code would execute without preemption Generally too inefficient on multiprocessor systems OS using this not broadly scalable Problems: Disabling interrupts on a multiprocessor can be time consuming. It is not wise to give the user the power of turning INT on and off. ( one make it on and forget to turn it off) Modern machines provide special atomic hardware instructions Atomic = non-interruptable Either test memory word and set value Or swap contents of two memory words
14 TestAndSet Instruction The important characteristic of this instruction is that it is executed atomically. If two get-and-set instructions are executed simultaneously (each on a different CPU), they will be executed sequentially in some arbitrary order.
15 Solution to Critical-section Problem Using Mutex Locks Disadvantage: It require busy waiting. Any process tries to enter its critical section must loop continuously in the call to acquire(). Busy waiting wastes CPU cycles that some other process might be able to use productively. Software approach. mutex is short for mutual exclusion. Used to protect critical regions and thus prevent race conditions. A process must acquire the lock before entering a critical section; it releases the lock when it exits the critical section.
16 Swap Instruction Definition: void Swap (boolean *a, boolean *b) { boolean temp = *a; *a = *b; *b = temp; } Shared Boolean variable lock initialized to FALSE; Each process has a local Boolean variable key Solution: do { key = TRUE; while ( key == TRUE) Swap (&lock, &key ); // critical section key = FALSE; // remainder section } while (TRUE);
17 Semaphore The hardware-based solutions to the critical-section problem are complicated for application programmers to use. A synchronization tool called a semaphore can be used. A semaphore S contains an integer variable that initialized and accessed only through two standard operations: acquire() and release(). Some times termed P&V (to test and to increment). Modifications to the integer value of the semaphore in the acquire() and release() operations must be executed indivisibly (only one thread can modify the semaphore at a time). OS often distinguish between counting and binary semaphores. Counting semaphore The value can range over an unrestricted domain. Binary semaphore The value can range only between 0 and 1 (known mutex locks in some OS).
18 Semaphore Implementation Using Java
19 Semaphore Usage 1. Controlling access to a given resource consisting of a finite number of instances. The semaphore is initialized to the number of resources available. Each thread that wishes to use a resource performs an acquire(). When a thread releases a resource, it performs a release() operation. When the count =0 means that all resources are being used (any thread that wish to use a resource will block until the count becomes greater than 0). 2. solve various synchronization problems. Two concurrently running processes: P1 run S1 and P2 run S2. Suppose we require that S2 be executed only after S1 has completed. by letting P1 and P2 share a common semaphore synch, initialized to 0. Because synch is initialized to 0, P2 will execute S2 only after P1 has invoked synch.release(),which is after statement S1 has been executed.
20 Semaphore Implementation Problem: Requires busy waiting. While a process is in its critical section, any other process that tries to enter its critical section must loop continuously in the entry code (clear problem in a multiprogramming system). Busy waiting wastes CPU cycles that some other process might be able to use productively. Solution Modify the acquire() and release() semaphore operations. Instead the process continue looping it can block itself. The block operation places a process into a waiting queue of the semaphore, and change the state from running to waiting. The CPU scheduler can selects another process to execute. The blocked process should be restarted when some other process executes a release() operation using wakeup() operation (changes the process from the waiting state to the ready state).
21 Semaphore Solution to Busy waiting problem Semaphore Implementation Using Java
22 Deadlock and starvation The semaphore implementation with a waiting queue may result in a Deadlock situation A system consisting of two processes, P0 and P1, each accessing two semaphores, S and Q, set to the value 1 Scenario: P0 executes S.acquire(), and P1 executes Q.acquire() S & Q=0. P0 executes Q.acquire(), it must wait until P1 executes Q.release(). P1 executes S.acquire(), it must wait until P0 executes S.release(). These operations cannot be executed, P0 and P1 are deadlocked. Dead Lock: Two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes. Indefinite blocking, or starvation A processes wait indefinitely within the semaphore (if we add and remove processes from the list associated with a semaphore in (LIFO) order.
23 Priority Inversion A higher-priority process needs to modify kernel data that are currently being accessed by a lower-priority processes. Since kernel data are typically protected with a lock, the higher-priority process will have to wait for a lower-priority one to finish. The situation becomes more complicated if the lower-priority process is preempted in favor of another process with a higher priority. Example: assume three processes, L priority < M priority < H priority. and process H requires resource R, which is locked by process L. Process H would wait for L to finish using resource R. If process M becomes runnable, thereby preempting process L. Indirectly, a process with a lower priority process M has affected how long process H must wait for L to use resource R. Solution: Use only one priority. The Process that access the resource inherit the high priority (Priority inheritance Protocol)
24 Classical Problems of Synchronization Classical problems used to test newly-proposed synchronization schemes Bounded-Buffer Problem Readers and Writers Problem Dining-Philosophers Problem
25 Bounded-Buffer Problem N buffers, each can hold one item Semaphore mutex initialized to the value 1 Semaphore full initialized to the value 0 Semaphore empty initialized to the value N
26 Bounded-Buffer Problem
27 Reader and Writer problem A database is to be shared among several concurrent processes, some of them are readers and the other are writers (read and write=update) the Database. If two readers access the shared data simultaneously, no effects. if a writer and some reader access the database simultaneously, a problem may occur. Writers must have exclusive access to the shared database. No reader should wait for other readers to finish simply because a writer is waiting. Once a writer is ready, that writer perform its write as soon as possible
28 Reader and Writer problem
29 Dining-Philosophers Problem 5 philosophers (PH) spend their lives thinking and eating. They share a circular table with five chairs, each belonging to one PH. In the center of the table is a bowl of rice, and a five single chopsticks When a PH thinks, she does not interact with others. When he gets hungry and tries to pick up the two chopsticks that are closest to her. A PH may pick up only one chopstick at a time. He cannot pick up a chopstick that is already in the hand of a neighbor. When a hungry PH has both her chopsticks at the same time, she eats without releasing her chopsticks. When she is finished eating, she puts down both of her chopsticks and starts thinking again. Representation of the need to allocate several resources among several processes in a deadlock-free and starvationfree manner.
30 Dining-Philosophers Problem-solution Represent each chopstick with a semaphore. A philosopher tries to grab the chopstick by executing an acquire() operation; she releases a chopstick by executing the release() operation. This Solution Have A Problems & not Acceptable it has the possibility of creating a deadlock
31 Dining-Philosophers Problem-solution Suppose that all five philosophers become hungry simultaneously and each grabs her left chopstick. All the elements of chopstick will now be equal to 0. When each philosopher tries to grab her right chopstick, she will be delayed forever. Possible solutions by placing restrictions on the philosophers: 1. Allow at most four philosophers to be sitting simultaneously at the table. 2. Allow a philosopher to pick up her chopsticks only if both chopsticks are available (note that she must pick them up in a critical section). 3. Use an asymmetric solution; for example, an odd philosopher picks up first her left chopstick and then her right chopstick, whereas an even philosopher picks up her right chopstick and then her left chopstick.
32 End of Chapter 6
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic
More informationChapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.
Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure
More informationChapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationInterprocess Communication By: Kaushik Vaghani
Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the
More informationChapter 6: Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationProcess Synchronization
CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem
More informationProcess Synchronization
Process Synchronization Chapter 6 2015 Prof. Amr El-Kadi Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationLesson 6: Process Synchronization
Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization
More informationCHAPTER 6: PROCESS SYNCHRONIZATION
CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background
More informationSynchronization Principles
Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,
More informationChapter 6: Process Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L11 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel feedback queue:
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Chapter 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization
More informationProcess Management And Synchronization
Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data may result in data inconsistency Multiple threads in a single process Maintaining data consistency requires mechanisms to ensure the orderly execution
More informationModule 6: Process Synchronization. Operating System Concepts with Java 8 th Edition
Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationProcess Co-ordination OPERATING SYSTEMS
OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne 1 PROCESS - CONCEPT Processes executing concurrently in the
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Operating System Concepts 9th Edition Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationSynchronization. Race Condition. The Critical-Section Problem Solution. The Synchronization Problem. Typical Process P i. Peterson s Solution
Race Condition Synchronization CSCI 315 Operating Systems Design Department of Computer Science A race occurs when the correctness of a program depends on one thread reaching point x in its control flow
More informationChapter 6: Process Synchronization. Module 6: Process Synchronization
Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationOperating Systems Antonio Vivace revision 4 Licensed under GPLv3
Operating Systems Antonio Vivace - 2016 revision 4 Licensed under GPLv3 Process Synchronization Background A cooperating process can share directly a logical address space (code, data) or share data through
More informationChapter 7: Process Synchronization!
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors 7.1 Background Concurrent access to shared
More informationModule 6: Process Synchronization
Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization Examples Atomic
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS
More informationProcess Synchronization
TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Process Synchronization [SGG7] Chapter 6 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin
More informationChapter 6: Process Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationChapter 6: Process Synchronization
Module 6: Process Synchronization Chapter 6: Process Synchronization Background! The Critical-Section Problem! Peterson s Solution! Synchronization Hardware! Semaphores! Classic Problems of Synchronization!
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data in the data section of a multi-thread process, in the shared memory of multiple processes, or in a shared file Although every example in this chapter
More informationDept. of CSE, York Univ. 1
EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared
More informationMaximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait
Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling Algorithm Evaluation CPU
More informationCS420: Operating Systems. Process Synchronization
Process Synchronization James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013! Chapter 5: Process Synchronization Background" The Critical-Section Problem" Petersons Solution" Synchronization Hardware" Mutex
More informationProcess Synchronization
CS307 Process Synchronization Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Background Concurrent access to shared data may result in data inconsistency
More informationProcess Synchronization
Process Synchronization Daniel Mosse (Slides are from Silberschatz, Galvin and Gagne 2013 and Sherif Khattab) Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution
More informationCSE 4/521 Introduction to Operating Systems
CSE 4/521 Introduction to Operating Systems Lecture 7 Process Synchronization II (Classic Problems of Synchronization, Synchronization Examples) Summer 2018 Overview Objective: 1. To examine several classical
More informationChapter 6 Synchronization
Chapter 6 Synchronization Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 Outline Background The Critical-Section
More informationIV. Process Synchronisation
IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.
More informationSemaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }
Semaphore Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() and V() Can only be accessed via two indivisible (atomic) operations wait (S) { while
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationProcess Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Process Synchronization: Semaphores CSSE 332 Operating Systems Rose-Hulman Institute of Technology Critical-section problem solution 1. Mutual Exclusion - If process Pi is executing in its critical section,
More informationWhat is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?
What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular
More informationChapter 6 Process Synchronization
Chapter 6 Process Synchronization Cooperating Process process that can affect or be affected by other processes directly share a logical address space (threads) be allowed to share data via files or messages
More informationProcess Synchronization. CISC3595, Spring 2015 Dr. Zhang
Process Synchronization CISC3595, Spring 2015 Dr. Zhang 1 Concurrency OS supports multi-programming In single-processor system, processes are interleaved in time In multiple-process system, processes execution
More informationChapter 7: Process Synchronization. Background. Illustration
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationProcess Synchronization
Chapter 7 Process Synchronization 1 Chapter s Content Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors 2 Background
More informationLecture 3: Synchronization & Deadlocks
Lecture 3: Synchronization & Deadlocks Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationChapter 7: Process Synchronization. Background
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationEI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)
EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) Dept. of Computer Science & Engineering Chentao Wu wuct@cs.sjtu.edu.cn Download lectures ftp://public.sjtu.edu.cn User:
More informationOS Process Synchronization!
OS Process Synchronization! Race Conditions! The Critical Section Problem! Synchronization Hardware! Semaphores! Classical Problems of Synchronization! Synchronization HW Assignment! 3.1! Concurrent Access
More informationProcess Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212
Operating Systems Spring 2009-2010 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) 2 Announcements Presentations: will be held on last teaching week during lectures make a 20-minute
More information1. Motivation (Race Condition)
COSC4740-01 Operating Systems Design, Fall 2004, Byunggu Yu Chapter 6 Process Synchronization (textbook chapter 7) Concurrent access to shared data in the data section of a multi-thread process, in the
More informationUNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01
1 UNIT 2 Basic Concepts of CPU Scheduling UNIT -02/Lecture 01 Process Concept An operating system executes a variety of programs: **Batch system jobs **Time-shared systems user programs or tasks **Textbook
More informationSynchronization. CS 475, Spring 2018 Concurrent & Distributed Systems
Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE
More informationConcurrency. Chapter 5
Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits
More informationCSE Opera,ng System Principles
CSE 30341 Opera,ng System Principles Synchroniza2on Overview Background The Cri,cal-Sec,on Problem Peterson s Solu,on Synchroniza,on Hardware Mutex Locks Semaphores Classic Problems of Synchroniza,on Monitors
More informationDealing with Issues for Interprocess Communication
Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed
More informationProcess Synchronization (Part I)
Process Synchronization (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Process Synchronization 1393/7/14 1 / 44 Motivation
More informationUNIT II PROCESS MANAGEMENT 9
UNIT II PROCESS MANAGEMENT 9 Processes-Process Concept, Process Scheduling, Operations on Processes, Interprocess Communication; Threads- Overview, Multicore Programming, Multithreading Models; Windows
More informationChapters 5 and 6 Concurrency
Operating Systems: Internals and Design Principles, 6/E William Stallings Chapters 5 and 6 Concurrency Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Concurrency When several processes/threads
More informationReal-Time Operating Systems M. 5. Process Synchronization
Real-Time Operating Systems M 5. Process Synchronization Notice The course material includes slides downloaded from: http://codex.cs.yale.edu/avi/os-book/ and (slides by Silberschatz, Galvin, and Gagne,
More informationIntroduction to Operating Systems
Introduction to Operating Systems Lecture 4: Process Synchronization MING GAO SE@ecnu (for course related communications) mgao@sei.ecnu.edu.cn Mar. 18, 2015 Outline 1 The synchronization problem 2 A roadmap
More informationProcess Synchronization(2)
CSE 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Computer Science and Engineering York University Semaphores Problems with the software solutions. Not easy
More informationBackground. Module 6: Process Synchronization. Bounded-Buffer (Cont.) Bounded-Buffer. Background
Module 6: Process Synchronization Background Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 12 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ 2 Mutex vs Semaphore Mutex is binary,
More informationPROCESS SYNCHRONIZATION
PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationProcess Synchronization. studykorner.org
Process Synchronization Semaphore Implementation Must guarantee that no two processes can execute wait () and signal () on the same semaphore at the same time The main disadvantage of the semaphore definition
More informationProcess Synchronisation (contd.) Operating Systems. Autumn CS4023
Operating Systems Autumn 2017-2018 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) Synchronization Hardware 6.4 (SGG) Many systems provide hardware support for critical section
More informationProcess Coordination
Process Coordination Why is it needed? Processes may need to share data More than one process reading/writing the same data (a shared file, a database record, ) Output of one process being used by another
More informationCS3502 OPERATING SYSTEMS
CS3502 OPERATING SYSTEMS Spring 2018 Synchronization Chapter 6 Synchronization The coordination of the activities of the processes Processes interfere with each other Processes compete for resources Processes
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationConcurrency: Mutual Exclusion and
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationModule 6: Process Synchronization
Module 6: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationChapter 6: Synchronization
Chapter 6: Synchronization Module 6: Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationCSC501 Operating Systems Principles. Process Synchronization
CSC501 Operating Systems Principles Process Synchronization 1 Last Lecture q Process Scheduling Question I: Within one second, how many times the timer interrupt will occur? Question II: Within one second,
More informationProcess Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008
Process Synchronization Mehdi Kargahi School of ECE University of Tehran Spring 2008 Producer-Consumer (Bounded Buffer) Producer Consumer Race Condition Producer Consumer Critical Sections Structure of
More informationChapter 5 Asynchronous Concurrent Execution
Chapter 5 Asynchronous Concurrent Execution Outline 5.1 Introduction 5.2 Mutual Exclusion 5.2.1 Java Multithreading Case Study 5.2.2 Critical Sections 5.2.3 Mutual Exclusion Primitives 5.3 Implementing
More informationLecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)
Lecture Topics Today: Concurrency (Stallings, chapter 5.1-5.4, 5.7) Next: Exam #1 1 Announcements Self-Study Exercise #5 Project #3 (due 9/28) Project #4 (due 10/12) 2 Exam #1 Tuesday, 10/3 during lecture
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L10 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Development project: You
More informationSubject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)
A. Multiple Choice Questions (60 questions) Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering) Unit-I 1. What is operating system? a) collection of programs that manages hardware
More informationSynchronization COMPSCI 386
Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose
More informationBackground. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.
Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency
More informationSynchronization. CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10)
Synchronization CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10) 1 Outline Critical region and mutual exclusion Mutual exclusion using busy waiting Sleep and
More informationProcess Synchronization
Process Synchronization Mandar Mitra Indian Statistical Institute M. Mitra (ISI) Process Synchronization 1 / 28 Cooperating processes Reference: Section 4.4. Cooperating process: shares data with other
More informationMutual Exclusion and Synchronization
Mutual Exclusion and Synchronization Concurrency Defined Single processor multiprogramming system Interleaving of processes Multiprocessor systems Processes run in parallel on different processors Interleaving
More informationLecture 5: Inter-process Communication and Synchronization
Lecture 5: Inter-process Communication and Synchronization Real-Time CPU Scheduling Periodic processes require the CPU at specified intervals (periods) p is the duration of the period d is the deadline
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationOperating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017
Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing
More informationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationR13 SET - 1 2. Answering the question in Part-A is compulsory 1 a) Define Operating System. List out the objectives of an operating system. [3M] b) Describe different attributes of the process. [4M] c)
More informationCS3733: Operating Systems
Outline CS3733: Operating Systems Topics: Synchronization, Critical Sections and Semaphores (SGG Chapter 6) Instructor: Dr. Tongping Liu 1 Memory Model of Multithreaded Programs Synchronization for coordinated
More informationSilberschatz and Galvin Chapter 6
Silberschatz and Galvin Chapter 6 Process Synchronization CPSC 410--Richard Furuta 2/26/99 1 Topics discussed Process synchronization Mutual exclusion--hardware Higher-level abstractions Ð Semaphores Ð
More informationChapter 6: Process Synchronization. Operating System Concepts 9 th Edit9on
Chapter 6: Process Synchronization Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Objectives To present the concept of process synchronization. To introduce the critical-section
More informationPart II Process Management Chapter 6: Process Synchronization
Part II Process Management Chapter 6: Process Synchronization 1 Process Synchronization Why is synchronization needed? Race Conditions Critical Sections Pure Software Solutions Hardware Support Semaphores
More information