(1) What is Process? Give the difference between Process and Program.
Process:
• Process is a program under execution.
• It is an instance of an executing program, including the current values of the pro-
gram counter, registers & variables.
• Process is an abstraction of a running program.
Process Program
A process is program in execution. A program is set of instructions.
A process is an active/ dynamic entity. A program is a passive/ static entity.
A process has a limited life span. It is A program has a longer life span. It is
created when execution starts and stored on disk forever.
terminated as execution is finished.
A process contains various resources A program is stored on disk in some file.
like memory address, disk, printer It does not contain any other resource.
etc… as per requirements.
A process contains memory address A program requires memory space on
which is called address space. disk to store all instructions.
(2) What is multiprogramming?
• A process is just an executing program, including the current values of the program
counter, registers, and variables.
• Conceptually, each process has its own virtual CPU.
• In reality, the real CPU switches back and forth from process to process, but to under-
stand the system, it is much easier to think about a collection of processes running in
(pseudo) parallel, than to try to keep track of how the CPU switches from program to
program.
• This rapid switching back and forth is called multiprogramming and the number of pro-
cesses loaded simultaneously in memory is called degree of multiprogramming.
(3) What is context switching?
• Switching the CPU to another process requires saving the state of the old process and
1
, 2 – Processes & Threads
loading the saved state for the new process.
• This task is known as a context switch.
• The context of a process is represented in the PCB of a process; it includes the value of
the CPU registers, the process state and memory-management information.
• When a context switch occurs, the kernel saves the context of the old process in its PCB
and loads the saved context of the new process scheduled to run.
• Context-switch time is pure overhead, because the system does no useful work while
switching.
• Its speed varies from machine to machine, depending on the memory speed, the num-
ber of registers that must be copied, and the existence of special instructions.
Figure 2-1. Context Switching
(4) Explain Process Model in brief.
• In this model, all the runnable software on the computer, sometimes including the op-
erating system, is organized into a number of sequential processes.
• A process is just an executing program, including the current values of the program
counter, registers, and variables.
• Conceptually, each process has its own virtual CPU.
• In reality, of course, the real CPU switches back and forth from process to process, but
to understand the system, much easier to think about a collection of processes running
2
, 2 – Processes & Threads
in (pseudo) parallel, than to try to keep track of how the CPU switches from program to
program.
• This rapid switching back and forth is called multiprogramming.
• In Fig. 2-2 (a) we see a computer multiprogramming four programs in memory.
• In Fig. 2-2 (b) we see four processes, each with its own flow of control (i.e., its own logi-
cal program counter), and each one running independently of the other ones.
• There is only one physical program counter, so when each process runs, its logical pro-
gram counter is loaded into the real program counter.
• When it is finished for the time being, the physical program counter is saved in the pro-
cess’ logical program counter in memory.
• In Fig. 2-2 (c) we see that over a long period of time interval, all the processes have
made progress, but at any given instant only one process is actually running.
• With the CPU switching back and forth among the processes, the rate at which a pro-
cess performs its computation will not be uniform and probably not even reproducible
if the same processes are run again.
• Thus, processes must not be programmed with built-in assumptions about timing.
Figure 2-2. (a) Multiprogramming of four programs. (b) Conceptual model of four inde-
pendent, sequential processes. (c) Only one program is active at once.
Process Creation
• There are four principal events that cause processes to be created:
1. System initialization.
2. Execution of a process creation system call by a running process.
3. A user request to create a new process.
4. Initiation of a batch job.
3