DOC PREVIEW
UB CSE 421 - Chapter 2 Processes and Threads

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Processes and ThreadsProcesses The Process ModelWhat is a process?Process creationTermination of a processProcess HierarchiesProcess StatesA five-state process modelState Transition Diagram (1)Process suspensionProcess suspension (contd.)State Transition Diagram (2)Implementation of Processes (1)Implementation of Processes (2)Operating System Control StructuresProcess descriptionProcess control blockProcess control block (contd.)Slide 19Slide 20Queues as linked lists of PCBsOS Functions related to ProcessesModes of executionSummary1Processes and ThreadsChapter 22.1 Processes2.2 Threads2.3 Interprocess communication2.4 Classical IPC problems2.5 Scheduling2ProcessesThe Process Model•Multiprogramming of four programs•Conceptual model of 4 independent, sequential processes•Only one program active at any instant3What is a process?•A process is simply a program in execution: an instance of a program execution.•Unit of work individually schedulable by an operating system.•OS keeps track of all the active processes and allocates system resources to them according to policies devised to meet design performance objectives.•To meet process requirements OS must maintain many data structures efficiently.•The process abstraction is a fundamental OS means for management of concurrent program execution. Example: instances of process co-existing.4Process creation•Four common events that lead to a process creation are:1) When a new batch-job is presented for execution.2) When an interactive user logs in / system initialization.3) When OS needs to perform an operation (usually IO) on behalf of a user process, concurrently with that process.4) To exploit parallelism an user process can spawn a number of processes.5Termination of a process•Normal completion, time limit exceeded, memory unavailable•Bounds violation, protection error, arithmetic error, invalid instruction•IO failure, Operator intervention, parent termination, parent request, killed by another process•A number of other conditions are possible. •Segmentation fault : usually happens when you try write/read into/from a non-existent array/structure/object component. Or access a pointer to a dynamic data before creating it. (new etc.)•Bus error: Related to function call and return. You have messed up the stack where the return address or parameters are stored.6Process Hierarchies•Parent creates a child process, child processes can create its own process•Forms a hierarchy–UNIX calls this a "process group"•Windows has no concept of process hierarchy–all processes are created equal7Process States •Possible process states–running–blocked–ready•Transitions between states shown8A five-state process model•Five states: New, Ready, Running, Blocked, Exit•New : A process has been created but has not yet been admitted to the pool of executable processes.•Ready : Processes that are prepared to run if given an opportunity. That is, they are not waiting on anything except the CPU availability.•Running: The process that is currently being executed. (Assume single processor for simplicity.)•Blocked : A process that cannot execute until a specified event such as an IO completion occurs.•Exit: A process that has been released by OS either after normal termination or after abnormal termination (error).9State Transition Diagram (1) NEWREADYRUNNINGBLOCKEDEXITAdmitDispatchTime-outReleaseEvent WaitEvent OccursThink of the conditions under which state transitions may take place.10Process suspension•Many OS are built around (Ready, Running, Blocked) states. But there is one more state that may aid in the operation of an OS - suspended state.•When none of the processes occupying the main memory is in a Ready state, OS swaps one of the blocked processes out onto to the Suspend queue.•When a Suspended process is ready to run it moves into “Ready, Suspend” queue. Thus we have two more state: Blocked_Suspend, Ready_Suspend.11Process suspension (contd.)•Blocked_suspend : The process is in the secondary memory and awaiting an event.•Ready_suspend : The process is in the secondary memory but is available for execution as soon as it is loaded into the main memory.•State transition diagram on the next slide.•Observe on what condition does a state transition take place? What are the possible state transitions?12State Transition Diagram (2) NEWREADYRUNNINGBLOCKEDEXITAdmitDispatchTime-outReleaseEvent WaitEvent OccursThink of the conditions under which state transitions may take place.ActivateSuspendEvent occursActivateSuspendBlocked SuspendReadySuspend13Implementation of Processes (1)14Implementation of Processes (2)Skeleton of what lowest level of OS does when an interrupt occurs15Operating System Control Structures•An OS maintains the following tables for managing processes and resources:–Memory tables (see later)–I/O tables (see later)–File tables (see later)–Process tables (this chapter)16Process description•OS constructs and maintains tables of information about each entity that it is managing : memory tables, IO tables, file tables, process tables.•Process control block: Associated with each process are a number of attributes used by OS for process control. This collection is known as PCB.17Process control block•Contains three categories of information:1) Process identification2) Process state information3) Process control information•Process identification: –numeric identifier for the process (pid)–identifier of the parent (ppid)–user identifier (uid) - id of the usr responsible for the process.18Process control block (contd.)•Process state information: –User visible registers–Control and status registers : PC, IR, PSW, interrupt related bits, execution mode.–Stack pointers19Process control block (contd.)•Process control information:–Scheduling and state information : Process state, priority, scheduling-related info., event awaited.–Data structuring : pointers to other processes (PCBs): belong to the same queue, parent of process, child of process or some other relationship.–Interprocess comm: Various flags, signals, messages may be maintained in PCBs.20Process control block (contd.)•Process control information (contd.)–Process privileges: access privileges to certain memory area, critical structures etc.–Memory management: pointer to the various memory management data structures.–Resource ownership : Pointer to resources such as opened


View Full Document

UB CSE 421 - Chapter 2 Processes and Threads

Documents in this Course
Security

Security

28 pages

Threads

Threads

24 pages

Security

Security

20 pages

Security

Security

52 pages

Security

Security

20 pages

Load more
Download Chapter 2 Processes and Threads
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 Chapter 2 Processes and Threads 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 Chapter 2 Processes and Threads 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?