Vous êtes sur la page 1sur 3

process

-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

3.1.2 Process State


-process changes state as it executes
-new-being created
-running-instructions are executing. note only 1 process can be running on a processor at a
time
-waiting-process waiting for event (I/O etc.)
-ready-waiting to be assigned to processor
-terminated-finished execution

Figure: program state

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

3.2 Process Scheduling


Process scheduler selects available process for execution on CPU fast enough so that users can interact
with each program while it is running
3.2.1 Scheduling Queues
-process enters system and put into job queue.
-processes in main memory and ready to execute re in ready queue

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: Ready queue and other PCBs


Device queue: list of processes trying to access a device. Each device has its own queue

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.

Vous aimerez peut-être aussi