0% found this document useful (0 votes)
1 views11 pages

Process

Uploaded by

hrishav20212059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views11 pages

Process

Uploaded by

hrishav20212059
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Process Concept

• Process – a program in execution


• Process execution must progress in sequential fashion

Example:
• A word-processing program being run by an individual user on a PC is a process
• A system task, such as sending output to a printer, is also a process

• A program by itself is not a process.


• A program can be a passive entity or an active entity
• Passive entity: the contents of a file stored on disk
• Active entity: a program counter specifying the next instruction to execute
Process Control Block (PCB)

• The Process Control Block is the key tool that enables the OS to support
multiprocessing

• The significant point about the Process Control Block is that it contains sufficient
information so that it is possible to interrupt a running process and later resume
execution

• When a process is interrupted, the current values of the program counter and the
processor registers are saved in the appropriate fields of the corresponding PCB and
the state of the process is changed to some other values
Process Control Block (PCB)
A process can be uniquely characterized by a number of elements

• Identifier: unique identifier to distinguish from other process

• State: If the process is currently executing then it is in the running state

• Program Counter: the address of the next instruction in the program to be executed

• Memory pointers: pointer to the program code and the data associated with this process

• Context data: these are data that are present in registers in the processor

• Accounting information: May include the amount of processor time and clock time used, time
limits

These list of information are stored in a data structure called a Process Control Block (PCB)
Process Control Block (PCB)
Process State
As a process executes, it changes state

• new: The process is being created

• ready: The process is waiting to be assigned to a processor

• running: Instructions are being executed

• waiting: The process is waiting for some event to occur

• terminated: The process has finished execution


Diagram of Process State
Process Scheduling Queues

• Job queue – set of all processes in the system

• Ready queue – set of all processes residing in main memory,


ready and waiting to execute

• Device queues – set of processes waiting for an I/O device


Schedulers
• Long-term scheduler (or job scheduler) – selects which processes
should be brought into the ready queue

• Short-term scheduler (or CPU scheduler) – selects which process


should be executed next and allocates CPU

• Processes can be described as either:

• I/O-bound process – spends more time doing I/O than


computations

• CPU-bound process – spends more time doing computations


Context Switch

• The term "context" refers to the data in the registers and program counter at a specific
moment in time.

• A register holds the current CPU instruction.

• A program counter, also known as an instruction address register, is a small amount of fast
memory that holds the address of the instruction to be executed immediately after the
current one.

• In a switch, the state of process currently executing must be saved so that when it is
rescheduled, this state can be restored.

• 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
Process Creation
• Operating systems need some way to create processes.

• When an operating system is booted, typically several processes are created.

• Some of these are foreground process: processes that interact with the user and
perform work for them

• Background processes: not associated with particular users but, instead have
some specific function

• There are three 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
Process Termination
• After a process is created, it does its job and finally terminates for the following
reason:
1. Normal exit
2. Error exit
3. Fatal error

• Most process terminated because they have done their work

• Screen-oriented interactive process generally do not exit when given incorrect


parameters. Instead they pop up dialog box and ask the user to try again.

• Termination due to error is usually caused due to program bug

You might also like