COMP 755 The Abstraction The Process Process The
COMP 755 The Abstraction: The Process
Process • The most fundamental abstractions that the OS provides to users: the process. • A process is a running program. • To view all running processes two Linux commands are commonly used: ps –aux and top (real time, use ctrl C to stop)
HOW TO PROVIDE THE ILLUSION OF MANY CPUS? • Answer: The OS creates this illusion by virtualizing the CPU. By running one process, then stopping it and running another, and so forth, the OS can promote the illusion that many virtual CPUs exist when in fact there is only one physical CPU (or a few). • We call this time sharing… time sharing of the CPU, allows users to run as many concurrent processes as they would like; the potential cost is performance, as each will run more slowly if the CPU(s) must be shared.
Terms • machine state: what a program can read or update when it is running. • address space: the memory the process can address • registers: process registers it can access • program counter (PC) tells us which instruction of the program is currently being executed • stack pointer and associated frame pointer are used to manage the stack for function parameters, local variables, and return addresses.
Overview of Process API • Create: An operating system must include some method to create new processes. • Destroy: As there is an interface for process creation, systems also provide an interface to destroy processes forcefully. • Wait: Sometimes it is useful to wait for a process to stop running • Miscellaneous Control: suspend and resume process • Status: There are usually interfaces to get some status information about a process as well, such as how long it has run for, or what state it is in.
Process States • Running: In the running state, a process is running on a processor. This means it is executing instructions. • Ready: In the ready state, a process is ready to run but for some reason the OS has chosen not to run it at this given moment. • Blocked: In the blocked state, a process has performed some kind of operation that makes it not ready to run until some other event takes place. A common example: when a process initiates an I/O request to a disk, it becomes blocked and thus some other process can use the processor.
3 State Model
5 state model
Process States • Running: The process is being executed • Ready: The process is prepared to execute when given the opportunity • Blocked: The process can not execute until some event occurs, such as the completion of an I/O operation • New: The OS is still creating the data structures and allocating memory for the process. • Exit: The process is no longer eligible for execution. The OS is in the process of releasing the resources allocated to this process.
Process Transitions • New Ready: When a process becomes ready to be executed. • Ready Running: When the CPU is available, the dispatcher selects a new process to run • Running Ready: The running process has run long enough for now; the running process gets interrupted because a higher priority process is in the ready state (preempted) • Running Blocked: When a process requests something for which it must wait (e. g. , initiates I/O, wait for input from another process) • Blocked Ready: When the event for which it was waiting occurs • Running Exit: A process is done or has failed.
- Slides: 10