UMSL CS 4760 - Interprocess Communication

Unformatted text preview:

Interprocess Communication 1Processes• Basic concept to build the OS, from old IBM mainframe OS to the most modern Windows• Used to express the requirements to be met by an OS– Interleave the execution of multiple processes, to maximize CPU utilization while providing good response time– Allocate resources to processes using a policy whilea avoiding deadlocks– Support interprocess communications and user creation of processes to help structuring applications• Background– Computer platform∗ Collection of hardware resources – CPU, memory, I/O modules, timers, storage devices– Computer applications∗ Developed to perform some task∗ Input, processing, output– Efficient to write applications for a given CPU∗ Common routines to access computer resources across platforms∗ CPU provides only limited support for multiprogramming; software manages sharing of CPU and other re-sources by multiple applications concurrently∗ Data and resources for multiple concurrent applications must be protected from other applications• Process– Abstraction of a running program– Unit of work in the system– Split into two abstractions in modern OS∗ Resource ownership (traditional process view)∗ Stream of instruction execution (thread)– Pseudoparallelism, or interleaved instructions– A process is traced by listing the sequence of instructions that execute for that process• Modeling sequential process/task– Program during execution– Program code– Current activity– Process stack∗ Function parameters∗ Return addresses∗ Temporary variables– Data section∗ Global variables• Concurrent Processes– Multiprogramming– Interleaving of traces of different processes characterizes the behavior of the CPU– Physical resource sharing∗ Required due to limited hardware resourcesInterprocess Communication 2– Logical resource sharing∗ Concurrent access to the same resource like files– Computation speedup∗ Break each task into subtasks∗ Execute each subtask on separate processing element– Modularity∗ Division of system functions into separate modules– Convenience∗ Perform a number of tasks in parallel– Real-time requirements for I/O• Process Hierarchies– Parent-child relationship– fork(2) call in Unix– In older non-multitasking systems such as MS-DOS, parent suspends itself and lets the child execute• Process states– A two-state process model∗ Simplest possible model∗ A process is either executing (running state) or it is idle (not-running state)∗ For a new process, the OS creates a new process control block and brings that process into memory in a not-running state– A five-state model∗ Running∗ Ready – Not running, waiting for the CPU∗ Blocked – Wait on an event (other than CPU)∗ Two other states complete the five-state model – New and Exit· A process being created can be said to be in state New; it will be in state Ready after it has been created· A process being terminated can be said to be in state ExitNew-Ready-DispatchTimeoutRunning-ExitBlocked@@@IEventwaitEventoccurs– Above model suffices for most of the discussion on process management in operating systems; however, it is limitedin the sense that the system screeches to a halt (even in the model) if all the processes are resident in memory andthey all are waiting for some event to happen– Create a new state Suspend to keep track of blocked processes that have been temporarily kicked out of memory tomake room for new processes to come in– The state transition diagram in the revised model isNew-Ready-DispatchTimeoutRunning-ExitBlocked@@@IEventwaitEventoccursSuspended@@@RSuspendActivateInterprocess Communication 3– Which process to grant the CPU when the current process is swapped out?∗ Preference for a previously suspended process over a new process to avoid increasing the total load on thesystem∗ Suspended processes are actually blocked at the time of suspension and making them ready will just changetheir state back to blocked∗ Decide whether the process is blocked on an event (suspended or not) or whether the process has been swappedout (suspended or not)– The new state transition diagram isNew-Ready-DispatchTimeoutRunning-ExitBlocked@@@IEventwaitEventoccursReadySuspended@@@I@@@RActivateActivateBlockedSuspended@@@@RSuspendEventoccurs– Process sleep state∗ A process can put itself to sleep while waiting for an event· Instead of constantly polling for input from keyboard, a shell puts itself to sleep∗ Process sleeps on a particular wait channel (WCHAN)∗ When the event associated with WCHAN occurs, every process waiting on that WCHAN is woken up∗ The awakened processes check to see if the signal was meant for them· Consider a set of processes waiting for data from the disk· Once data becomes available, processes check whether the data is ready for them∗ If the signal is not for the processes, they put themselves to sleep on the same WCHANProcess control• Modes of execution– OS execution vs user process execution– OS may prevent execution of some instructions in user mode and allow them to be executed only in privileged mode(also called kernel mode, system mode, or control mode)∗ Read/write a control register, such as PSW∗ Primitive I/O and memory management– The two modes protect the OS data structures from interference by user code– Kernel mode provides full control of the system that may not be needed for user programs– The kernel mode can be entered by setting a bit in the PSW– The system can enter privileged mode as a result of a request from user code and returns to user mode after com-pleting the request• Implementation of processes– Process table∗ One entry for each processInterprocess Communication 4∗ program counter∗ stack pointer∗ memory allocation∗ open files∗ accounting and scheduling information– Interrupt vector∗ Contains address of interrupt service procedure· saves all registers in the process table entry· services the interrupt• Process creation– Assign a unique process identifier to the new process; add this process to the system process table that contains oneentry for each


View Full Document

UMSL CS 4760 - Interprocess Communication

Documents in this Course
Load more
Download Interprocess Communication
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Interprocess Communication and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Interprocess Communication 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?