0% found this document useful (0 votes)
9 views

Chapter1 Unit1

Uploaded by

raunakraj0110
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Chapter1 Unit1

Uploaded by

raunakraj0110
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 105

Chapter 1: Introduction(OS Structure,

Modes and Services)By: Parveen Kaur


OPERATING SYSTEM?

• Abstract: To simplify how


hardware actually looks
like.

• Arbitrate: To manage , to
oversee the hardware
use
Definition of Operating System

– A program that acts as an intermediate/ interface


between a user of a computer and the computer
hardware.
• OS is a resource allocator

Manages all resources

Decides between conflicting requests for efficient and
fair resource use
• OS is a control program

Controls execution of programs to prevent errors and
improper use of the computer
What is an Operating System?


It is a layer of system software that:

directly has privileged access to underlined hardware

hides hardware complexity

manages hardware on behalf of one or more
applications according to policies.

An operating system is the one program that is running
at all the times on the computer- usually called the
kernel.

Kernel is a program that (allow) let the hardware to
recognize and read the program/process.
Operating System Goals:

– Execute user programs and make problem


solving easier.
– Make the computer system convenient to
use
– Efficiently use available resources
Computer System Structure
• Computer system can be divided into four components:
– Hardware – provides basic computing resources

CPU, memory, I/O devices
– Operating system
• Controls and coordinates use of resources among various
applications and users
– System/Application programs – define the ways in which the
system resources are used to solving user problems

Word processors, compilers, web browsers, database systems,
video games
– Users

People, machines, other computers
Abstract View of System Components
Computer Startup

• bootstrap program is loaded at power-up or reboot



Typically stored in ROM or EPROM, generally known as
firmware

Initializes all aspects of system

It checks the CPU, memory, and basic input-output
systems (BIOS) for errors. Once successful, the software
will begin to activate the computer's disk drives.

It then finds the first piece of the operating system: the
bootstrap loader , Which Loads operating system kernel
and starts execution.
Bootstrap Loader


The bootstrap loader sets up the small driver programs that
interface with and control the various hardware. It sets up the
divisions of

memory

user information, and

Applications

It establishes the data structures needed to communicate
within and between the subsystems and applications of
the computer.

Then it turns control of the computer over to the operating
system. Wind
Computer System Organization

Computer-system operation


One or more CPUs, device controllers connect through common bus
providing access to shared memory

Concurrent execution of CPUs and device controllers competing for
memory cycles
Computer-System Operation


I/O devices and the CPU can execute concurrently

Each device controller is in charge of a particular device
type

Each device controller has a local buffer

CPU moves data from/to main memory to/from local
buffers

I/O is from the device to local buffer of controller

Device controller informs CPU that it has finished its
operation by causing an interrupt
Interrupt

The occurrence of an event is usually signaled by an
interrupt from either the hardware or software.
• Hardware can trigger an interrupt at any time by sending a
signal to CPU, usually through Data Bus.
• Software may trigger an interrupt by executing a special
operation called system call/ monitor call
Types of Operating System
Batchoperating
The users of a batch Operating
systemSystems
do not interact with the
computer directly.
Each user prepares his job on an off-line device like punch cards and
submits it to the computer operator.
To speed up processing, jobs with similar needs are batched together
and run as a group .

*[https://www.tutorialspoint.com/operating_system/os_types.htm]
Batch Operating Systems

Jobs are batched together by type of languages and requirements, on
first come first serve basis.

Then a special program, the monitor program, manages the execution
of each program in the batch.

The monitor program is always in the main memory and available for
execution.

Bank System, Payroll System, data entry systems.
Advantages:

improves computer efficiency as it eliminates CPU time between two
jobs.
Disadvantages:

No interaction between user and computer.

No mechanism to prioritize the processes.

Starvation, difficult to debug.
Batch Operating Systems


Early computers were machines run from a console

The common input devices were card readers and tape drives.

The common output devices were line printers, tape drives, and card
punches.

To speed up processing, operators batched jobs with similar needs
together and ran them through the computer as a group.
User Prepares a JOB (Program) using Punch Cards  Computer
Operator Wait for Output
Multiprogrammed OS

2 or more processes reside in memory at the same time

Single user processes cannot keep CPU and I/O devices busy at all
times

Multiprogramming organizes jobs (code and data) so CPU always
has one to execute

It is mixture of I/O bound and CPU bound processes

Multiprogramming assumes a single shared processor. One job
selected and run via job scheduling from job pool
Multiprogrammed OS

Job scheduling is the process of allocating system
resources to many different tasks by an operating system.

If several jobs are ready to run at the same time, then the
system chooses which one to run through the process of
CPU Scheduling.

In this the operating system picks up and begins to execute
one of the jobs from memory .

Once this job needs an I/O operation operating system
switches to another job (CPU and OS always busy).

Jobs in the memory are always less than the number of jobs
on disk(Job Pool).
Multiprogrammed OS
Advantages:

Multiprogramming increases CPU utilization, CPU will never
be idle and keeps on processing.

Reduce response time
Disadvantages:

No interaction between user and computer.
Multitasking/Timesharing OS

Multiple jobs are executed by the CPU simultaneously by
switching between them.

The time that each task gets to execute is called quantum.
After this time interval is over OS switches over to the next
task.

Only one CPU is involved, but it switches from one process to
another so quickly that it gives the appearance of executing all
of the processes at the same time.
Multitasking/ Time Sharing OS

There is at least one program is executing in memory
process

If several jobs ready to run at the same time  CPU
scheduling

If processes don’t fit in memory, swapping moves them in
and out to run.

If a program is not using the CPU, however, it can allow
another program to use it temporarily.

Multics, Unix, etc.

Types of Multitasking OS:
1. Preemptive: the operating system parcels CPU time slices to
each program.
2. Cooperative: each program can control the CPU for as long as
it needs it.


In time sharing systems the prime focus is on minimizing
Multitasking/ Time Sharing OS
Advantages:

Each task gets an equal opportunity

Fewer chances of duplication of software

CPU idle time can be reduced
Disadvantages:

Reliability problem

One must have to take care of the security and integrity of
user programs and data

Data communication problem
Multiprocessing OS
• A multiprocessor system consists of several
processors that share a common physical memory,
operating system as well, Parallel computing is
achieved.
• Multiprocessor system provides higher computing
power and speed.
Multiprocessing OS

Multi-processor systems; that is, they have multiple CPU.
• Also known as parallel systems or tightly coupled systems
• Such systems have more than one processor in close communication,
sharing the computer bus, the clock, and sometimes memory and
peripheral devices.

Types of Multiprocessing OS:
1. Symmetric : Symmetric multiprocessing occurs when many processors
work together to process programs using the same OS and memory.
Shared memory allows all processors to communicate with one another.
2. Asymmetric : The processing of programs by several processors in a
master-slave arrangement is known as asymmetric multiprocessing.
Processors do not need to communicate because the master processor
controls them.
Multiprocessing OS
Advantages:

This operating system is more suited to supporting multiple
users simultaneously.

The multitasking operating systems have well-defined
memory management.
Disadvantages:

The multiple processors are busier at the same time to
complete any task in a multitasking environment, so the CPU
generates more heat.
Network Operating System

These systems run on a server and provide the capability to
manage data, users, groups, security, applications, and
other networking functions, in small private area(LAN).

These types of operating systems allows multiple devices
within a network to communicate and share resources with
each e.g. access of files, printers, etc.
Network Operating System

The role of the NOS is to provide basic network services and
features that support multiple input requests simultaneously in
a multiuser environment.
• Tightly coupled systems, all the users are well aware of the
underlying configuration, of all other users within the network,
their individual connections, etc.

Types of Network OS:
1. Peer to Peer: allow users to share network resources saved in
a common, accessible network location. All devices are treated
equally in terms of functionality. Used for small to medium
LAN.
2. Client- Server: provide users with access to resources through
a server, all functions and applications are unified under one
file server that can be used to execute individual client actions
regardless of physical location.
Network Operating System
Advantages:

Network traffic reduces due to the division between clients and
the server.

It acts as a backup for the individual computers that are
connected to the network.

Highly secure with features like authorization of users,
hardware authentication, restrictions on shared data…
Disadvantages:

Servers are costly.

User has to depend on central location for most operations.

Maintenance and updates are required regularly.
Distributed Systems

A distributed operating system is one in which several
computer systems connected through a single
communication channel.

These systems have their individual processors
and memory. Communicate through high-speed buses or
telephone lines.

The individual components or systems of the network are
nodes
Distributed Systems

Each system over the network keeps copy of the data, and this
leads to Reliability (Because if one system crashes , data is not
lost).

Loosely coupled systems independent systems possess their
own memory unit and CPU.
Advantages:

The load on the system decreases.

If one system stops it will not affect the other, fault-tolerant.

This type of system is fault-tolerant.
Disadvantages:

Software used for such systems is highly complex.

Failure of the main network will lead to the failure of the whole
system.

Real Time
Time bound systems
Operating System

It is employed mostly in those systems in which the results of the
computations are used to influence a process while it is executing,

E.g. Airlines reservation system, Heart Pacemaker.

When an event occurs outside of the computer, it is conveyed to
the computer via a sensor that is used to monitor the event. The
sensor generates a signal that the OS interprets as an interrupt.
When the operating system receives an interrupt, it starts a specific
process or a collection of processes to handle it.

Real-time systems are concurrent, which means they may respond
to several processes at once. Within the system, there are multiple
separate jobs going on, and it replies to each one in brief intervals.
Real Time Operating System
• Types of Real Time OS:
1. Soft Real time Systems: There may be a deadline assigned to a
job/process, but a minor delay(Positive delay) is allowed .
Exp: online transaction systems.
2. Hard Real Time Systems: Each process is assigned a specific
time instance, and Process must complete in that time otherwise
system will crash.
Exp: airline traffic control system, heart pacemaker.
3. Firm Real Time Systems: also need to follow the deadlines.
However, missing a deadline may not have big impact but could
cause undesired affects, like a huge reduction in quality of a
product.
Exp: Various types of Multimedia applications.
Operating Syst
OS can be explored from 2 view points:
1. User view:

The goal of the Operating System is to maximize the work and
minimize the effort of the user.

Operating System gives an effect to the user as if the processor is
dealing only with the current task, but in background processor is
dealing with several processes.
2. System View:
Operating System is a program involved with the hardware.

OS is a resource allocator

Allocates and Manages all resources and their sharing.

Decides between conflicting requests for efficient and fair resource
use

OS is a control program

Controls execution of programs to prevent errors and improper use of
the computer
Operating-System Operations

To protect OS, Dual-mode operations exist:

User mode (1) and kernel mode (0)

A Mode bit is added to hardware to indicate mode


Provides ability to distinguish when system is running
user mode or kernel mode

System call changes mode to kernel, return from call
resets it to user

Kernel mode is also called supervisor mode, system
mode or privileged mode.
Operating-System Operations


OS’s are Interrupt driven. If no process, no I/o devices, No
users then OS will sit quietly waiting for some event to
occur.


Program or software send, Generate Events by using system
calls. Error or request by a software creates exception or
trap

E.g. Division by zero

To ensure proper execution of OS, we must distinguish
between execution of OS code and user defined code.
User/Kernel Protection Boundary
User/Kernel Protection Boundary
Transition from User to Kernel Mode
Transition from User to Kernel Mode

Timer to prevent infinite loop / process hogging resources

Timer is set to interrupt the computer after some time period

Keep a counter that is decremented by the physical clock.

Operating system set the counter (privileged instruction)

When counter zero generate an interrupt

Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Operating Syste
It is easier to create an operating system in pieces, much as we break down larger issues into
smaller, more manageable subproblems. Every segment is also a part of the operating system.
Operating system structure can be thought of as the strategy for connecting and incorporating
various operating system components within the kernel.


Simple Structure

Monolithic Structure

Layered Approach Structure

Micro-Kernel Structure

Exo-Kernel Structure

Virtual Machines
Operating System Structure
1. Simple Structure -- MS-DOS

written to provide the most functionality in the least space

Not divided into modules

Although MS-DOS has some structure, its interfaces and levels of
functionality are not well separated

Advantages of Simple Structure:

Because there are only a few interfaces and levels, it is simple to
develop.

Because there are fewer layers between the hardware and

the applications, it offers superior performance.


Disadvantages of Simple Structure:

The entire operating system breaks if just one user program
malfunctions.

Since the layers are interconnected, and in communication with one
another, there is no abstraction or data hiding.

The operating system's operations are accessible to layers, which
can result in data tampering and system failure.
2. Non Simple Structure -- UNIX
The UNIX OS consists of two parts:

1. System programs

2. The kernel

Consists of everything below the system-call
interface and above the physical hardware

Provides the file system, CPU scheduling, memory
management, and other operating-system functions;
a large number of functions for one level
Traditional UNIX System Structure
Traditional LINUX System Structure
Kernel has many inbuilt modules
Layered Approach

The operating system is
divided into a number of
layers (levels), each built on
top of lower layers. The
bottom layer (layer 0), is the
hardware; the highest (layer
N) is the user interface.

With modularity, layers are
selected such that each uses
functions (operations) and
services of only lower-level
layers

Advantages of Layered Structure:

Work duties are separated since each layer has its own functionality, and
there is some amount of abstraction.

Debugging is simpler because the lower layers are examined first, followed
by the

top layers.


Disadvantages of Layered Structure:

Performance is compromised in layered structures due to layering.

Construction of the layers requires careful design because upper layers only

make use of lower layers' capabilities.
Operating System Services

An operating system provides an environment for the programs to run.

It provides certain services to programs
Operating System Services

Operating-system services provides functions that are
helpful to the user:
– User interface - Almost all operating systems have a user interface
(UI)

Varies between Command-Line (CLI), Graphics User Interface
(GUI).
– Program execution - The system must be able to load a program into
memory and to run that program, end execution, either normally or
abnormally (indicating error)
– I/O operations - A running program may require I/O, which may
involve a file or an I/O device.
– File-system manipulation - read and write files and directories,
create and delete them, search them, list file Information,
permission management.
Operating System Services
– Communications – Processes may exchange information, on the same
computer or between computers over a network
• Communications may be via shared memory or through message
passing (packets moved by the OS)
– Error detection – OS needs to be constantly aware of possible errors

May occur in the CPU and memory hardware, in I/O devices, in
user program

For each type of error, OS should take the appropriate action to
ensure correct and consistent computing

Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system.

Resource allocation – OS must ensure allocation of resources to all
programs running.

Many types of resources - such as CPU cycle time, main memory,
and file storage, I/O devices
Operating System Services


Accounting - To keep track of which users use how much and
what kinds of computer resources.

Protection and security - The owners of information stored in a
multiuser or networked computer system may want to control
use of that information, concurrent processes should not
interfere with each other

Protection involves ensuring that all access to system resources
is controlled

Security of the system from outsiders requires user
authentication, extends to defending external I/O devices
from invalid access attempts

If a system is to be protected and secure, precautions must
be instituted throughout it.

A chain is only as strong as its weakest link.
Kernel


A kernel is a central component of an operating system.

It acts as an interface between the user applications and the hardware.

The sole aim of the kernel is to manage the communication between the
software (user level applications) and the hardware (CPU, disk memory
etc).

The main tasks of the kernel are :

Process management

Device management

Memory management

Interrupt handling

I/O communication

File system...etc..
Kernel

A kernel is the lowest level of software that interfaces with
the hardware in your computer.

It is responsible for interfacing all applications that are
running in “user mode” down to the physical hardware,
and allowing processes, to get information from each other
using inter-process communication (IPC).

Types of Kernels :
1. Monolithic Kernel
2. Microkernel
3. Hybrid
Monolithic Kernel

A monolithic kernel is an operating system architecture
where the entire operating system (which includes the device
drivers, file system, and the application IPC etc.) is working in
kernel space, in supervisor mode.


Monolithic kernels are able to dynamically load (and unload)
executable modules at runtime.


Examples of operating systems that use a monolithic kernel
are - Linux, Solaris, OS-9, DOS, Microsoft Windows
(95,98,Me) etc.
Monolithic Kernel
Monolithic Kernel
Pros:

More direct access to hardware for programs

Easier for processes to communicate between each other

If your device is supported, it should work with no additional
installations

Processes react faster because there isn’t a queue for
processor time.
Cons:

Large install footprint

Large memory is needed

Less secure because everything runs in supervisor mode

Advantages of Monolithic Structure:

Because layering is unnecessary and the kernel alone is responsible for managing
all operations, it is easy to design and execute.

Due to the fact that functions like memory management, file management, process
scheduling, etc., are implemented in the same address area, the monolithic kernel
runs rather quickly when compared to other systems. Utilizing the same address
speeds up and reduces the time required for address allocation for new processes.


Disadvantages of Monolithic Structure:

The monolithic kernel's services are interconnected in address space and have an
impact on one another, so if any of them malfunctions, the entire system does as
well.

It is not adaptable. Therefore, launching a new service is difficult.
MicroKernel

In a Microkernel architecture, the core functionality is
isolated from system services and device drivers.


This architecture allows some basic services like device
driver management, file system etc. to run in user space.


This reduces the kernel code size and also increases the
security and stability of OS as we have minimum code
running in kernel.


Examples of operating systems that use a microkernel are -
QNX, Integrity, PikeOS, Symbian, L4Linux, Singularity, K42,
Mac OS X, HURD, Minix, and Coyotos.
MicroKernel
– Advantages of Micro-Kernel Structure:
• It enables portability of the operating system across platforms.
• Due to the isolation of each Micro-Kernel, it is reliable and secure.
• The reduced size of Micro-Kernels allows for successful testing.
• The remaining operating system remains unaffected and keeps running properly even
if a component or Micro-Kernel fails.

– Disadvantages of Micro-Kernel Structure:


• The performance of the system is decreased by increased inter-module
communication.
• The construction of a system is complicated.
Types of Kernel
MicroKernel
Pros

Portability

Small install footprint

Small memory

Security
Cons

Hardware is more abstracted through drivers

Hardware may react slower because drivers are in user
mode

Processes have to wait in a queue to get information

Processes can’t get access to other processes without
waiting
HybridKernel

Hybrid kernels have the ability to pick and choose what they
want to run in user mode and what they want to run in
supervisor mode.

Device drivers and file system I/O will be run in user mode
while IPC and server calls will be kept in the supervisor
mode.

This require more work of the hardware manufacturer
because all of the driver responsibility is up to them.
Hybrid Kernel
Pros

Developer can pick and choose what runs in user mode and
what runs in supervisor mode

Smaller install than monolithic kernel

More flexible than other models
Cons

Processes have to wait in a queue to get information

Processes can’t get access to other processes without
waiting

Device drivers need to be managed by user
Interrupts

An interrupt is a signal from a device attached to a
computer or from a program within the computer that
causes the main program that operates the computer (the
operating system) to stop and figure out what to do next.


Interrupts can be of following type:


Generated by Hardware (Hardware Interrupt)

Generated by Software (Software Interrupt)
Hardware Interrupt

1. Hardware interrupts are used by devices to communicate


that they require attention from the operating system.
2. Hardware interrupts by sending signal to CPU via system
bus.
3. Hardware interrupts are referenced by an interrupt number.
4. These numbers are mapped with hardware that created
the interrupt. This enables the system to
monitor/understand which device created the interrupt and
when it occurred.
Software Interrupt/ Trap
• Interrupt generated by executing a
instruction.
• Software interrupts by a special operation
called a System Call or Monitor Call.
Exp: 1. cout in C++ is a kind of interrupt
because it would make a system to print
something.
2. division by zero
Basic steps when interrupt occurs:

1. Interrupt Occurred?
2. H/w Transfers control to OS
3. OS preserves current state of process by using
Registers and Program counter
4. Determine which kind of interrupt has occurred
and Provides resources
5. When interrupt is executed, address is loaded to
program counter and interrupted services are
resumed.
I/O Interrupt
• Once the I/O is started, 2 kind of interrupts may
arise:
• Synchronous interrupt (I/O): The control is
transferred to the user process when I/O completes.
• Asynchronous interrupt (I/O): Returns control to
user process without waiting for I/O to complete.
(a) Synchronous (b) Asynchronous
Waiting of I/O may be accomplished in 2
ways:


Wait: it let the CPU wait till the next
interrupt.


Loop: Loop continues until interrupt is
active.
Device Status Table
• To keep the track of how many I/O requests
are pending
• Device Status Table is maintained.
– Device type
– Address
– State (idle,busy)
System Calls

Allow user-level processes to request services of the operating
system.

It provides a way in which program talks to the operating system .

Why system calls are required?


• It is a request to the operating system to perform some activity.

It is a call to the kernel in order to execute a specific function that
controls a device or executes a instruction.


A system call looks like a procedure call
Accessing System Calls

System calls are accessed by programs via a high-level Application
Program Interface (API) (provides run time environment)


System calls are implemented via API, API’s interact with kernel of
OS.
Example of System Calls

System call sequence to copy the contents of
one file to another file
System Call Implementation

A number is associated with each system call

System-call interface maintains a table indexed according to
these numbers


The system call interface invokes intended system call
in OS kernel and returns status of the system call with a
return value.


The caller needs to know nothing about how the system
call is implemented

Just needs to obey API and understand what OS will do as a
result call

Most details of OS interface hidden from programmer by API
API – System Call – OS Relationship
Standard C Library Example

C program invoking printf() library call, which calls
write() system call
System Call Dispatch

1. Kernel assigns system call number to each system


number
2. Kernel initializes system call table, mapping system
call number to functions implementing the system
call
3. User process sets up system call number and
arguments
4. User process runs
System Call Dispatch

5. Hardware switches to kernel mode and calls


kernel’s interrupt handler for user process
(interrupt dispatch)
6. Kernel looks up syscall table using system call
number
7. Kernel calls/invokes the corresponding function
8. Kernel returns by running interrupt return and
processing the actual program.
System Call Parameter Passing
Passing Parameters to System Calls:

Information required for a system call vary according to OS
and call.


Three general methods used to pass parameters to the OS

1. Pass the parameters in registers

When parameters are < 6.

2. Parameters stored in a block, or table, in memory, and address
of block passed as a parameter in a register. (6 or more)

This approach taken by Linux and Solaris

3. Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system.
Parameter Passing via Table
Types of System Calls5 Categories

• Process Control • File Management



end, abort

load, execute –
create file, delete file

create process, –
open, close file
terminate process

get process attributes,

read, write,
set process attributes reposition

wait for time –
get and set file

wait event, signal event attributes

allocate and free
memory
Types of System Calls (Cont.)

Device Management •
Communications

request device, release device

read, write, reposition –
create, delete

get device attributes, set device communication
attributes connection

logically attach or detach devices –
send, receive

Information Maintenance messages

transfer status

get time or date, set time or date information

get system data, set system data

get and set process, file, or device

attach and detach
attributes remote devices
System Call Implementation
Q1. Who controls the execution of programs
to prevent errors and improper use of
computer?
a) Resource allocator
b) Control Program
c) Hardware
d) None of the above
Q2. The operating system switches from
user mode to kernel mode so the mode bit
will change from?
a) 0 to 1
b) 1 to 0
c) Remain constant
d) None
Q3. In which type of operating system users
do not interact directly with the computer
system?
a) Multiprogramming operating systems
b) Multiprocessing operating systems
c) Batch operating systems
d) Distributed operating systems
Ans 3) c
Q4. What is the objective of
multiprogramming operating systems?
a) Maximize CPU utilization
b) Switch the CPU among processes
c) Achieve multitasking
d) None of the above
Ans4. a)
Q5. Who signalled for the occurrence of
an event either from the hardware or the
software?
a) Bootstrap program
b) Interrupt
c) Disk Controller
d) CPU
Ans5: b
Q6. In which type of I/O interrupts the
control return to the user program after the
completion of I/O operation?
a) Synchronous I/O interrupts
b) Asynchronous I/O interrupts
c) System Call
d) Hardware
Ans 6) a
Q7: The device-status table containsa)
each I/O device typeb) each I/O device
state c) each I/O device address d) all of
the above
(d)
Ans 7 (d)
Storage Structure and Hierarchy
Magnetic Tape

Optical Tape
Main Memory (RAM)

You might also like