Understanding Operating Systems: Concurrent Processes PDF

Document Details

ComplimentarySugilite6654

Uploaded by ComplimentarySugilite6654

Universiti Malaysia Sarawak (UNIMAS)

Tags

concurrent programming multiprocessing operating systems parallel processing

Summary

This document covers concurrent processes within operating systems discussing multiprocessing and parallel processing concepts. Topics include concurrent programming, thread states, and processor configurations.

Full Transcript

CHAPTER 6 UNDERSTANDING OPERATING LECTURE 7: CONCURRENT PROCESSES After completing this chapter, you should be able to describe:  The critical difference between processes and processors, and their connection  The differences among common configurations of multiproc...

CHAPTER 6 UNDERSTANDING OPERATING LECTURE 7: CONCURRENT PROCESSES After completing this chapter, you should be able to describe:  The critical difference between processes and processors, and their connection  The differences among common configurations of multiprocessing systems  The significance of a critical region in process synchronization  The basic concepts of process synchronization software: test-and- set, WAIT and SIGNAL, and semaphores 2  The need for process cooperation when several processes work together  How several processors, executing a single job, cooperate  The similarities and differences between processes and threads  The significance of concurrent programming languages and their applications 3 Parallel processing  Multiprocessing  Two or more processors operate in unison  Two or more CPUs execute instructions simultaneously  Processor Manager  Coordinates activity of each processor  Synchronizes interaction among CPUs First of all, understand what is a Multiprocessing system, click on https://www.youtube.com/watch?v=IZfWjg3U3mA 4  Parallel processing development  Enhances throughput  Increases computing power  *Benefits  Increased reliability  More than one CPU  If one processor fails, others take over  Not simple to implement  Faster processing  Instructions processed in parallel two or more at a time 5  Faster instruction processing methods  CPU allocated to each program or job  CPU allocated to each working set or parts of it  Individual instructions subdivided  Each subdivision processed simultaneously  Concurrent programming  -Two major challenges  Connecting processors into configurations  Orchestrating processor interaction  Example: six-step information retrieval system  Synchronization is key 6 Understanding Operating Systems, Sixth Edition 7  Developed for high-end midrange and mainframe computers  Each additional CPU treated as additional resource  Today hardware costs reduced (Moore’s law)  Multiprocessor systems available on all systems  Multiprocessing occurs at three levels  Job level  Process level  Thread level  Each requires different synchronization frequency Understanding Operating Systems, Sixth Edition 8 Understanding Operating Systems, Sixth Edition 9  Multi-core processing  Several processors placed on single chip  Problems  Heat and current leakage (tunneling)  Solution  Single chip with two processor cores in same space  Allows two sets of simultaneous calculations  80 or more cores on single chip  Two cores each run more slowly than single core chip Understanding Operating Systems, Sixth Edition 10  Multiple processor configuration impacts systems  *Three types  Master/slave  Loosely coupled  Symmetric To understand more onTypes of Multiprocessing system, click on https://www.youtube.com/watch?v=So9SR3qpWsM 11  Asymmetric multiprocessing system  Single-processor system  Additional slave processors  Each managed by primary master processor  Master processor responsibilities  Manages entire system  Maintains all processor status  Performs storage management activities  Schedules work for other processors  Executes all control programs Understanding Operating Systems, Sixth Edition 12 Understanding Operating Systems, Sixth Edition 13  Advantages  Simplicity  Disadvantages  Reliability  No higher than single processor system  Potentially poor resources usage  Increases number of interrupts Understanding Operating Systems, Sixth Edition 14  Several complete computer systems  Each with own resources  Maintains commands and I/O management tables  Independent single-processing difference  Each processor  Communicates and cooperates with others  Has global tables  Several requirements and policies for job scheduling  Single processor failure  Others continue work independently  Difficult to detect Understanding Operating Systems, Sixth Edition 15 Understanding Operating Systems, Sixth Edition 16  Decentralized processor scheduling  Each processor is same type  Advantages (over loosely coupled configuration)  More reliable  Uses resources effectively  Can balance loads well  Can degrade gracefully in failure situation  Most difficult to implement  Requires well synchronized processes  Avoids races and deadlocks Understanding Operating Systems, Sixth Edition 17 Understanding Operating Systems, Sixth Edition 18  Decentralized process scheduling  Single operating system copy  Global table listing  Interrupt processing  Update corresponding process list  Run another process  More conflicts  Several processors access same resource at same time  Process synchronization  Algorithms resolving conflicts between processors Understanding Operating Systems, Sixth Edition 19  Successful process synchronization  Lock up used resource  Protect from other processes until released  Only when resource is released  Waiting process is allowed to use resource  Mistakes in synchronization can result in:  Starvation  Leave job waiting indefinitely  Deadlock  If key resource is being used Understanding Operating Systems, Sixth Edition 20  Critical region  Part of a program  Critical region must complete execution  Other processes must wait before accessing critical region resources  Processes within critical region  Cannot be interleaved  Threatens integrity of operation To understand more on Process Synchronization Critical Region, click on https://www.youtube.com/watch?v=eKKc0d7kzww Understanding Operating Systems, Sixth Edition 21  Synchronization  Implemented as lock-and-key arrangement:  Process determines key availability  Process obtains key  Puts key in lock  Makes it unavailable to other processes  Types of locking mechanisms  Test-and-set  WAIT and SIGNAL  Semaphores Understanding Operating Systems, Sixth Edition 22  Indivisible machine instruction (TS)  Executed in single machine cycle  If key available: set to unavailable  Actual key  Single bit in storage location: zero (free) or one (busy)  Before process enters critical region  Tests condition code using TS instruction  No other process in region  Process proceeds  Condition code changed from zero to one  P1 exits: code reset to zero, allowing others to enter Understanding Operating Systems, Sixth Edition 23  Advantages  Simple procedure to implement  Works well for small number of processes  Drawbacks  Starvation  Many processes waiting to enter a critical region  Processes gain access in arbitrary fashion  Busy waiting  Waiting processes remain in unproductive, resource-consuming wait loops Understanding Operating Systems, Sixth Edition 24  Modification of test-and-set  Designed to remove busy waiting  Two new mutually exclusive operations  WAIT and SIGNAL  Part of process scheduler’s operations  WAIT  Activated when process encounters busy condition code  SIGNAL  Activated when process exits critical region and condition code set to “free” Understanding Operating Systems, Sixth Edition 25  Nonnegative integer variable  Flag  Signals if and when resource is free  Resource can be used by a process  Two operations of semaphore  P (proberen means “to test”)  V (verhogen means “to increment”) Understanding Operating Systems, Sixth Edition 26 Understanding Operating Systems, Sixth Edition 27  Let s be a semaphore variable  V(s): s: = s + 1  Fetch, increment, store sequence  P(s): If s > 0, then s: = s – 1  Test, fetch, decrement, store sequence  s = 0 implies busy critical region  Process calling on P operation must wait until s > 0  Waiting job of choice processed next  Depends on process scheduler algorithm Understanding Operating Systems, Sixth Edition 28 Understanding Operating Systems, Sixth Edition 29  P and V operations on semaphore s  Enforce mutual exclusion concept  Semaphore called mutex (MUTual EXclusion) P(mutex): if mutex > 0 then mutex: = mutex – 1 V(mutex): mutex: = mutex + 1  *Critical region  Ensures parallel processes modify shared data only while in critical region  Parallel computations  Mutual exclusion explicitly stated and maintained To understand more on Semaphore, click on https://www.youtube.com/watch?v=DvF3AsTglUU&t=130s Understanding Operating Systems, Sixth Edition 30  Several processes work together to complete common task  Each case requires  Mutual exclusion and synchronization  Absence of mutual exclusion and synchronization  Results in problems  Examples  Producers and consumers problem  Readers and writers problem  Each case implemented using semaphores Understanding Operating Systems, Sixth Edition 31  One process produces data  Another process later consumes data  Example: CPU and line printer buffer  Delay producer: buffer full  Delay consumer: buffer empty  Implemented by two semaphores  Number of full positions  Number of empty positions  Mutex  Third semaphore: ensures mutual exclusion To understand more on Producer and Consumer problem, click on https://www.youtube.com/watch?v=LRiN3DJdskA Understanding Operating Systems, Sixth Edition 32 Understanding Operating Systems, Sixth Edition 33  Two process types need to access shared resource  Example: file or database  Example: airline reservation system  Implemented using two semaphores  Ensures mutual exclusion between readers and writers  Resource given to all readers  Provided no writers are processing (W2 = 0)  Resource given to a writer  Provided no readers are reading (R2 = 0) and no writers writing (W2 = 0) Understanding Operating Systems, Sixth Edition 34  Concurrent processing system  One job uses several processors  Executes sets of instructions in parallel  Requires programming language and computer system support Understanding Operating Systems, Sixth Edition 35 A = 3 * B * C + 4 / (D + E) ** (F – G) Understanding Operating Systems, Sixth Edition 36 A = 3 * B * C + 4 / (D + E) ** (F – G) Understanding Operating Systems, Sixth Edition 37 SUMMARY  Multiprocessing  Single-processor systems  Interacting processes obtain control of CPU at different times  Systems with two or more CPUs  Control synchronized by processor manager  Processor communication and cooperation  System configuration  Master/slave, loosely coupled, symmetric Understanding Operating Systems, Sixth Edition 38  Multiprocessing system success  Synchronization of resources  Mutual exclusion  Prevents deadlock  Maintained with test-and-set, WAIT and SIGNAL, and semaphores (P, V, and mutex)  Synchronize processes using hardware and software mechanisms Understanding Operating Systems, Sixth Edition 39  Avoid typical problems of synchronization  Missed waiting customers  Synchronization of producers and consumers  Mutual exclusion of readers and writers  Concurrent processing innovations  Threads and multi-core processors  Requires modifications to operating systems Understanding Operating Systems, Sixth Edition 40  Threads  Small unit within process  Scheduled and executed  Minimizes overhead  Swapping process between main memory and secondary storage  Each active process thread  Processor registers, program counter, stack and status  Shares data area and resources allocated to its process Understanding Operating Systems, Sixth Edition 41 Understanding Operating Systems, Sixth Edition 42  Operating system support  Creating new threads  Setting up thread  Ready to execute  Delaying or putting threads to sleep  Specified amount of time  Blocking or suspending threads  Those waiting for I/O completion  Setting threads to WAIT state  Until specific event occurs Understanding Operating Systems, Sixth Edition 43  Operating system support (cont'd.)  Scheduling thread execution  Synchronizing thread execution  Using semaphores, events, or conditional variables  Terminating thread  Releasing its resources Understanding Operating Systems, Sixth Edition 44  Information about current status and characteristics of thread Understanding Operating Systems, Sixth Edition 45  Ada  First language providing specific concurrency commands  Developed in late 1970’s  Java  Designed as universal Internet application software platform  Developed by Sun Microsystems  Adopted in commercial and educational environments Understanding Operating Systems, Sixth Edition 46

Use Quizgecko on...
Browser
Browser