Processes: 3.1 Process Concept
Processes: 3.1 Process Concept
PROCESSES
3.1 PROCESS CONCEPT
• Process is a program in execution.
• A Process will need certain resources (such as CPU time, memory, files and
I/O devices) to accomplish its task.
• The operating system is responsible for the following activities in
connection with process management.
Process creation and deletion.
Scheduling of processes.
Provision of mechanisms for:
process synchronization
process communication
Deadlock handling for processes
3.1.1 The Process
• An operating system executes a variety of programs:
Batch system – job
Time-shared systems – user programs or tasks
• In general a process consists of following sections.
1. Text section: It is basically the program code associated
with process.
2. Data section: Consists of global variables.
3. Stack section: Consists of return addresses of sub-
routine call, local variables of a sub-routine.
3.1.2 Process State
As a process executes, it changes state. The state of a process is defined,
in part, by the current activity of that process.
• New: The process is being created.
• Running: Instructions are being executed.
• Waiting: The process is waiting for some event to occur.
• Ready: The process is waiting to be assigned to a process.
• Terminated: The process has finished execution.
3.1.3 Process Control Block (PCB)
• Each process is represented in the operating system by a process control block (PCB)-
also called a task control block.
• A PCB is shown in figure
• 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, plus any condition-code information.
• CPU-scheduling information: This information includes a process
priority, pointers to scheduling queues, and any other scheduling
parameters.
• Memory-management information: It includes value of the base
and limit registers, the page tables, or the segment tables, depending
on the memory system used by OS.
• Accounting information: It includes the amount of CPU and real time used, time limits,
account numbers, process numbers and so on.
• I/O status information: The information includes the list of I/O devices allocated to this
process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary from
process to process.
3.2 PROCESS SCHEDULING
• Process scheduling is an essential part of a Multiprogramming operating
system.
• Multiprogramming systems allow more than one process to be loaded into
the executable memory at a time.
• Then the loaded process shares the CPU using time multiplexing.
3.2.1 Scheduling Queues
• The operating system also maintains three types of queues
1. Job Queue, 2.Ready Queue, 3.Device Queue.
• When the process enters into the system, then this process is put into a
job queue.
• Job queue - consists of all processes in the system.
• Ready Queue -The processes that are residing in main memory and are
ready and waiting to execute.
• Device queue – the list of processes waiting for a particular I/O device
.Each device has its own device queue.
• Queue is represented by rectangular box.
• The circles represent the resources that serve the queues.
• The arrows indicate the process flow in the system
• A new process is initially put in the ready queue. It waits in the ready queue
until it is selected for execution.
• Once the process is assigned to the CPU and is executing, one of several
events could occur:
• The process could issue an I/O request and then it would be placed in an I/O
queue.
• The process could create new subprocess and wait for its termination.
• The process could be removed forcibly from the CPU, as a result of interrupt
and put back in the ready queue.
3.2.2 Schedulers
• A process migrates between the various scheduling queues throughout its
lifetime.
• The operating system must select, for scheduling purposes, processes from
these queues in some fashion.
• The selection process is carried out by the appropriate scheduler.
• Schedulers selects the program based on
I/O bound: A process spends more time doing I/O than computation.
CPU bound : A process spends more time doing computations than I/O
• The system with the best performance will have a combination of CPU-bound
and I/O-bound processes.
Schedulers are of three types:
1.Long Term Scheduler
2.Short Term Scheduler
3.Medium Term Scheduler
1.Long Term Scheduler
• It is also called job scheduler.
• The long-term scheduler selects processes from this pool and loads them
into memory for execution.
• Long-term scheduler is invoked very infrequently (seconds, minutes)
(may be slow).
• The long-term scheduler controls the degree of multiprogramming (the
number of processes in memory).
• If the degree of multiprogramming is stable, then the average rate of
process creation must be equal to the average departure rate of processes
leaving the system.
• The long-term scheduler should select a good process mix of I/O-bound
and CPU-bound processes.