Académique Documents
Professionnel Documents
Culture Documents
-program in execution
batch system has jobs, time shared system has user programs/ tasks
3.1.1 Process
-program code -> text section
-current activity->program counter and register contents
-stack-temporary data
-data section - globals
-heap -dynamically allocated memory during process run time
-program is passive, process is active, program becomes process when exe is loaded into mem
Figure: process control block. Each process in OS is represented by a process control block (PCB/TCB).
PCB serves as repo for information that may vary from process to process
-State-new ready running waiting halted
-PC address of next instruction
-cpu registers-must be saved when interrupt occurs.
-cpu-scheduling information-process priority, pointers to scheduling queues, scheduling parameters
-memory management info-value of base and limit registers, page tables, segment tables
-accounting information-amount of cpu and real time used, time limits, account numbers, job numbers
-I/O-list of i/o devices, open files, etc
Figure: PCB is represented by task_struct which has all the necessary information for representing a
process.
-Queue is normally a linked list.
-ready queue header contains pointers to first and last pcbs.
Figure: Queueing diagram of process scheduling. Process in ready queue until it is selected of execution
or dispatched and then 1 of 4 possible events happen. Process continues until it terminates
3.2.2 Schedulers
-scheduler-selects process from queue
-long term/job scheduler selects processes from mass storage pool and loads them to memory. Controls
the degree of multiprogramming (number of processes in mem). To be stable, in=out so only needs to
be invoked when process leaves. Can take more time to decide
-long term scheduler needs good mix of i/o and cpu bound processes to keep system balanced
-time sharing systems often times dont have long term schedulers. Every new process is put in
memory for short term scheduler
-short term/CPU scheduler selects ready processes for execution. Must select new process frequently
-medium term scheduler-swapping->take process of memory and add it back to ready queue later later.
3.2.3 Context Switch
-context represented in PCB by registers, process state, and mem management
-context switch->perform state save of current process and then state restore of another process.
Kernel saves old process context in PCB and loads saved context of new process.