· Process is a program in execution
·Process ≠ program
· The program is only part of a process;
· One program can be several processes
· Components of a process
· The program code also called text section
· Current activity including : program counter, processor registers
· Stack containing temporary data
· Function parameters, return addresses, local variables
· Data section containing global variables
· Heap :- a memory that is dynamically allocated during run time
Thread
· Thread is a basic unit of CPU utilization;
· Belongs to a process
· Is a flow of control within a process
· consists of a program counter (PC), a register set, and a stack
· A process can have a single or multiple thread
Basic idea of Thread
· We build virtual processors in software, on top of physical processors:
Processor: Provides a set of instructions along with the capability of
automatically executing a series of those instructions.
Thread: A minimal software processor in whose context a series of instructions
can be executed.
Saving a thread context implies stopping the current execution and saving all the
data needed to continue the execution at a later stage.
Process: A software processor in whose context one or more threads may be
executed.
Executing a thread, means executing a series of instructions in the context of that
thread.
Context Switching
· A technique used for pausing what the system is doing and taking on another “possibly” urgent job.
·Save the context of the current job so that it can resume back from where it has left off ·
Load the context ofthe new job
· Context switching is an overhead
· Processor context:The minimal collection of values stored in the registers of aprocessor used for the
execution of aseries of instructions (e.g., stack pointer, addressing registers, program counter).
· Allows to handle interrupt and resume back later on
· Thread context:The minimal collection of values stored in registers and memory, used for the
execution of a series of instructions (i.e., processor context,state).
· Process context:The minimal collection of values stored in registers and memory, used for the
execution of a thread (i.e.,thread context, but now also at least MMU register values).