Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 65

BASICS OF

THE
OPERATING SYSTEMS

V SEM ETC
NIT RAIPUR
Shrish Verma
UNIT-I

INTRODUCTION: Operating System objective and function.


The Evolution of Operating Systems, Batch, interactive, time
– sharing and real time systems.
Protection.
Operating System Structure: System COMPONENTS,
operating system service, System structure.
Distributed Computing,
The Key Architecture Trend: Parallel Computation, Input-
Output Trends.
Function of OS
OS does what we must also learn to do
SHARING NICELY
 Control
 Optimize the Performance
 Manage the Resources

10-3
Operating System As Resource manager
A Resource Manager
Operating System is seen as a way of providing the users
of the computer with the resources they need at any
given time.
Some resource requests may not be able to be met
(memory, CPU usage etc.) but the operating system is
able to deal with scheduling problems such as these.
Other resources have a layer of abstraction placed
between them and the physical resource (e.g. a printer).
Hardware Resources of a Computer System
The Processor

The Main (Primary Memory) RAM/ROM

Secondary Memory (HDD/SDD/Removable


Drives)

The Input Output Devices


OS: Resource Management
File systems, monitor, keyboard, etc
The OS is in charge of making all the application
programs “share nicely”
Examples:
sending keystrokes to correct application
Placing overlapping windows on the screen
Making sure apps don’t access each others memory

10-6
Operating System Resource
Management (Sharing)
Process Management (Sharing the CPU)
Sharing IO devices
Main (Primary Memory) Management
(Shared among many programs)
Disk (Secondary Memory) Management (More
sharing)

10-7
Major OS’s
Unix
Windows
Linux
Mac OS
Embedded OS’s (Android, iOS)
Real-Time OS’s

10-8
Which is the BEST OS??
NONE are “best”

Consumer POV (Point of View)


Buy whatever turns you on
Professional POV
Cost, tasks, maintenance, support, legacy issues,
popularity (network effects), etc.

10-9
A Little History - Mainframes
Mainframes – from 1950

1. Earliest computers had no OS at all!


2. Proprietary (custom) OS’s
3. VMX
4. Early Unix versions
5. Unix was invented at AT&T Bell Labs

10-10
Mainframe
Circa 1950

10-11
Mainframe
IBM System 360 circa 1964

10-12
A Little History - Unix
 Mainframes were often shared by many users
 A multiuser OS was needed and Unix arose to fill
this need
 Ken Thompson wrote the first version in 1969
 Dennis Ritchie developed ‘C’ language in 1973
 The above two developed 5th Ed Unix in 1974 written in
‘C’ language
 IBM, Digital Equipment Corporation (DEC), Honeywell,
Hewlett Packard each had their own proprietary version
on Unix

10-13
A Brief Time-line of evolution of UNIX

4. 1

4. 2

4. 4
D

D
BS

BS

BS
V1

V4

V7
V3
I X
s

N 1981 1983 1993


lt ic

IX

IX

IX
IX
U
ic

D
UN

UN

UN
UN
Mu

Un

BS

II I

V
1965 1969 1970 1973 1974 1979

m
em
AT

e
&T

st
st

Sy
Sy
UN
I X
1982 1984

LINUX – 1991 BY LINUS TORVALDS


LINUS UNIX A free version on GNU (General Public Licence)

1998 – X/OPEN & IEEE started work to merge two standards


2001 – Single UNIX Specification Version 3 (SUSV3)
Also known as IEEE1003.1:2001
2002 – ISO standardized SUSV3 and IEEE1003.1:2001
A Little History – Early Personal Computers
Microcomputers based on the first integrated CPU
chips ~ late 1970’s
MITS Altair 8800 (MS’s big break)
Commodore 64
Atari ST
TRS 80
Apple 2 (Apple 1 was a kit)
Each machine had their own proprietary OS (or none
at all for the Altair!)

10-15
APC’s
Little History
and Macs – 1980’s
– PC’s n Macs
IBM PC
 IBM hired MS to supply DOS (A basic
command-line OS)
 MS bought DOS from another party

Apple Macintosh
 Apple wrote theie own GUI OS
 Apple borrowed the idea from Xerox PARC

10-16
A Little History – Windows OS
IBM PC needed a GUI
IBM hired MS to write OS2 for PS2 (not Playstation!)
MS wrote Windows at the same time
Guess who won?

Why did MS win?


 DOS was a “cash cow” for MS
 Windows had backward compatibility w DOS
 PC hardware was cheaper than Mac HW

10-17
Operating System Architecture/ Structure
MONOLITHIC ARCHITECTURE
 Operating system software to manage the resources of the system are
contained in a single package which is called the ‘KERNEL’.

 Operating system works in the KERNEL space, i.e., address space of


device drivers, process management, ipc, etc., is the same as that of
KERNEL.

USER MODE (OTHER FEATURES/COMPILERS/EDITOR, ETC.)

KERNEL MODE (IT HANDLES BASIC FEATURES ONLY)

FILE
PROCESS MEMORY DEVICE CONCURR
SYSTEM
MGMT MGMT MGMT ENCY IPC
MGMT

HARDWARE
Advantages of Monolithic Architecture

 Fast: Monolithic operating systems are fast. Thus, they provide


better process scheduling, memory management, File management,
etc.

 Direct Interaction between Components: All the components and the


kernel can directly interact.

 It also helps in gaining a better speed.

 Easy and Simple: Its structure is easy and simple as all the
components are in the same address space.

 Better for Smaller Tasks: Monolithic OS works better for handling


smaller tasks.

Source: https://www.codingninjas.com/studio/library/operating-system-architecture https://www.geeksforgeeks.org/


Disadvantages of Monolithic Architecture

 Prone to Errors: Monolithic OS can generate errors and bugs in the


system. It is because user programs use the same address space
as the kernel.

 Difficult to Update: In a monolithic OS, all the OS code is in a single


big chunk, therefore, it is difficult to add or remove features in the
OS.

 Not Portable: The code written in a monolithic OS is difficult to


carry with or transfer to another system: this is because all the
code works in a big chunk only, and you need to move it all.

Source: https://www.codingninjas.com/studio/library/operating-system-architecture https://www.geeksforgeeks.org/


OS: Interfaces

An operating system
interacts with different
aspects of a computer
system on one side and
with the user on the
other.

10-21
LAYERED ARCHITECTURE
 OS is modularized
giving rise to
abstraction of having
different ‘LAYERS’
 Better management of
services, better for
further development
of services/
components
 These layers are so
designed that each
layer uses the
functions of the lower-
level layers. This
simplifies the
debugging process Layered Abstraction of the UNIX Operating
System
for each layer.
Layered Abstraction of the Operating System

USER/S

APPLICATIONS, UTILITIES,
OFFICE, MATLAB, VIDEO PLAYERS, DBMS SYS, N/W, ETC.
OPERATING SYSTEM UTILITIES
TEXT EDITORS, COMPILERS, ETC.

Kernel / Resident OS

Basic Input Output System

HARDWARE
ADVANTAGES OF LAYERED OS

Modularity: This architecture promotes modularity because each layer only does its
assigned duties.

Easy debugging: It is relatively simple to debug because the layers are discrete. If a
mistake happens in the CPU scheduling layer, the developer can only debug that
layer, as opposed to a Monolithic system where all services are present at the same
time.

Easy update: A change made to one layer will have no effect on the other layers.
No direct access to hardware: The hardware layer is the design's innermost layer.
So, unlike the Simple system, where the user has direct access to the hardware, a
user can use hardware services but not directly modify or access it.

Abstraction: Every layer is focused on its own set of tasks. As a result, the other
layers’ functions and implementations are abstract.

Source: https://www.codingninjas.com/studio/library/operating-system-architecture
DISADVANTAGES OF LAYERED OS
Complex and careful implementation: Because a layer can use the services
of the levels below it, the layers must be carefully arranged. The memory
management layer, for example, is used by the backup storage layer. As a
result, it must be placed behind the memory management layer. As a result,
significant modularity leads to complicated implementation.

Slower in execution: When a layer wishes to communicate with another layer,


it sends a request that must travel through the layers between the two layers to
be fulfilled. As a result, unlike the Monolithic system, which is faster, it increases
response time. As an output, increasing the number of layers may result in an
inefficient design.

Source: https://www.codingninjas.com/studio/library/operating-system-architecture
MULTI-KERNEL ARCHITECTURE

 System calls/codes for File System Management, device


management are stored and executed in User Mode.

 The Kernel mode address space is limited to IPC, Virtual


Memory, Memory Management and process management.
ADVANTAGES OF MICROKERNEL OS

 Performance: Microkernel architecture is compact and isolated and


well protected hence it performs better.

 Security: Microkernels are safe since only those components are


provided that would not otherwise disturb the system’s functionality.

 Scalable: It is easily expandable as compared to a monolithic kernel.


Modularity: Microkernels are modular, and the various modules can be
swapped out, reloaded, and modified without affecting the Kernel.

Source: https://www.codingninjas.com/studio/library/operating-system-architecture https://www.geeksforgeeks.org/


DISADVANTAGES OF MICROKERNEL OS

 Performance overhead: Performance overhead arises due to the


need for inter-process communication between kernel modules.
A context switch or a function call is required when the drivers
are implemented as procedures or processes.

 Limited hardware support: The microkernel architecture can be


more difficult to port to new hardware platforms.
HYBRID ARCHITECTURE OF OS

NONE OF THE PRESENT DAY OS IS STRICTLY FOLLOWING A


SINGLE ARCHITECTURE. THESE TEND TO BE HYBRID AT TIMES.

LINUX IS MONOLITHIC AS HAVING SERVICE IN KERNEL ADDRESS


SPACE GIVES BETTER PERFORMANCE BUT IT IS MODULAR TO AS
IT ALLOWS NEW FUNCTIONALITY TO BE ADDED DYNAMICALLY.
Batch system

Source: Modern Operating Systems – A. S. Tenenbaum & H. Bos (Fourth ed.)


Batch Processing
1. Write a Program In FORTRAN ON PAPER

2. Transfer the written program to PUNCH CARD, PUNCHING the holes at


right row x column. A PUNCHED PROGRAM  ‘JOB’

3. SUBMIT CARD DECK  OPERATOR  GO DO SOMETHING  …….

4. OPERATOR  READ THE JOB ON TAPE SPOOL  PUT SPOOL ON CPU


 B.O.S. RUNS THE PROGRAM  OUTPUT TO SPOOL PRINTER
CARD DEC FOR A JOB
Batch Operating System
JOB CONTROL LANGUAGE

CONTROL CARDS

$JOB: SPECIFIES PARAMETERS, MAX. TIME, NAME, ETC.

$FORTRAN: OS LOADS FORTRAN COMPILER FROM THE SPOOL


AND COMPILE THE PROGRAM

$LOAD: COMPILED OBJECT CODE IS LOADED BY THE OS

$RUN: OS RUNS THE OBJECT CODE OF THE JOB

$END: OS UNDERSTANDS THE END OF A JOB

EXAMPLE OF BATCH OS: FMS (FORTRAN MONITOR SYSTEM,


IBSYS: IBM’S OS FOR 7049 COMPUTER
Interactive Systems (OS)
Instant Response from the Computer
system.
Multiple Input devices for interaction

Mouse
Keyboard
Microphone
camera
Joystick
Pen

Text on VDU
Graphics on VDU
Video on VDU and LS
Music/audio/voice on LS
Text/graphics/photos on Printer
Interactive Systems (OS)
In interactive systems the user and computer exchange information frequently and
dynamically. Norman’s evaluation/execution model is a useful way of
understanding the nature of interaction:
1. User has a goal (something to achieve)

2. User looks at system and attempts to work out how he would execute a series of
tasks to achieve the goal.

3. User carries out some actions (providing input to the system by pressing buttons,
touching a screen, speaking words etc)

4. System responds to the actions and presents results to the user. System can use
text, graphics, sounds, speech etc.

5. User looks at the results of his action and attempts to evaluate whether or not
the goals have been achieved.
A good interactive system is one where:
 User can easily work out how to operate the system in an attempt to achieve his
goals.

 User can easily evaluate the results of his action on the system.
Time Sharing Systems Ex. Mainframe
shared Dot Tele Typewriter
Matrix Printer Dumb Terminal

Tele Typewriter
Tele Typewriter Dumb Terminal
Dumb Terminal Central
Processing
Unit including
Memory,
Storage, etc.
Time sharing Systems
Time-sharing OS provides the following features for users:
 Each user grabs dedicated time for all operations.
 Multiple active users can use the same computer at the same
time.
 End-users feel that they monopolize the computer system.
 Better interaction between users and computers.
 Each user’s job is run in a circular queue hence the Response
time is small for each one
 It can make quick processing with a lot of tasks.
Source: https://www.codingninjas.com/studio/library/operating-system-architecture
Time Sharing Systems
Advantages of Time-Sharing OS

The time-sharing operating system has the following advantages:


 It provides a quick response
 Reduces CPU idle time
 All the tasks are given a specific time in a circular manner
 Facilities better sharing of software used
 Saves memory by code sharing
 Improves response time
 Easy to use and user friendly
Source: https://www.codingninjas.com/studio/library/operating-system-architecture
Time Sharing Systems
Disadvantages of Time-Sharing OS
 It tends to consume many resources
 Requires high specification of hardware
 It has a problem of reliability
 Complicated security and integrity of user programs and
data
 Complicated Inter-process communication

Source: https://www.codingninjas.com/studio/library/operating-system-architecture
Time Sharing Systems
MULTIPROGRAMMING
(MULTIPLE PROCESSES SCENARIO)

WHEN PROCESS A IS BUSY IN IO, PROCESS B IS PERFORMING ITS CPU BURST


& VICE VERSA (IDEAL CASE)
AS A RESULT BOTH CPU & IO ARE BUSY

SYSTEM EFFICIENCY IS OPTIMUM

SHARING OF RESOURCES IS VERY IMPORTANT AND


CRITICAL
Time Sharing Systems
Multiprogramming System Time-Sharing System
The processor and memory The processor's time is shared with multiple
underutilization problem is resolved, and users. That's why it is called a time-sharing
multiple programs run on the CPU. That's operating system.
why it is called multiprogramming.

In multiprogramming, the process can be In this process, two or more users can use a
executed by a single processor. processor in their terminal.

Multiprogramming OS has no fixed time Time-sharing OS has a fixed time slice.


slice.
In a multiprogramming OS system, before In a time-sharing OS system, executive
finishing a task, the executive power is not power is taken off before finishing
taken off. execution.

The system model of a multiprogramming A system model of the time-sharing system


system is multiple programs. is multiple programs and multiple users.

Multiprogramming system maximizes The Time-sharing system maximizes


response time. response time.

Example: Mac OS, Window OS, Example: Windows NT server, Unix, Linux,
Real-Time Operating System - RTOS
The basic hardware for RTOS is the microcontroller and RTOS
is always specific to an embedded system used on an
appliance/machine

INTERRUPT
CONTROL FLASH RAM TIMER
CLOCK
CKT

PROCESSOR

POWER BUS IO PORTS


CONTROL (Can be multiple)
CKT
A typical Embedded System
Comm.
INTERRUP
T
devices
FLASH RAM TIMER
CONTROL

Sensors
Conditioning
CLOCK CKT

PROCE

Signal
Ckt
SSOR

Actuato
BUS
POWE IO PORTS

r
CONTR
OL (Can be multiple)
R CKT

Sensors

Signal Analog to
Conditioning Digital Con. B

RTOS
Input Port
S
Actuators Signal Digital to Output Port P
Conditioning Analog Con.
Real – Time Operating System (RTOS)

 RTOS is very different from a general-purpose OS.

 RTOS is much smaller and runs of tight power and time constraint.

 It uses a strict priority-based scheduling for process as well as resources to


meet the tight power and time deadlines.

 It has a microkernel-based architecture.

 The hardware which is to be controlled by RTOS are Microcontrollers


(which are basically worked through BSP – ‘Board support Package’),,
Flash and RAMs, IO devices (Sensors, actuators, communication devices,
signal processing ckts), etc.
Real – Time Operating System (RTOS)
Structure/ Architecture

Applications Applications
n/w

schedulers
File System
protocol
RTOS

Facility
Debug
KERNEL Kernel
BSP Device
IO
Board Support Program Time Device
mgmt
Mgmt Drivers

BSP
Target Hardware Target Hardware
Distributed System
Internet
Client – Server System
Tightly Couples systems

 Kernel/Multi-kernel Architecture
 Homogeneity is required: Same type of the software on server
as well as clients.
 Clients only interact with/through the server.
 If the server fails all the services are stopped. Reliability issues
Peer-to-peer (P2P) System
Loosely Couples systems

 Equal load distribution among the nodes


 Node-to-node interaction can take place. Nodes act as both client and
server.
 Better reliability than the Client-server arch, difficult to dismantle
 Example: Bitcoin, Ethereum (Crypto currency), BitTorrent, Tor
Three tier and N-Tier systems

Most commonly used in present day online


gaming and e-commerce applications
Features of the Distributed systems

 Openness

 Scalability

 Heterogeneity

 Reliability

 Resource Sharing

 Flexibility
OS for Mobile Devices Mac OS X

 MAC OS X is a hybrid OS having a layered system.


 AQUA Graphical User Interface and Application environment and
services.
 Cocoa environment specifies API provides objective –C programming
for the OS
 Kernel environment comprises of MACH Microkernel and BSD Unix
kernel
 MACH provides memory management, Remote Procedure Call (RPC)
and IPC
 BSD the command line interface and support for File System
OS for Mobile Devices iOS
 iOS is the Mobile OS for Apple iPhone
and iPad.
 iOS is structured on MAC OS X but
does not directly run it.
 Cocoa Touch is the environment which
provides for developing Applications
for iOS for hardware like touch screen.
 Media Services provides for services
catering to audio, video and graphics.
 Core Services provides functionalities
for networking, cloud computing and
database etc,
 Core OS is the Kernel environment of
MAC OS X.
OS for Mobile Devices ANDROID
 Developed by Open Handset
Alliance (led by Google).
 Android smartphones and
tablets
 Hybrid OS, Layered Architecture
 Linux kernel provides
processor, memory and device-
driver support.
 It is expanded for power
management
 Java byte code is converted
to ,dex file which runs on Dalvik
Virtual Machine.
 Dalvik Virtual Machine optimizes
the memory use hence better for
mobile devices.
Layered Abstraction of the UNIX Operating
System
bash:-Bash is a Unix shell and
command language written by Brian
Fox for the GNU Project as a free
software replacement for the Bourne
shell.
csh:-The C shell (csh) is a command
shell. Csh can be used for entering
commands interactively or in shell
scripts.
cut:-The cut command in UNIX is a
command for cutting out the sections
from each line of files and writing the
result to standard output.
vi:-
shell:-
cmp:-
more:-
ps:-"process status" displays the
currently-running processes.
Layered Abstraction of the WINDOWS –NT
Operating System
UNIX (LINUX) SYSTEMs
Operating System Concepts - 1

System Calls
Each system call has a procedure associated with it so
that system calls can be done in a familiar way.
The procedures places the parameters into registers
and informs the operating system
OS is informed via a TRAP instruction (sometimes
known as a kernel call or a supervisor call).
Operating System Concepts - 2

CPU switches from user mode to kernel (or


supervisor) mode
After carrying out the work the operating system will
return a result in the same way as a user written
function written in a high-level language.
Example of an operating system call (via a procedure)
is
count = read(file, buffer, nbytes);
Use system calls to manipulate objects
Booting Flow in UNIX
Booting Flow in windows
File System in Unix

You might also like