Os 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Operating System

by:
Bijoy Das

Assistant Professor

School of Computer Engineering

Kalinga Institute of Industrial Technology

1 / 31
What is an Operating System (OS) ?
A program that acts as an intermediary between a user of a computer
and the computer hardware

Operating System Goals


− Execute user programs
− Make the computer system convenient to use
− Use the computer hardware in an efficient manner.

OS Usage
− Hardware abstraction
− Resource Management

”The one program running at all times on the computer” is the kernel

Everything else is either


a system program, or
an application program
2 / 31
Computer System Structure

Hardware - provide basic computing resources


− CPU, Memory, I/O Devices

Operating Systems
− Controls and coordinates use of hardware among various applications
and users

Application Programs - define the ways in which the system


resources are used to solve the computing problems of the users
− Word processors, compilers, web browsers, database systems, video
games

Users
− People, machines, other computers

3 / 31
Four Components of a Computer System

user 1 user 2 user 3 ... user n

... database
compiler assembler text editor
system

system and application programs

operating system

computer hardware

Figure: Computer System Components

4 / 31
What Operating System Do

Depends on the point of view

Users wants convenience, ease of use and good performance


− Dont care about Resource Utilization

But shared computer such as mainframe or minicomputer must keep


all users happy

Users of dedicated systems such as workstations have dedicated


resources but frequently use shared resources from servers.

Handheld are resource-poor, optimized for usability and battery-life

5 / 31
OS as Resource Manager

Resources in Computer System


System call Interface Central Processing Unit (CPU)
Main Memory, Secondary Memory
Memory CPU
Management Scheduling
Input/Output Devices (I/O Devices)

File System
OS as Resource Manager
Management
Allow multiple processes to share
resources
Networking Inter Process Improves performance by efficient
Stack Communication
utilization of resources.

Device Drivers OS as Control Program


Controls execution of programs to
prevent errors and improper use of the
computer 6 / 31
Types of Operating System
Batch Operating System
This type of operating system does not interact with the computer
directly
There is an operator which takes similar jobs having the same
requirement and groups them into batches.
It is the responsibility of the operator to sort jobs with similar needs.

Figure: Batch Operating System 7 / 31


Contd..

Advantages of Batch Operating System


Multiple users can share the batch systems
The idle time for the batch system is very less
It is easy to manage large work repeatedly in batch systems

Disadvantages of Batch Operating System


The computer operators should be well known with batch systems.
Batch systems are hard to debug.
It is easy to manage large work repeatedly in batch systems

8 / 31
Multi-Programming Operating System

It can be simply illustrated as more than one program is present in


the main memory and any one of them can be kept in execution.
This is basically used for better execution of resources.

Figure: Multi-Programming Operating System

Advantages
Multi Programming increases the Throughput of the System
It helps in reducing the response time 9 / 31
Multi-Processing Operating System

a type of Operating System in which more than one CPU is used for
the execution of resources.
It betters the throughput of the System

Figure: Multi-Processing Operating System

10 / 31
Time-sharing Operating System

Each task is given some time to execute so that all the tasks work
smoothly.
Each user gets the time of the CPU as they use a single system

Figure: Time-sharing Operating System


11 / 31
Contd ..
Advantages of Time-sharing OS
Each task gets an equal opportunity
CPU idle time can be reduced
Resource Sharing: Time-sharing systems allow multiple users to
share hardware resources such as the CPU, memory, and peripherals,
reducing the cost of hardware and increasing efficiency
Improved Productivity: Time-sharing allows users to work
concurrently, thereby reducing the waiting time for their turn to use
the computer. This increased productivity translates to more work
getting done in less time.

Disadvantages of Time-sharing OS
High-overhead
complexity
Security Risks
12 / 31
Real-time Operating System
These types of OSs serve real-time systems.

The time interval required to process and respond to inputs is very


small. This time interval is called response time

Real-time systems are used when there are time requirements that are
very strict like missile systems, air traffic control systems, robots, etc.

Types of Real-time Operating System


Hard Real-Time Systems
− Air Traffic Control
− Medical System
Soft Real-Time Systems
− Multimedia Transmission and Reception
− Computer Games
− Communication system like voice over Ip
13 / 31
Operating System Structure

Multiprogramming needed for efficiency


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

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


one to execute

A subset of total jobs in system is kept in memory

one job selected and run via job scheduling

When it has to wait (for I/O for example), OS switches to another job

14 / 31
contd ..
Timesharing (multitasking)
is logical extension in which CPU switches job so frequently that users can
interact with each job while it is running, creating interactive computing
Response Time should be < 1 second

Each user has at least one program in execution → Process

If several jobs ready to run at the same time → CPU Scheduling

If processes don’t for in memory, Swapping moves them in and out to


run

virtual memory allows execution of processes not completely in


memory
15 / 31
OS provides Abstraction

What is the output of the program ? Displaying on the Screen


ld
Wor
Main Memory (RAM) Hello
#include <stdio.h>
int main () {

char str [ ] = " Hello World!\n"; ld +


Processor Wor or +
printf("%s", str); Hello es + Col
t
rdina
Coo depth
}
Graphics Card

How the string is displayed on the screen ?


Monitor

16 / 31
Contd ..

Usage of OS
App Easy to program apps
− No more nitty-gritty
printf ("%s", str); details for
programmers
system call
Reusable
( write to STDOUT )
− apps can reuse OS
Operating System functionality
device driver Portable
− The app does not
change when
hardware changes

17 / 31
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect through a common bus
providing access to shared memory
Concurrent execution of CPUs and devices competing for memory
cycles.

18 / 31
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 the local buffer of the controller

Device controller informs CPU that it has finished its operation by


causing an interrupt

19 / 31
Storage Definition and Notation Review

− bit: basic unit of computer storage. It can contain one of the two
values 0 and 1
− A byte is 8 bits
− word: Unit of data. It is made up of one or more bytes.
− A kilobyte, or KB, is 1024 bytes or 210 bytes
− A megabyte, or MB, is 10242 bytes or 220 bytes
− A gigabyte, or GB, is 10243 bytes or 230 bytes
− A terabyte, or TB, is 10244 bytes or 240 bytes
− A petabyte, or PB, is 10245 bytes or 250 bytes

Computer manufacturers often round off these numbers and say that a
megabyte is 1 million bytes and a gigabyte is 1 billion bytes

20 / 31
Storage Structure
Main Memory
Storage media that the CPU can access directly
− Random access
− Volatile

Hard Disk
Rigid metal or glass platters covered with magnetic recording material
− Disk surface is logically divided into tracks, which are subdivided into
sectors
− The disk controller determines the logical interaction between the
device and the computer

Solid-state disks
faster than hard disks, nonvolatile faster than hard disks, nonvolatile
− Various technologies
− Becoming more popular 21 / 31
Storage Hierarchy

Storage System Organized in Hierarchy


− Speed
− Cost
− Size

Caching– Copying information into faster storage system. Main


memory can be viewed as a cache for secondary memory

22 / 31
Storage-Device Hierarchy

Figure: Storage Hierarchy


23 / 31
Caching

Important Principle, performed at many levels in a computer


(hardware, OS, software)

Information in use copied from slower to faster storage temporarily

Faster Storage (cache) checked first to determine if information is


there
− If it is, information is accessed directly from the cache (fast)
− If not, data copied to cache and then used

24 / 31
Major OS Components

Process Management

Memory Management

I/O device Management

Secondary Storage Management

file systems Management

Protection Management

Network Management
25 / 31
Process Management

A process is a program in execution. It is a unit of work within the


system. A program is passive entity but process is active entity

Process needs resources to complete its task


− CPU, Memory, I/O, files

process terminates require reclaim of any reusable resources

process has one program counter specifying location of the next


instruction to be executed
− Process executed instruction sequentially, one at a time until
completion

26 / 31
Process Management Activities

The operating system is responsible for the following activities with


process management
Creating and deleting both user and system processes

suspending and resuming processes

providing mechanism for process synchronization

providing mechanism for process communication

providing mechanism for deadlock handling

27 / 31
Memory Management

To execute a program all (or part) of the instructions must be inside


memory

All (or part) of the data that are needed by the program must be in
memory

memory management determines what is in memory and when

memory management activities


− Keeping track of which part of memory are currently being used and by
whom
Deciding which processes and data are needed to move in and out of
memory
Allocating and Deallocating memory space as needed.

28 / 31
Storage Management

OS provides uniform, logical view of information storage


Abstracts physical properties to logical unit → file
Each medium is controlled by device (i.e. disk drive, tape drive etc.)
− Varying properties include access speed, capacity, data transfer rate etc.

File-System Management
Files usually are organized into directories
Access Control mechanism (permission of the user)

OS activities
Creating and deleting files and directories
Primitives to manipulate files and directories
mapping files onto secondary storage
backup files onto stable storage medium
29 / 31
I/O Management

One purpose of OS is to hide peculiarities of hardware devices from


the user
I/O subsystem is responsible for
− Memory management of I/O including buffering (storing data
temporarily while it is being transferred), caching (storing parts of data
to faster device for performance), spooling (the overlaping of output of
one job with the input of other job)

General device-driver interface

Drivers for specific hardware devices

30 / 31
Protection and Security

Protection - any mechanism for controlling access of processes or


users to resources defined by the OS

Security – defense of the system against internal and external


attacks

System generally first distinguish among users, to determine who can


do what
− User identities (user IDs, security IDs) include name and associated
number, one per user

− User ID then associated to files, processes of that user to determine


access control

31 / 31

You might also like