OSS - Lecture 02-1 - Processes Threads
OSS - Lecture 02-1 - Processes Threads
IKB20103
User data
program code
Process State
As a process executes, it changes state
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to
occur
ready: The process is waiting to be assigned to a
processor
terminated: The process has finished execution
Diagram of Process State
Process Control Block (PCB)
Information associated with each process
(also called process control block(PCB))
Process state – running, waiting, etc
Program counter – location of instruction to next
execute
CPU registers – contents of all process-centric
registers
CPU scheduling information- priorities, scheduling
queue pointers
Memory-management information – memory
allocated to the process
Accounting information – CPU used, clock time
elapsed(passed since start, time limits
I/O status information – I/O devices allocated to
process, list of open files
CPU Switch From Process to Process
Threads
So far, process has a single thread of execution
Consider having multiple program counters per
process
Multiple locations can execute at once
Multiple threads of control -> threads
l ogi n kt hr e add s s hd
pi d = 8415 pi d = 2 pi d = 3028
e mac s t cs ch
ps
pi d = 9204 pi d = 4005
pi d = 9298
Process Creation (Cont.)
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
fork() system call creates new process
exec() system call used after a fork() to replace the
process’ memory space with a new program
Process Termination
Process executes last statement and then asks the operating
system to delete it using the exit() system call.
Returns status data from child to parent (via wait())
Process resources are deallocated by operating system
Parent may terminate the execution of children processes
using the abort() system call. Some reasons for doing so:
Child has exceeded allocated resources
Task assigned to child is no longer required
The parent is exiting and the operating systems does not
allow a child to continue if its parent terminates
Process Termination
Some operating systems do not allow child to exists if
its parent has terminated. If a process terminates,
then all its children must also be terminated.
cascading termination. All children, grandchildren,
etc. are terminated.
The termination is initiated by the operating system.
The parent process may wait for termination of a child
process by using the wait()system call.
Multiprocessor Architecture – Chrome Browser
Many web browsers ran as single process (some still do)
If one web site causes trouble, entire browser can hang or crash
Google Chrome Browser is multiprocessor with 2 different types of
processes:
Browser process manages user interface, disk and network I/O
Renderer process renders web pages, deals with HTML, Javascript.
A new renderer created for each website opened
Q&A