0% found this document useful (0 votes)
83 views21 pages

Operating Systems 2015-2016: Dr. O. Moonian Dept. of CSE Faculty of Engg. University of Mauritius

This document provides an introduction to operating systems and processes. It discusses that an operating system acts as an extended machine that hides hardware details and manages resources. A process is defined as an instance of a running program. Processes have states like running, ready, blocked. The operating system maintains process tables with process control blocks that store process state and allocation information. Interrupts cause process state switching and the operating system handles interrupt service. Multiprogramming improves CPU utilization by switching between multiple ready processes.

Uploaded by

jeremie daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views21 pages

Operating Systems 2015-2016: Dr. O. Moonian Dept. of CSE Faculty of Engg. University of Mauritius

This document provides an introduction to operating systems and processes. It discusses that an operating system acts as an extended machine that hides hardware details and manages resources. A process is defined as an instance of a running program. Processes have states like running, ready, blocked. The operating system maintains process tables with process control blocks that store process state and allocation information. Interrupts cause process state switching and the operating system handles interrupt service. Multiprogramming improves CPU utilization by switching between multiple ready processes.

Uploaded by

jeremie daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Operating Systems

2015-2016

Lecture 1
Introduction
Dr. O. Moonian
Dept. of CSE
Faculty of Engg.
University of Mauritius
1
Introduction

• A computer system consists of


– hardware
– system programs
– application programs
2
What is an Operating System

• It is an extended machine
– Hides the messy details which must be performed
– Presents user with a virtual machine, easier to use

• It is a resource manager
– Each program gets time with the resource
– Each program gets space on the resources

3
Introduction to Processes(1)
 The principal function of a processor is to execute
program instructions.
 The process concept is used to designate programs under
execution
 A process can be considered to be one of the following
– An instance of a program running on a computer
– A unit of resource allocation
• Previously the process could also be considered as :
– The entity that can be assigned to and executed on a processor
– A unit of activity characterized by the execution of a sequence
of instructions, a current state, and an associated set of system
instructions
4
Introduction to Processes(2)
• When a system is booted, the OS secretly starts a number
of processes, often unknown to the user, Eg.
– To wait for e-mails,
– Virus scanners,
– Wait for print commands.
• Whenever a user runs a program, a new process is started.
• A process consists of :
– the executable program,
– the program’s data and stack,
– its program counter,
– stack pointer and other registers
– A number of resources
– + all the other information required to run the program.
5
Introduction to Processes(3)
• The concept of a process allows the system to
– Interleave the execution of multiple programs (or
applications) to maximize processor utilization while
providing reasonable response time
– Allocate resources to applications
– Support communication among applications
– create a hierarchy of executable entities
• The life of a process is bounded by its creation and
termination

6
The Process Model
• All runnable software on the computer (sometimes
including the OS) is organized into processes.
• In the discussion of processes, it will be assumed that
the system has only one processor (or CPU).
• Each user views the CPU as executing his process
sequentially.
– In reality the CPU switches back and forth from process to
process.
– This is known as multiprogramming.
– It is, however, simpler, to think of the system as consisting of
a number of parallel processes.

7
The process Model
The diagram below briefly describes how a computer system handles multiprogramming.

8
The process Model
Trace of Process
• Sequence of instruction that execute for a process
• Dispatcher switches the processor from one process to another

9
The process Model

10
Process Creation
 Operating Systems have some way of creating processes.
 A process can be created whenever it is required.
 Principal events that cause process creation
1. System initialization
2. Execution of a process creation system call
3. User request to create a new process
4. Initiation of a batch job

11
Process Termination
• Processes either terminate voluntarily or are terminated
by the system
• Conditions which terminate processes
1. Normal exit (voluntary)
2. Error exit (voluntary)
– Eg. looking for a file but the file does not exist
3. Fatal error (involuntary)
– Eg. division by zero
4. Killed by another process (involuntary)

12
Process Hierarchies
 A process can create other processes which in turn can also
create processes.
 Thus we can have a hierarchical process structure.
 A process can also send messages to other processes
 In Unix a process and its descendants form a group and a
signal can be sent to the group.
 Also in Unix when the system starts, a special process called
init is created.
 Init creates one process at each terminal.
 When a user logs in, the process at the terminal creates a new

process
 Windows have no concept of process hierarchy.
 Thus processes have no parent-children relationship
13
Process States
A 3-states process model

Process Transitions

Possible process states


• running
• blocked
• ready
Transitions between states shown

14
Process States
A 5-states process model

15
Implementation of Processes(1)
 To implement processes, the OS maintains a table of structures
called the process table, with one entry per process.
– The entries are known as process control blocks

• Each entry (PCB) contains information about:


 The process state
 the program counter,
 the stack pointer
 memory allocation
 status of open files
 accounting
 scheduling
 + all the other information that must be saved when the process is
switched from running to ready or blocked mode

16
Implementation of Processes(2)

Some of the fields of a typical process table entry

17
Implementation of Processes (3)
– A process executes on the processor.
– During its execution, interrupts can occur (Eg. if an I/O
completes).
– When an interrupt occurs, the CPU needs to stop running the
process for some time and handle the interrupt.
– Associated with each I/O device is a location near the bottom of
memory, called an interrupt vector
– The interrupt vector contains the address of the interrupt service
procedure (or interrupt handler).

18
Implementation of Processes (4)
– The required information are pushed onto the stack by the
interrupt hardware (The information include the program
counter, the Program Status Word - which contains
information like the mode of execution the kind of interrupt
enabled etc., and some registers)
– The computer then jumps to the address specified by the
interrupt vector
– The interrupt service procedure starts out by saving all required
information in the process table
– It then calls the required procedure to do the real work of
processing the interrupt. (This will usually also involve waking
up a process)

19
Modeling Multiprogramming
• On Large Computers, Monoprogramming is rarely used
• For Fairness to all users and also
• Since processes spend a considerable amount of time
waiting for I/O
• Modelling Multiprogramming:
– If processes use the CPU for 20% of the time, then 5
processes would use the CPU at 100%.
– However this assumes that all the processes never wait for
the I/O at the same time.
– A more realistic approach is to make use of a probabilistic
model.
• Let n be no. of processes in memory and each process
waits for I/O a fraction p of its time.
– CPU utilization = 1-pn

20
Modeling Multiprogramming

21

You might also like