4 OS Processes
4 OS Processes
Process Concept
An operating system executes a variety of programs that run as a
process.
Process – a program (Job) in execution; process execution must
progress in sequential fashion. No parallel execution of instructions of
a single process
This entity contains at least two types of elements:
• Program code and a set of data
A program functionProgram.py
A process Execution of this program (run the program)
A thread a portion (sub-task) of this process
Thread 1: Taking
fName value from user
Thread 2: Taking
sName value from user
Thread 3: Calling a
function (greeting)
Thread 4: Printing message
on computer screen
Difference between program & process
PROGRAM PROCESS
PROCESS THREAD
Program scheduler
• Initialize each program
• Only concerned with selecting programs from a queue of incoming
programs
• Places them in a process queue (READY queue)
Process scheduler
• Determines which processes get the CPU, when, and for how long.
• Also decides when processing should be interrupted decides when
each step will be executed recognizes when a process has
concluded and should be terminated
Process Scheduling
Process scheduler selects among available processes
for next execution on CPU core
Goal -- Maximize CPU use, quickly switch processes onto
CPU core
Maintains scheduling queues of processes
• Ready queue – set of all processes residing in main
memory, ready and waiting to execute
• Wait queues – set of processes waiting for an event
(i.e., I/O)
• Processes migrate among the various queues
Representation of Process Scheduling
CPU Switch From Process to Process
A context switch occurs when the CPU switches from
one process to another.
Context Switch
When CPU switches to another process, the system must
save the state of the old process and load the saved state
for the new process via a context switch
Context of a process represented in the PCB
Context-switch time is pure overhead; the system does no
useful work while switching
• The more complex the OS and the PCB the longer
the context switch
Time dependent on hardware support
• Some hardware provides multiple sets of registers per
CPU multiple contexts loaded at once
C Program Forking Separate Process
Creating a Separate Process via Windows API