You are on page 1of 23

Operating System

Process & Scheduling

Process is a program in execution
process execution must progress in sequential fashion
a process includes:
1. program counter
2. stack
3. data section
Process in Memory
operating system process

Process State (important)

As a process executes, it changes state

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 processor
Terminated : The process has finished execution

operating system - process

Diagram of Process State

operating system - process

Process Control Block (PCB)

Information associated with each process
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management information
Accounting information
I/O status information
Where is it ?
operating system - process

CPU Switch From Process to Process

operating system - process

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
Processes migrate among the various queues

operating system - process

Representation of Process Scheduling

operating system - process

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

operating system - process

Addition of Medium Term Scheduling

operating system - process


Context Switch (important)

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
Context of a process represented in the PCB
Context-switch time is overhead; the system does no
useful work while switching
Time dependent on hardware support
operating system - process


Process Creation
Parent process create children processes, which, in
turn create other processes, forming a tree of
Process identified and managed by a process
identifier (pid)

operating system - process


Process Creation (cont)

UNIX examples (UNIX ????)
fork system call creates new process
exec system call used after a fork to replace the
process memory space with a new program

operating system - process


Process Termination
Process executes last statement and asks the OS to delete it (exit)
Output data from child to parent
Process resources are deallocated by OS
Parent may terminate execution of children processes (abort)
Child has exceeded allocated resources
Task assigned to child is no longer required
parent is exiting
Some operating system do not allow child to continue if its parent

All children terminated - cascading termination

operating system - process


Interprocess Communication
Processes may be independent or cooperating (Can
affect or be affected by other processes, including
sharing data)
Why cooperating ?
Information sharing , Computation speedup ,
Modularity, and Convenience
Two models of IPC :
Shared memory & Message passing
operating system - process


IPC model
Which one is message passing ?
Which one is Shared memory ?

operating system - process



selects from among the processes in memory that are ready to
execute, and allocates the CPU to one of them

decide when a process :

1. running to waiting state
2. running to ready state
3. waiting to ready state
4. Terminates

Scheduling under 1 and 4 is nonpreemptive

All other scheduling is preemptive
operating system CPU Scheduling


Scheduling Factor

1. CPU utilization - keep the CPU as busy as possible

must be maximized
2. Throughput - number of processes that complete their execution
per time unit
must be maximized
3. Turnaround time - amount of time to execute a particular process
must be minimized
4. Waiting time - amount of time a process has been waiting in the
ready queue
must be minimized
5. Response time - amount of time it takes from when a request was
submitted until the first response is produced, not output (for
timesharing environment)
must be minimized
operating system CPU Scheduling



operating system CPU Scheduling


1. Abraham Silberschatz, Peter Baer Galvin, Greg
Gagne, Operating System Concepts With Java,

operating system - process


Assignment 2
Make report about your experiment in dual boot
Experiment 1 - Windows Linux
1. Explain detail steps to install windows and then linux on the same machine/pc
2. Explain about GRUB, or LILO according to the installation
Experiment 2 Linux windows x
1. Explain detail steps to install linux and then windows on the same machine/pc
2. Is there any difference installation steps between 1st experiment and 2nd
3. How about the GRUB or LILO, is it all right ? or anything is missing ? Explain how to
overcome the missing thing (if there is something wrong)

operating system - process


Submit your report to elearning
REPORT must contain :
1. Cover page : Student id, and bla bla bla
2. Explanation important step of those experiments
3. References
Format : AS2-<NRP>.pdf (eg. AS2-5214100010.pdf)

operating system - process