Process Concept
Process Concept
2411
1
Chapter 3
Processes
Process Concept
Operating Systems
Lecturer: Sana Rehman
2
What is Process
What all the CPU activities are called?
A batch system executes jobs, whereas a time-shared system has user programs, or tasks.
3 Continued…
On a single-user system, a user may be able to run several programs at one time: a
word processor, aWeb browser, and an e-mail package.
If a user can execute only one program at a time, such as on an embedded device
that does not support multitasking, the operating system may need to support its
own internal programmed activities, such as memory management.
In many respects, all these activities are called processes.
Job and process can be used interchangeably, but for operating system process is
preferred.
4 The Process
A process is a program in execution.
A process is more than the program code, which is sometimes known as the text section.
What it includes
It includes the current activity, as represented by the value of the program counter and
the contents of the processor’s registers.
A process generally also includes the process stack, which contains temporary data (such
as function parameters, return addresses, and local variables), and a data section, which
contains global variables.
A process may also include a heap, which is memory that is dynamically allocated during
process run time.
5 Continued….
Program and Process
A program by itself is not a process.
A program is a passive entity, such as a file containing a list of instructions stored on
disk (often called an executable file).
A process is an active entity, with a program counter specifying the next instruction to
execute.
Executing a Program
A program becomes a process when an executable file is loaded into memory.
Two common techniques for loading executable files are double-clicking an icon
representing the executable file
Entering the name of the executable file on the command line (as in prog.exe or a.out).
6 Process State
When a process executes, it changes state.
The state of a process is defined in part by the current activity of that process.
A process may be in one of the following states:
1. New. The process is being created.
2. Running. Instructions are being executed.
3. Waiting. The process is waiting for some event to occur (such as an I/O completion or
reception of a signal).
4. Ready. The process is waiting to be assigned to a processor.
5. Terminated. The process has finished execution.
7 Continued…
These names are arbitrary, and they vary across operating systems.
It is important to realize that only one process can be running on any processor at any
instant.
Many processes may be ready and waiting.
8 Process Control Block
Each process is represented in the operating system by a process control block (PCB)—
also called a task control block.
9 Continued…
• Process state. The state may be new, ready, running, waiting, halted, and so on.
• Program counter. The counter indicates the address of the next instruction to be executed
for this process.
• CPU registers. The registers vary in number and type, depending on the computer
architecture.
They include accumulators, index registers, stack pointers, and general-purpose
registers
• CPU-scheduling information. This information includes a process priority, pointers to
scheduling queues, and any other scheduling parameters.
• Memory-management information. This information may include such items as the
value of the base and limit registers and the page tables, or the segment tables,
depending on the memory system used by the operating system
10 Continued…
• Accounting information. This information includes the amount of CPU and real time
used, time limits, account numbers, job or process numbers, and so on.
• I/O status information. This information includes the list of I/O devices allocated to the
process, a list of open files, and so on.
11 Threads (sequence of execution)
The process model has implied that a process is a program that performs a single thread of
execution.
Example
When a process is running a word-processor program, a single thread of instructions is
being executed.
This single thread of control allows the process to perform only one task at a time.
The user cannot simultaneously type in characters and run the spell checker within the
same process