L5_process Synchronization1 - P r o c e s d i n a t How do...

Info icon This preview shows pages 1–19. Sign up to view the full content.

View Full Document Right Arrow Icon
Process coordination
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
How do we maximize CPU utilization / improve efficiency? Multiprogramming Multiprocessing
Image of page 2
Concurrent operation In uni-processor system Processes are interleaved in time In multiprocessor system processes are overlapped
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Interleaving P1 P2 P3
Image of page 4
Overlapping P1 P2 P3
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Concurrent operation Interleaving and overlapping improves processing efficiency Interleaved /overlapped process may produce unpredictable results if not controlled properly
Image of page 6
Why Problem arises with Interleaving & overlapping Finite resources Relative speed of execution of processes can not be predicted Sharing of resources(non shareable ) among processes Sharing of memory is required for Inter process communication
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Example Procedure echo; Var out,in:Character; Begin input (in, keyboard); out:=in; output(out,Display) End
Image of page 8
Process p1 1. input (in, keyboard); 2. ------------------ 3. ------------------ 4. ------------------ 5. out:=in; 6. output(out,Display ) Process P2 1. -------- 2. input (in, keyboard); 3. out:=in; 4. output(out,Display )
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Operating system concern The result of a process must be independent of the speed at which the execution is carried out
Image of page 10
We need to understand: How processes interact? The problem is faced as system has several resources which are to be shared among the processes In system we have processes which are unaware of existence of other processes and such processes compete for resources Processes indirectly aware of each other such processes exhibit cooperation Processes directly aware of each other, show cooperation
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
When Processes compete for resources,the problem of deadlock , mutual exclusion and starvation may occur When processes are directly aware of other processes, the problem of deadlock and starvation still might exist
Image of page 12
Concurrency control problem Mutual exclusion Starvation Deadlock
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Cooperating & competing processes can cause problem when executed concurrently
Image of page 14
How Processes cooperation is achieved ? Shared Memory Mutual exclusion Message passing
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Solution to critical section problem Successful use of concurrency requires Ability to define critical section Enforce mutual exclusion Any Solution to critical section problem must satisfy Mutual exclusion Progress : when no process in critical section, any process that makes a request for critical section is allowed to enter critical section without any delay Processes requesting critical section should not be delayed indefinitely (no deadlock, starvation) No assumption should be made about relative execution speed of processes or number of processes A process remains inside critical section for a finite amount of time
Image of page 16
Approach to handle Mutual Exclusion Software Approach ( User is responsible for enforcing Mutual exclusion) Hardware Support Disabling of Interrupt Special Instructions OS support Semaphore Monitor
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Software Approach ( Solution 1) Var turn :0..1; Process 0 ------ ------ While turn <>0 do { nothing}; < Critical Section code >; Turn := 1; Process 1 While turn <>1 do { nothing}; Turn := 0;
Image of page 18
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern