This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Processes and Concurrent Process Control Processes, and their variant, threads, are the most essential elements in a computer system under the control of the operating system. Proper management of processes is critical in the correct functioning and efficient operation of the system. A process is a program in execution. It is created when a program’s execution is requested and initiated. Once created, a process goes through a number of states throughout its existence until it terminates. The following diagram depicts typical state transitions of a process. A sequential process is a process with a single thread of control regulating its execution. Concurrent processes refer to simultaneous interacting sequential processes. Concurrent processes are asynchronous, each with its own address space. Between two processes, some components are disjoint and can be executed concurrently while other components require communication and synchronization. A process may spawn new processes, resulting in multiple threads of execution. A particular implementation that supports this capability groups a process and the subprocesses it spawns together to share a common address space, but each has its own local state. Theses processes are referred to as light-weight processes, or threads. Multi-threaded processes present another level of concurrency in the system. Thread management functions may be implemented as a software layer in the user space. They may also be implemented at the kernel level. When two processes (or threads) access a shared variable concurrently, a race condition occurs. Examples of race condition: 1. Two threads need to access variable count as follows: Observer: do forever Reporter: do forever Observe an event; print count; count := count + 1; count := 0; end end Suspended- blocked Running Blocked Ready Nonexistent Suspended- ready Signal Suspend Schedule Schedule Signal Create Delete Resume Delete Suspend Wait Delete Delete Resume Suspend Signal Suspended- blocked Running Blocked Ready Nonexistent Suspended- ready 2. Two threads need to update the queue below as follows: E-process: Insert element E into the queue by F-process: Insert element F into the queue by E^.next := first; F^.next := first; first := E; first := F; As these examples illustrate, race condition could easily lead to erroneous results in the shared variables if (i) there are concurrent access to them to change their content; and (ii) the concurrent access is not properly controlled. The code segment that accesses the shared variable is referred to as a critical section (CS). Executing critical sections mutually exclusively will prevent the corruption of the shared variables due to race condition....
View Full Document
This note was uploaded on 04/11/2010 for the course CECS 526 taught by Professor Nguyen,t during the Spring '08 term at CSU Long Beach.
- Spring '08