0% found this document useful (0 votes)
60 views

Process Process Creation / Termination

This document summarizes key concepts about processes and process states. It defines a process as a program in execution, distinguishing it from a passive program stored on disk. A process contains both the executing program and its current state. Processes transition between different states, such as running, ready, blocked, and terminated. When a process finishes its time slice, it moves from the running to ready state, allowing the CPU scheduler to select the next process to run. Processes may also move to the blocked state if they are waiting for an event like I/O before continuing execution.

Uploaded by

Ron Santelices
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Process Process Creation / Termination

This document summarizes key concepts about processes and process states. It defines a process as a program in execution, distinguishing it from a passive program stored on disk. A process contains both the executing program and its current state. Processes transition between different states, such as running, ready, blocked, and terminated. When a process finishes its time slice, it moves from the running to ready state, allowing the CPU scheduler to select the next process to run. Processes may also move to the blocked state if they are waiting for an event like I/O before continuing execution.

Uploaded by

Ron Santelices
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Process Process Creation / Termination

n A process (sometimes called a task, or a n Reasons for process creation


job) is, informally, a program in execution ● User logs on

n “Process” is not the same as “program” ● User starts a program

● We distinguish between a passive ● OS creates process to provide a service


program stored on disk, and an actively (e.g., printer daemon to manage printer)
executing process ● Program starts another process (e.g.,
n Multiple people can run the same netscape calls xv to display a picture)
program; each running copy corresponds
to a distinct process
n Reasons for process termination
● The program is only part of a process; the
● Normal completion
process also contains the execution state
● Arithmetic error, or data misuse (e.g.,
n List processes (HP UNIX): wrong type)

● ps — my processes, little detail ● Invalid instruction execution

● ps -fl — my processes, more detail ● Insufficient memory available, or memory


bounds violation
● ps -efl — all processes, more detail
● Resource protection error
n Note user processes and OS processes ● I/O failure
1 Fall 1998, Lecture 05 2 Fall 1998, Lecture 05

Process Execution A Two-State Process Model

n Conceptual model of 4 processes n This process model says that either a


executing: process is running, or it is not running
(one Program Counter per process)
time

process process process


n State transition diagram:
A B C
dispatch

process enter not exit


running running
D

pause

n Queuing diagram:
queue
n Actual interleaved execution of the 4 enter dispatch
CPU
exit
processes:
(one Program Counter)
time
pause
process A
process B
process C
process A n CPU scheduling (round-robin)
process B
process C
process A ● Queue is first-in, first-out (FIFO) list
process C
process A
process D ● CPU scheduler takes process at head of
process C
process D queue, runs it on CPU for one time slice,
process C
then puts it back at tail of queue
3 Fall 1998, Lecture 05 4 Fall 1998, Lecture 05
Process Transitions in
Waiting on Something to Happen…
the Two-State Process Model

n When the OS creates a new process, it is n Some reasons why a process that might
initially placed in the not-running state otherwise be running needs to wait:
● It’s waiting for an opportunity to execute ● Wait for user to type the next key
● Wait for output to appear on the screen
n At the end of each time slice, the CPU
scheduler selects a new process to run ● Program tried to read a file — wait while
OS decides which disk blocks to read,
● The previously running process is paused and then actually reads the requested
— moved from the running state into the information into memory
not-running state (at tail of queue)
● Netscape tries to follow a link (URL) —
● The new process (at head of queue) is wait while OS determines address,
dispatched — moved from the not- requests data, reads packets, displays
running state into the running state requested web page
n If the running process completes its
execution, it exits, and the CPU scheduler n OS must distinguish between:
is invoked again
n If it doesn’t complete, but its time is up, it ● Processes that are ready to run and are
gets moved into the not-running state waiting their turn for another time slice
anyway, and the CPU scheduler chooses
a new process to execute ● Processes that are waiting for something
to happen (OS operation, hardware
event, etc.)
5 Fall 1998, Lecture 05 6 Fall 1998, Lecture 05

State Transitions in Five-State


A Five-State Process Model
Process Model

n The not-running state in the two-state n new → ready


model has now been split into a ready ● Admitted to ready queue; can now be
state and a blocked state considered by CPU scheduler
● Running — currently being executed
n ready → running
● Ready — prepared to execute
● CPU scheduler chooses that process to
● Blocked — waiting for some event to
execute next, according to some
occur (for an I/O operation to complete, or
scheduling algorithm
a resource to become available, etc.)
● New — just been created n running → ready
● Exit — just been terminated ● Process has used up its current time slice

n State transition diagram: n running → blocked


new
admit
ready
dispatch
running
release
exit ● Process is waiting for some event to
timeout
occur (for I/O operation to complete, etc.)
event
occurs event
wait n blocked → ready
blocked
● Whatever event the process was waiting
on has occurred
7 Fall 1998, Lecture 05 8 Fall 1998, Lecture 05
Process State Process Control Block (PCB)

n The process state consists of (at least): n For every process, the OS maintains a
● Code for the program
Process Control Block (PCB), a data
structure that represents the process and
● Program’s static and dynamic data its state:
● Program’s procedure call stack ● Process id number
● Contents of general purpose registers ● Userid of owner
● Contents of Program Counter (PC) ● Memory space (static, dynamic)
—address of next instruction to be
executed ● Program Counter, Stack Pointer, general
purpose registers
● Contents of Stack Pointer (SP)
● Process state (running, not-running, etc.)
● Contents of Program Status Word (PSW)
— interrupt status, condition codes, etc. ● CPU scheduling information (e.g., priority)

● OS resources in use (e.g., memory, open ● List of open files


files, connections to other programs) ● I/O states, I/O in progress
● Accounting information ● Pointers into CPU scheduler’s state
queues (e.g., the waiting queue)
åEverything necessary to resume the
● …
process’ execution if it is somehow put
9
aside temporarily Fall 1998, Lecture 05 10 Fall 1998, Lecture 05

You might also like