Understanding Process Scheduling: States, I/O vs CPU Processes, Table, and Policies, Study notes of Operating Systems

An overview of process scheduling, including the states of a process (new, ready, running, waiting, and terminated), i/o-bound and cpu-bound processes, the process table, and scheduling policies such as round robin, first-come first-served, and shortest job first. It covers the concept of context switching and the differences between non-preemptive and preemptive scheduling.

Typology: Study notes

Pre 2010

Uploaded on 07/31/2009

koofers-user-z54-2
koofers-user-z54-2 🇺🇸

10 documents

1 / 39

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Part 4. Processes and Process
Schedulling
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download Understanding Process Scheduling: States, I/O vs CPU Processes, Table, and Policies and more Study notes Operating Systems in PDF only on Docsity!

Part 4. Processes and Process

Schedulling

Optional Reading

Chapter 3 in Silberschatz et al. (stop before

3.4, threads)

Chapter 5 in Silberschatz et al. (skip 5.4,

thread scheduling)

Example of ps command

brastius 636 % ps -e PID TTY TIME CMD 0? 0:17 sched 1? 0:08 init 2? 0:00 pageout 3? 112:48 fsflush 317? 0:00 xdm 218? 0:01 cron 248? 0:00 sendmail 57? 0:00 sysevent 72? 0:00 picld 140? 0:20 in.route 153? 2:17 sshd 158? 0:43 rpcbind

New Ready Running Waiting Terminated

State Diagram

I/O-Bound Processes

Processes that are most of the time waiting for an event: mouse event, keyboard, Ethernet packet arrives etc. This type of processes spends most of its time in the waiting state. These processes are in ready/running state only for a short period of time: update mouse cursor after mouse movement show a character on the screen etc.

CPU-Bound Processes

These processes need the CPU for long periods of time: Scientific/Numerical Applications Compiler/Optimizer Renderer Image processing These processes are often in the ready or running state Most applications are I/O bound

Process Table

Process ID (PID) 0 1 2 3 4 5 MAX PID- . . . Each Entry Includes: PID: Index in process table -Command and args -List of memory mappings used by process -Owner -PC (Program Counter) -Registers -Stack pointer -List of Open Files -State (Wait, Ready, Running etc.)

Process Table

Each process table entry contains enough

information to restart (put in running state) a

process that is in the waiting or ready state.

A process may have more than one thread.

There is a stack, pc and a set of registers in

the process table entry for each thread that

the process has.

Example

“ps -eaf”

UID PID PPID CMD

root 1 0 /sbin/init

ntp 4859 1 /usr/sbin/ntpd

Note: if a parent process dies, the child

becomes an orphan

Orphan processes are “adopted” by init

Process Scheduling

From the user’s point of view, an OS allows running multiple processes simultaneously. In reality, the OS runs one process after another to give the illusion that multiple processes run simultaneously. The Process Scheduler is the OS subsystem that runs one process after the other and decides what process to run next. A Context Switch is the procedure used by the OS to switch from one process to another

Types of Scheduling

There are two types of scheduling:

 (^) Non Preemptive Scheduling  (^) Preemptive Scheduling

Non Preemptive Scheduling

  • (^) In Non Preemptive Scheduling a context switch (switch from one process to another) happens only when the running process goes to a waiting state or when the process gives up the CPU voluntarily.
  • (^) This is a very primitive type of scheduling. It is also called cooperative scheduling. It was used in Windows 3.1 and initial versions of MacOS. The main problem of Non Preemptive Scheduling is that a misbehaved process that loops forever may hold the CPU and prevent other processes from running.

Advantages/Disadvantages of

Non Preemptive Scheduling

  • (^) Advantages of Non Preemptive

Scheduling :

 (^) More control on how the CPU is used.  (^) Simple to implement.

Advantages of Preemptive scheduling:

 (^) More robust, one process cannot monopolize the CPU  Fairness. The OS makes sure that CPU usage is the same by all running process.

CPU Burst

Most processes require periodic CPU time only for a short while:  (^) CPU Burst  (^) e.g., process an event, then return to waiting state  Needs vary process by process The faster the needed CPU bursts are satisfied, the better the responsiveness of the OS. Average Completion Time: Average time a process waits for a CPU burst to be satisfied (until the task is completed)