Sie sind auf Seite 1von 34

Process Management

KAREN JOYCE A. MARIANO


I N S T R U C TO R I
INSTITUTE OF COMPUTER STUDIES
PROCESS
✓ A process is an instance of a program in execution.
✓ It needs certain resources such as CPU time, memory, files and I/O
devices.
✓ It also needs to request for all the resources needed.
✓ As the request is granted by the operating system, these resources
are used and then released when the process ends.
✓ The process is an active entity which is already in execution and as it
executes, it changes state. Each process shown in Figure 3.1 may be
in one of the following states:
1. New or Held - a process which has just been
created and has not yet been loaded in memory.
2. Ready – a process that is allocated a space in
the primary storage and waiting to be dispatched to
the processor. These ready processes are placed in a
queue so that the operating system can keep track
which of the processes will be selected for execution.
3. Running- a process instruction being executed, was allotted
time in the processor. The running process may lose its time in the
processor for some reasons and may either be transferred back to
the ready queue; to the waiting queue for an event completion; or
release by the operating system.
4. Blocked or Waiting – a process waiting for some events to occur
(like I/O completion) before it can continue executing. It does not
require services of the processor until the blocking event is
completed.
5. Exit, Halted or terminated - a process which has finished
execution and has been released by OS from the pool of executable
processes.
PROCESS SCHEDULER
✓ Scheduling affects the performance of the system because it
determines which processes will wait and which will progress.
Scheduling is a matter of managing queues to minimize queuing
delay and to optimize performance in a queuing environment.
✓ Operating system features three types of schedulers namely Long-
term or job or admission scheduler, short-term or CPU
scheduler and medium-term or midterm scheduler. The names
connote that frequency with which the function is used. Table 3.1
summarizes the work of each scheduler [STAL2001].
BASIC CONCEPTS IN PROCESS SCHEDULING
✓ CPU Scheduling refers to the sequence or order of process
execution as they are allotted the processor.
✓ The scheduler assigned to do the task is the short-term
scheduler.
✓ The many ways of allotting the processor to a specific job or
process is known as the CPU scheduling algorithm.
✓ The main purposes of scheduling algorithms are to minimize resource
starvation and to ensure fairness among the parties utilizing the
resources.
✓ Evaluation of the best CPU scheduling algorithm takes into account
the following criteria:
1. Increase CPU utilization. The main goal is to make the
CPU busy processing at all times. CPU utilization is the
ratio of the total CPU burst and the total time used up
for processing all the jobs in the ready queue. It is the
percentage of time the processor is busy. The
greater the CPU utilization, the better the
performance of the specific CPU scheduling algorithm.
2. Increase throughput. Throughput refers to the
number of processes that has completed their
execution per time unit. It measures how much work is
being performed in a given time. This is dependent on the
average length or burst time of a process and may also
be influenced by the scheduling algorithm. More
processes completing in a given time would mean greater
throughput.
3. Reduce Turn-around time. Turn-around time is the
amount of time to execute particular processes. It
refers to the time when the process was submitted
up to its time of completion. It includes actual
execution time and time spent waiting for the
resources. Shorter turn-around time is better.
4. Reduce Waiting time. Waiting time refers to the
amount of time a process has been waiting in the
ready queue before it was allotted the processor. A
shorter waiting time is better for all processes.
5. Reduce Response time. Response time is the amount of time it takes
when a request was submitted till the first response is produced.
Shorter response time is better. According to J. Archer Harris, other
scheduling criteria which may be considered are balanced utilization,
predictability, fairness and priorities.
6. Balanced Utilization evaluates the percentage utilization of not only
the CPU but also the memory, I/O devices, and other system resources.
7. Predictability refers to consistency in response time.
8. Fairness in scheduling refers to the equal opportunity given to all
processes to execute such that no one is allowed to suffer from
starvation.
9. Preferential treatment to processes with higher priorities may also
be considered as a criterion.
CPU SCHEDULING ALGORITHMS
✓ CPU scheduling deals with the problem of choosing which of
the processes in the ready queue is to be assigned the CPU.
✓ There is a long list of common scheduling practices and
disciplines but only the classic scheduling algorithms is
covered in this lesson.
✓ The algorithms that will be described are: First Come First
Served (FCFS), Shortest Job First (SJF), Non-Pre-emptive
Priority (NPP), Pre-emptive Priority (PP), Shortest Remaining
Time First (SRTF) and Round Robin (RR).
✓ Scheduling algorithms may be categorized as either
non-preemptive or preemptive algorithm.
✓ Non-preemptive means that once a process is in the
running state, it continues to execute until it terminates.
✓ Preemptive means currently running processes may be
interrupted and moved to the ready state by the operating
system even if the total burst time (allotted time to
execute) has not been consumed.
✓ The first three algorithms mentioned above are non-
preemptive while the next three are pre-emptive in nature.
In evaluating the scheduling algorithms, the following
information are needed:
1. Gantt Chart – shows the execution pattern or order
of processing of all processes in the ready queue.
2. Turn-around Time – the finish time of each process.
Sometimes known as the residence time that shows the
total time a process spends in the system until it
terminates.
3. Waiting Time – the time each process has to wait
for processing before it terminates.
FIRST COME FIRST SERVED (FCFS)

✓ First come first served, also known as First In, First Out
(FIFO) allocates the CPU based on the time of arrival. It is
the simplest, and most common policy done to put order
in executing processes in the processor. Its main
disadvantage is poor performance which creates “convoy
effect”. The process in line will rely primarily on the
process in execution.
To illustrate this algorithm, let us solve the given problem. At time
= 0, we have only one job in the ready queue hence, the only job which
the short-term scheduler can choose is J1. J1 will execute with a burst of
12. At time=12, There are already 2 jobs in the ready queue, namely J2
and J3. Since J2 arrived first, J2 will process for a burst of 5 until time=27.
At time=27, the only job in the ready queue is J5. J5 will process until
time=36. The Gantt Chart will look like:
SHORTEST JOB FIRST (SJF)
In the shortest job first algorithm, the steps to single out a process
are as follows:
1. Check the time of arrival in the ready queue.
2. From the list of jobs in the ready queue, the job with the shortest
burst is allotted the processor and terminates when the burst time is
completed. In case where burst time of processes / jobs are the
same, use FCFS as the tie breaker.
NON-PREEMPTIVE PRIORITY (NPP)
In the non-preemptive priority algorithm, the steps to single out a
process are as follows:
1. Check the time of arrival in the ready queue.
2. From the list of jobs in the ready queue, identify and process
the job with the highest priority ( 1 being the highest). The chosen
job terminates when the burst time is completed. In case the assigned
priority of jobs are the same, use FCFS to pick the job which will
execute.
PREEMPTIVE PRIORITY (PP)
In preemptive priority algorithm, the steps to single out a process are
as follows:
1. Check the time of arrival in the ready queue.
2. From the list of jobs in the ready queue, identify and
process the job with the highest priority ( 1 being the highest). The
chosen job will be preempted to move out if an incoming job in the
ready queue has a higher priority.
SHORTEST REMAINING TIME FIRST (SRTF)
The shortest remaining time first is preemptive shortest job first. The
steps to single out a process to process are as follows:
1. Check the time of arrival in the ready queue.
2. From the list of jobs in the ready queue, identify and process the
job with the shortest remaining time (burst time). The chosen job will be
preempted to move out if an incoming jo0b in the ready queue has a
shorter remaining time.
ROUND ROBIN (RR)
✓ In round robin, the time slice should be specified. The time
slice or quantum defines the amount of time that a job is
allocated the processor.
✓ As the time slice of a job expires, it is preempted at that specific
time to go back to the tail of the ready queue. A job is terminated
when all its bursts have been completed otherwise it has to go
back to the ready queue.
✓ Assuming that P! has a bursts time of 23, and the quantum given is
5, P1 needs to go back to the processor 5 times to complete its
burst and terminate. The fifth time it goes to the processor will
only be to finish the remaining 3 burst.
The steps to single out a process are as follows:
1. Check all jobs and arrange them according to the time of arrival.
2. From the list of jobs in the ready queue, identify and process the
job according to the time slice specified. If the time slice is
greater than the burst time, the process is terminated when the
burst time is completed. If the time slice is less than the burst time,
the job expires at the end of the given time slice and returns to the
ready queue.

The following steps above are followed until the ready queue
becomes empty. Take note that every time a job is preempted, it goes
back to the ready queue at the time it was preempted.

Das könnte Ihnen auch gefallen