Sunteți pe pagina 1din 60

ICT 223 Operating

Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

ICT 223 - Operating Systems


Mzumbe University (MU)

Mr. Kilima, F. G.
BSc. ICTM, (Mzumbe University)
MSc. Computer Science, (Makerere University)

April 9, 2015

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Code of conduct
Observe the following code conduct:
Be in class on time before the lecturer.

Late

comers will not be allowed to come in.


Switch off your phones while in class.

Phone

ringings will not be tolerated.


All communications concerning ICT 223

lectures, seminars, notes, assignments and


tests will be done via CR.
Any excuse for not attending a lecture/seminar

session should be communicated before via CR.


Use English for all communications with a

lecturer.
Strictly adhere to the timetable and deadlines

given.

ICT 223 Operating


Systems

Code of Conduct - Contd

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Class Representatives (CRs) do not approve

requests for failure to sit for tests.


No alternative tests will be given to any

students who will miss tests or assignments


without securing permissions from relevant
authorities.
Read all references provided to you for better

understanding of the topics covered.


Follow proper chain of command in presenting

your problems.
Observe the university rules and regulations.

ICT 223 Operating


Systems

Code of Conduct - Contd

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Lectures and tests will be conducted any day

and time as deems necessary including Friday,


Saturday or Sunday.
Course assessment:

Quiz - Many.
2 Assignments @ 10%.
2 tests @ 15%.
Final exams - 50%.

Hope to enjoy your maximum cooperation.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating System (OS)


It is a set of computer programs that runs and

controls computing resources (hardware and


application software) and acts as an interface
between computer user and hardware.
It is the most important software that runs a
computer to manage and control its resources
and operations.
It relieves the user from dealing with the
complexities of programs and hardware.
The OS provides the means for proper use of
these resources.
No any application software or hardware can be
utilized if a computer is not installed with
an operating system.
Different operating systems provide different
ways for users to tell the hardware to perform
some task.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating System (OS)


OS forms a layer of software whose function is

to provide user programs with a better,


simpler, cleaner model of the computer and to
handle managing all computing resources.
The OS executes in the kernel (supervisor)

mode in which it has complete access to all


hardware and can execute any instruction the
machine is capable of executing.
All other user programs execute in user mode

in which they have limited (subset) of


instructions to execute.
The OS runs on the bare hardware and provides

the base for other user programs.

ICT 223 Operating


Systems

Operating System (OS)

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating systems are huge, complex, hard to

write and long lived. They contain several


millions of lines of codes.
This explains why OS takes long periods of

time to evolve.
The OS is intimately tied to the hardware of

the computer it runs and it must know a great


deal of them.
The central part of the OS is called kernel.
It is arguably considered that what makes up

the kernel comprises the OS.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating System (OS)


OS for different devices are designed to

achieve different goals, some to be more


convenient, others to be more efficient while
others to be both more convenient and
efficient.
Since OS is a large and complex software, it

is created piece by piece and joined together


in away that all components can efficiently
recognize and communicate with each other.
A. Siblerchatz, P. Galvin and G. Gagne equate

the OS with government as it performs no


useful work by itself but provides conducive
environment within which other programs can do
useful work.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating System (OS)


Desktop operating systems are designed to have

high convenience and performance with little


attention on resource utilization.
Mainframe and minicomputers operating systems

are designed to maximize resource utilization


since many users are connected to them through
personal computers (terminals) in order to use
its limited resources.
These operating systems ensure that all

resources such as memory, CPU time, I/O system


etc are used efficiently and that no any user
takes more than its fair share.
OS runs all the time when the computer is on.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating System (OS)


Operating systems of some of the embedded

computer systems such as some home and


automobile devices are designed to operate
without human (user) intervention.
OS always faces numerous and possibly

conflicting requests for resources and it must


decide how to allocate them fairly without
causing resource starvation and deadlock.
OS acts as a control program which manages the

execution of user program to prevent errors


and improper use of computer.
Operating systems exist because they offer a

reasonable way to solve the problem of


creating a usable computing environment.

ICT 223 Operating


Systems

OS: Major goals

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Any operating system has the following goals:


To provide environment in which a user can

execute application software and make solving


user problems easier.
Supervises computer hardware to provide
appropriate mechanisms to ensure correct
operations of the system and efficient use of
the hardware.
Prevent application software from interfering
with proper operations of the system.
Make computer systems more convenient to use.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Interaction of OS with
other components

Figure: Interaction of Computer components

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of Operating
System
Operating systems serve the following

functions:
User Interface (UI): Provides UI in such forms

as:
Command Line Interface (CLI): Uses special
programs and text based commands to send
commands to the system.
Batch interface: Commands and directives to
control the commands are entered into files,
e.g. the use of punched cards.
Graphical User Interface (GUI): Uses a window
interface with icons, a pointing device to
direct I/O, menus and keyboard to enter text.
Resource allocation and control: Regardless of the

number of users or jobs running at the same


time, the OS coordinates resource allocation
for each process and prevent resource
starvation and deadlock.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of OS - Continued
CPU scheduling: An activity in which a CPU

switches among processes of different


programs, which is the basis for
multiprogramming. When a running process has
to wait (pause) for any reason, the OS takes
CPU away from it and gives the CPU to another
process. This process makes the computer more
productive.
Input/Output (I/O) handling: Recognizing input

from input devices, sending output to the


output devices and controlling all peripheral
devices. It also prevents a user process from
attempting to disrupt the normal operations of
the system such as by issuing illegal I/O
operations.

ICT 223 Operating


Systems

Mosquito net in Action

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Figure: Rampant use of mosquito nets in Tanzania

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of OS - Continued
Memory management:

The main memory (RAM)


provides the working area for CPU and is the
only large storage device that is accessible
by CPU directly. Due to multiprogramming,
small size of RAM, and large sizes of
programs, the OS provides efficient management
of RAM in order to improve CPU utilization and
CPUs response time. The OS memory management
tasks include:
Allocate and deallocate memory space to and

from programs.
Keep track of which memory parts are currently

being used and by which programs.


Decide which processes and data to move into

and out of the memory.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of Operating
System
Interrupt handling: An interrupt is a signal from

a hardware attached to the computer (hardware


interrupt) or from a software (software
interrupt) within the computer that causes the
operating system to stop and attend to it.
Interrupts provide a way to trap and handle
problems when they arise. OS provides the CPU
with appropriate instructions (interrupt
handler) for handling specific interrupt.
Interrupts do also provide a mechanism of
receiving information from hardware or
servicing a software routine.
Mass storage management: It is responsible
activities such as free space management,
storage allocation, disk scheduling, cache
management etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of OS - Continued
File system management: The OS is responsible

for creating and deleting files, creating and


deleting directories, backing up files etc.
Controls application software: The OS is

responsible for the installation, execution of


application software and allocating them
resources they need.
Controls computer hardware: The OS is

responsible for the installation and managing


of all hardware devices installed in the
system.
Enforces system security: Authenticate users,

prevent unauthorized access to system


resources etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of OS - Continued
Virtual memory: If a computer does not have

enough RAM needed to run programs, computer


uses virtual memory to compensate the RAM
deficit. This becomes necessary because of
the small sizes of RAM, need for big and fast
memory and low processing speed of the hard
disk. In creating the virtual memory:
The OS maps a portion of the hard disk (also

called hard drive) with memory addresses to


mimic RAM.
The OS modifies a small portion of the hard
disk to improve its performance (processing
speed).
The modified portion will exclusively be used
by the OS to store data and programs that would
been stored in RAM if it was big enough.
This temporary storage location in the hard

disk is called swap file or page file.

ICT 223 Operating


Systems

OS: Quiz (5 Minutes)

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

List any four services commonly being offered by


any computer OS.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Functions of OS - Continued
Multiprogramming: It is the ability of the

computer to run multiple programs at the same


time which aims at increasing resource
utilization and system performance. It is
done by operating system to simultaneously
keep several jobs in the memory (RAM). To
achieve multiprogramming:
The OS picks and begins to execute one of the

jobs in the memory.


When the (current) job has to wait for any

reason such as for I/O operation, the CPU


switches to and executes to another job.
When the second job has to wait, the CPU
switches another job.
When the first job finishes waiting, it is
given the CPU back.
All these operations are done under the

supervision of OS.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Kinds of Operating Systems


OS are developed to run on different kinds of

computer based devices (machines).


This has led to different kinds of OS as shown

below:
Mainframe OS: The OS which run on room sized

computers called mainframe computers found in


major corporate data centers, Internet web
servers, research centers etc. Mainframe
computers are connected to hundreds or
thousands of terminals (laptops, desktops or
workstation) and handle their data processing.
Handheld computer OS:The OS for handheld
computer devices such as smart phones, Personal
Assistant Digital (PDA) etc.
Personal computer OS: OS that runs on common
personal computers, mainly being mini-laptops,
laptops, desktops and workstations.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Kinds of Operating Systems


Most common kinds of OS are:
Server OS: They run on servers which allow

multiple users to share computing resources


over networks. Server machine can be large
personal computers, workstations, minicomputers
or mainframe computers. Servers provide
services such as print service, file service,
web service etc.
Sensor node OS: They run on networks of tiny
sensor nodes that communicate with each other
and the base station using wireless
communication. Sensor nodes are deployed for
various purposes such as protecting perimeters
of the building, guard national borders, detect
fires in the forests or smoke in the buildings,
measure temperature and precipitation for
weather forecasting, glean information about
enemy movements in the battle fields etc.

ICT 223 Operating


Systems

Kinds of Operating Systems

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Most common kinds of OS are:


Smart card OS:The smallest OS that runs on

smart cards which are credit card sized devices


containing a CPU chip. Smart cards are used
for various purposes such as SIM cards, ID
cards, credit cards, driving license etc.
Smart cards can store a lot of information of
persons and items they are created for.
Embedded OS: They run on devices that are not
generally thought of as computers and which do
not accept users installed software. These are
such as micro waves ovens, cameras, TV sets,
DVD recorders, cars, toys, MP3 players etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Operating systems:
Important Things to Know
Only when necessary, should a computer have

more than one operating system.


One computer may have as many application

software as per user needs, available free


disk space, processing power, OS platform etc.
Examples of Operating systems are:
Windows OS - Windows 95,Windows Xp, Windows

Vista, windows 7 and windows 8.


Linux - Ubuntu, Debian, Fedora, Linux Mint,

Gentoo, Mandriva, Knoppix, Red Hat and SUSE.


Unix, Solaris, Mac OS etc.

ICT 223 Operating


Systems

Operating system Structure

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

An OS provides the environment within which

programs are executed by providing certain


vital services to programs and users.
OS vary greatly in their make up since they

are organized along different lines.


Before designing an OS, its goals must be well

defined in order to form the basis for choices


among various algorithms and strategies.
OS can be viewed from various vantage

(advantageous) points such as services they


offer, security, interfaces it provides to
users, components it has, performance etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

System calls
System call is a means by which a process

requests a specific kernel service.


A process is a program in execution which

among others includes current activity, data


etc.
Though there are hundreds of system calls,

they are generally categorized into the


following categories:

Process control
File management
Directory management
Device management
Information maintenance
Interprocess communication
Miscellaneous

ICT 223 Operating


Systems

Process control system


calls

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

They are system calls related to the

management of program processes.


They ensure that program process do execute

and finally halt either normally (gracefully)


or abnormally (abort).
They are responsible for:

load and execute processes


end and abort processes
create and terminate child processes
waiting for time
wait event or signal event
get and set process attributes
allocate and free memory

ICT 223 Operating


Systems

File management system


calls

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

They are the system calls issued in operations

related to file management such as:

open a file for reading, writing or both.


close an open file
Read data from a file into a buffer.
Write data from buffer into a file.
get and set attributes of a file.
create and delete file.

ICT 223 Operating


Systems

Directory management system


calls

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

They are the system calls issued in operations

related to directory and file management such


as:

create and delete (remove) directories.


allow sharing of files in a directory.
mount a file system.
unmount a file system.
create links of directories.

ICT 223 Operating


Systems

Device management system


calls

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

They are the system calls issued in operations

related to device management such as:


processing requests for devices such as memory,

hard drive, file etc by the process.


release of devices
write to a device
get and set device attributes
logically attach and detach device
provide exclusive use of devices by a process

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Information maintenance
system calls
They are responsible for the transferring of

information between user programs and OS.


Different kind of information usually flows

between user programs and OS such as date and


time, number of users, amount of used or free
memory space.
They are responsible for:
get and set time and date
get and set system data
get and set attributes for process, device,

file, directory etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Interprocess communication
system calls
Processes must be able to communicate with

each other in order to be able to share


information.
Two methods (models) of interprocess
communication are message passing model and
shared-memory model.
In a message-passing model, communicating
processes exchange messages with one other in
order to transfer information.
Before the communication, a connection must be
established and each process must have a name
which is translated by the OS into process
identifier.
After the connection has been established,
processes can then share messages.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Interprocess communication
system calls- Contd
In shared memory model, communicating

processes use a shared memory to share


messages for communication.
Because the OS prevents one process from

accessing another processs memory, shared


memory requires that communicating process
must remove this restriction.
After the restriction has been removed, the

processes can exchange information by reading


and writing on the shared memory.
The form of data and location of shared memory

are determined by the communicating processes.

ICT 223 Operating


Systems

Interprocess communication
system calls- Contd

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Interprocess communication system calls are

responsible for:

create and delete communication process


send and receive messages
transfer status information
attach and detach remote devices

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

OS design and
implementation
OS design goals
The first problem in designing an OS is to
define its goals and specification.
The design of the system will be affected by
the hardware, type of system, users of the
system etc.
There is no unique solution to the problem of
defining the requirements for an OS.
OS implementation
Once the OS has been designed, it must be

implemented.
Traditionally OS have been written in assembly

languages.
With the advent of high level programming

languages, OS are written using languages such


as C and C++.

ICT 223 Operating


Systems

OS design and
implementation

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

OS implementation
Linux and Windows OS are written using C
language with small sections of assembly code
for device drivers.
Advantages of using high level programming

languages in writing OS are:

OS are written faster.


OS contain shorter statements.
Easy to understand the statements and debug.
Increases portability across different CPU
types (Intel, Motorola, SPARC, MIPS etc)

Weaknesses of using high language are:


Reduced speed.
Increased storage requirements.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

OS design and
implementation

Weaknesses of using high level language:


However, major improvements in OS performance

are more likely to be the result of better data


structures, algorithms and hardware designs
than the use of assembly languages.
After the OS has been written and found to work
correctly, the bottleneck routines can be
identified and replaced with assembly language
equivalents.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

OS booting
Booting is the process of starting the

computer by loading the kernel into RAM.


When a computer is switched on, the bootstrap

programs stored in ROM or Electrically


Erasable Programmable ROM (EEPROM), takes
charge of running the computer.
Bootstrap programs are charged with loading
the kernel into RAM and initialize its
execution.
It also runs diagnostics, also known as Power
On Self Test (POST) to determine the states of
hardware devices connected to the systems.
When the POST is positive, bootstrap programs
proceed with other booting steps like
initializing the hardware such as RAM, CPU
registers, drives etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

OS booting- Contd
Bootstrap programs are stored in ROM or

special forms of ROM known as Electrically


Erasable Programmable ROM (EEPROM), which is
read only memory except when explicitly given
a command to become writeable.
This explains why smart phones can have their
OS upgraded, reinstalled, and computers have
their BIOS programs upgraded.
All forms of ROM and the programs they store
are commonly referred to as firmware.
ROM has become the best choice of memory for
storing bootstrap programs because:
It is non volatile:

Its contents can not be


erased even if the computer is switched off.
It is read only: Once programs have been
written, they can not be modified.
It can not be affected by computer virus
programs due to its read only nature.

ICT 223 Operating


Systems

Quiz II

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

List any four advantages of writing OS using

any of the high level programming languages


like C, C++ or Java.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Processes
Early computers allowed only one program to be

executed at one time.


The running program had access to all
resources of the system.
Current day computer systems allow multiple
programs to be loaded into memory (RAM) and
executed concurrently (simultaneously).
Program by itself is not a process.
Process is a program in execution with
associated set of resources such as data,
program counter etc.
For a program to be executed, a process is
created for that program.
Conceptually, each process has its own virtual
CPU, but practically the CPU switches back and
forth from process to process.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Processes
Two or more processes may be associated with

the same program, such as when a user runs


multiple copies of the same program.
A process can be either foreground or

background.
A foreground process is a process which

interact with users and performs some task for


them.
A background process is a process which is not

associated with particular users and have some


specific tasks such as receiving incoming
mails.
Background processes are also called daemon

processes.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Process states
As a process executes, it changes its state.
The state of the process is defined in part by

the activity it performs.


Each process may be in one of the following
states:
New: The process is being created.
Running: The process is being executed.
Waiting: The process is waiting for an event to

occur
Ready: The process is waiting to be assigned a

processor.
Terminated: The process has finished execution.

Though names of process states may vary from

system to system, the states they represent


are the same and found in all systems.

ICT 223 Operating


Systems

Process states

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Figure: Different states of a process

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Process Control Block (PCB)


A data structure in the OS kernel containing

the information needed to manage a particular


process.
It is also called Task Control Block.
PCB contains the following information:
Process state: A state of the process such as
new, ready, running, waiting, halted etc.
Program counter: A CPU register that that
stores the address of the next instruction to
be executed.
CPU registers: Are the high speed storage
locations of the CPU that that store different
kind of information required by the CPU.
CPU scheduling information: Includes process
information and scheduling information.
Memory management information: Information
related to memory assigned to a process.

ICT 223 Operating


Systems

Process Control Block (PCB)

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Components of the PCB:


Accounting information: Information related to
the CPU such as real time, time limits, process
numbers etc.
I/O status information: Includes a list of I/O
devices allocated to the process, a list of
open files etc.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

CPU scheduling
It is the basic of multiprogrammed operating

systems as it enables the CPU to switch among


process which increases computers performance
and efficiency.
The objective of multiprogramming is to have

some processes running all time in order to


maximize utilization of the computing
resources such as CPU.
Multiprogramming is achieved through time

sharing in which CPU switches among processes


so frequently that users can interact with
each program while it is running.
Process scheduler selects one process from a

set of several available processes for


execution on the CPU.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

CPU scheduling
For a single processor system, only one

process will be running at a time.


A process is executed until it has to wait for

a resource such as data, file or hardware.


When one process is waiting for a resource,

the CPU picks up another process, until the


resource for the earlier process becomes
available.
This ensures that CPU does not waste any time
when one process is waiting for the resource,
that is the CPU does not become idle.
For this to happen, several processes are kept
in memory (RAM) at the same time.
When one process is to wait, the OS takes the
CPU away from that process and give the CPU to
another process.

ICT 223 Operating


Systems

CPU scheduling

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

This pattern is repetitive that each time one

process has to wait, another process has to


take CPU.
CPU scheduling is central to the OS design.
When the CPU is to be idle, the OS selects a

process from the processes in the memory that


are ready to execute (ready queue) and
allocate the CPU to that.
The ready queue is not necessarily a first-in,

first-out (FIFO) queue.

ICT 223 Operating


Systems

Nonpreemptive CPU
scheduling

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

It is CPU scheduling scheme in which a process

that has been allocated CPU keeps the CPU


until it releases the CPU either by
terminating or by switching to the waiting
state.
Nonpreemptive CPU scheduling occurs in either
of the following conditions:
When a process switches from running state to

the waiting state.


When a process terminates after completing its

execution.

ICT 223 Operating


Systems

Preemptive CPU scheduling

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

It is a CPU scheduling scheme in which a

process is forced to relinquish the CPU before


it finishes its execution.
Preemptive CPU scheduling occurs in either of
the following conditions:
When a process switches from running state to

the ready state.


When a process is suspended.
When the process is canceled.

Preemptive scheduling scheme incurs a cost

associated with access to shared data.

ICT 223 Operating


Systems

Warming Up

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Make revision on Java programming.


Areas of Interests:
Data structures such as arrays, lists, stacks
etc.
Multithreading
Networking
File input and output

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

CPU scheduling criteria


Several criteria are used by the OS to compare

and choose CPU scheduling algorithms.


Commonly used criteria are:
CPU utilization: The CPU must be utilized to the
maximum.
Throughput: As many processes must be completed
per unit time as possible.
Turnaround time: The time between the submission
of the of process and its completion.
Waiting time: It is the sum of periods spent for
a process waiting in the ready queue.
Response time: It is the time from submission
of the request to execute the process and
getting its output.

ICT 223 Operating


Systems

CPU scheduling algorithms

BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Commonly implemented CPU scheduling algorithms

are:
First-Come, First Served (FCFS) CPU scheduling

algorithm
Shortest Job First (SJF) CPU scheduling

algorithm
Priority CPU scheduling algorithm
Round Robin (RR) CPU scheduling algorithm
Multilevel Queue CPU scheduling algorithm
Multilevel Feedback Queue CPU scheduling
algorithm

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

First-Come, First Served


(FCFS) scheduling algorithm
It is also known as First-in-first-out (FIFO)

or strict queuing scheme.


It is the simplest CPU scheduling to code and

implement.
The processes are assigned CPU in the order

they request it.


The implementation of the FCFS is managed by

the FIFO queue.


When a process enters the ready queue, its PCB

is linked with the tail of the queue.


When the CPU is free, it is allocated process

at the head of the queue.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

First-Come, First Served


(FCFS) scheduling algorithm
The average waiting time under FCFS policy is

often quite long.


Each time a process that has been in the ready

queue the longest is picked.


It is a nonpreemptive scheduling algorithm.

Group Assignment
Discuss the strengths and weaknesses of FCFS.
Using an array data structure, write a Java

program that accepts ten string literals and


displays them based on the FCFS algorithm.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Shortest Job First scheduling


algorithm
It associates each process with the CPU burst

(also known as burst time).


Burst time is the amount of time the process

uses the CPU.


When the CPU is free, it is assigned a process

that has the smallest next burst time.


The algorithm ensures that the shortest

process jumps to the head of the queue past


longer jobs.
If the next CPU bursts of the two processes

are the same, then FCFS algorithm is used to


break the tie.
It is a nonpreemptive algorithm.

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Shortest Job First scheduling


algorithm

Consider the following processes;

Process
Burst Time
P1
6
P2
8
P3
7
P4
3
Using SJF, the CPU would be assigned to the
processes in the order P4 , P1 , P3 , P2

ICT 223 Operating


Systems
BSc. ICT-M
II, BSc.
ICT-B II &
BSc. ITS II

Shortest Job First scheduling


algorithm
Individual Assignment
Discuss the strengths and weaknesses of SJF

algorithm.
Using an array data structure, write a Java

program that accepts ten string literals, and


ten integer values each associated with a
specific string literal. After accepting the
values, the program should then output string
literals starting with the one with the
shortest time value and finishing with a
string literal that has the largest time
value. The time values SHOULD NOT be set in
any predetermined order (ascending or
descending order).

S-ar putea să vă placă și