[go: up one dir, main page]

0% found this document useful (0 votes)
181 views126 pages

OS UNIT-1 Introduction

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

OS UNIT-1 Introduction

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

U20CBT406

OPERATING SYSTEMS

L C HRS
3 3 45
Course Objectives
To grasp a fundamental understanding of operating systems
and processes
To learn the concepts of CPU scheduling and Inter-Process
Communication
To learn the concepts of Deadlock and Concurrent
Programming
To understand memory management concepts in OS
To understand the concepts of I/O, file and disk management
To learn the features of UNIX operating systems
Course Outcomes
CO1 - Define the concepts of operating systems operations,
processes, and threads. (K2)
CO2 - Apply the concepts of CPU scheduling and Inter-Process
Communication (K3)
CO3 - Describe the concepts of Deadlock and Concurrent
Programming. (K2)
CO4 - Simulate the principles of memory management (K3)
CO5 - Identify appropriate I/O, file system, and disk
organizations for a variety of computing scenarios (K2)
Syllabus
UNIT I INTRODUCTION AND PROCESS MANAGEMENT (9
Hrs)
Introduction: Concept of Operating Systems - Generations of OS- Types
of OS-OS Services- Interrupt handling and System Calls-Basic
architectural concepts of an OS - Concept of Virtual Machine- Resource
Manager view- process view and hierarchical view of an OS.
Processes: Definition-Process Relationship- Different states of Process-
Process State transitions- Process Control Block (PCB) - Context
switching.
Thread: Definition- Various states- Benefits of threads- Types of
threads- Concept of multithreads.
UNIT II CPU SCHEDULINGAND INTER PROCESS
COMMUNICATION (9 Hrs)
Process Scheduling: Foundation and Scheduling objectives - Types of
Schedulers- Scheduling criteria. Scheduling algorithms: Pre-emptive and non-
pre-emptive- FCFS- SJF- RR-Multiprocessor scheduling- Real Time
scheduling.
Inter-process Communication: Concurrent processes, precedence graphs,
Critical Section, Race Conditions, Mutual Exclusion, Hardware Solution,
Semaphores, Strict Alternation, Peterson’s Solution, The Producer / Consumer
Problem, Event Counters, Monitors, Message Passing, Classical IPC Problems:
Reader’s & Writer Problem, Dinning Philosopher Problem, Barber’s shop
problem.
UNIT III DEAD LOCK AND I/O (9 Hrs)
Deadlocks: Definition - Necessary and sufficient conditions for
Deadlock - Deadlock Prevention, Deadlock Avoidance: Banker’s
algorithm - Deadlock detection and Recovery.
Concurrent Programming: Critical region, conditional critical
region, monitors, concurrent languages, communicating sequential
process (CSP)
UNIT IV MEMORY MANAGEMENT (9 Hrs)
Memory Management: Basic concept - Logical and Physical address
maps - Memory allocation: Contiguous Memory allocation – Fixed
and variable partition– Internal and External fragmentation and
Compaction.
Virtual Memory: Basics of Virtual Memory – Hardware and
control structures – Locality of reference- Page allocation-
Partitioning, Paging- Page fault-Working Set-Segmentation-
Demand paging- Page Replacement algorithms: Optimal, FIFO –
SC –NRU-LRU.
UNIT V I/O AND FILE MANAGEMENT (9 Hrs)
I/O Hardware: I/O devices- Device controllers-Direct Memory
Access- Principles of I/O
File Management: Concept of File- Access methods- File types-
File operation- Directory structure-File System structure-
Allocation methods -Free-space management - directory
implementation- efficiency and performance.
Disk Management: Disk structure- Disk scheduling – FCFS-
SSTF- SCAN- C-SCAN- Disk reliability, Disk formatting, Boot-
block, Bad blocks.
Case study: UNIX OS file system
Text Books
1. Abraham Silberschatz, Peter Baer Galvin and Greg
Gagne, “Operating System Concepts”, John Wiley & Sons
(Asia) Pvt. Ltd, Ninth Edition,2017.
2. Gary Nutt, “Operating Systems- A Modern Perspective”,
Pearson Education Pvt. Ltd, Second Edition, 2013.
3. Andrew S. Tanenbaum, “Modern Operating Systems”, 3rd
edition Prentice Hall of India Pvt. Ltd,2015.
Reference Books
1. William Stallings, “Operating System”, Prentice Hall of
India, 6th Edition, 2009
2. Charles Patrick Crowley, “Operating System: A Design-
oriented Approach”Tata McGraw - Hill Edition 1998 21st
reprint,2009 .
3. Maurice J. Bach , “Design of the Unix Operating
Systems”Prentice-Hall2 nd edition ,1986
4. Daniel Pierre Bovet, Marco Cesati , “Understanding the
Linux Kernel”O'Reilly Media, Incorporated publications,2
nd edition ,2005
Web References
1. https://nptel.ac.in/courses/106108101/
2. http://www.tcyonline.com/tests/operating-system-
concepts
3. http://www.galvin.info/history-of-operating-system-
concepts-textbook
4. http://www.ittestpapers.com/operating-system-
concepts
UNIT I
INTRODUCTION AND
PROCESS MANAGEMENT
INTRODUCTION
Concept of Operating Systems
Generations of OS
Types of OS
OS Services
Interrupt handling and System Calls
Basic architectural concepts of an OS
Concept of Virtual Machine
Resource Manager view
Process view and hierarchical view of an OS
1. Concept of Operating
Systems
What is an Operating
System?
A program(system software) that acts as an
intermediatory(interface) between a user of a
computer and the computer hardware
Operating system goals:
◦ Execute user programs and make solving user
problems easier
◦ Make the computer system convenient to use
◦ Use the computer hardware in an efficient manner
Computer System Structure
Computer system can be divided into four components(layers):
Hardware
◦ Provides the basic computing resources such as CPU, memory, I/O
devices
Operating system
◦ Controls and coordinates the use of the hardware among various
applications and users
Application programs
◦ Defines 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, etc.,
Users
◦ People, machines, other computers
Four Components of a Computer System
Operating System Mode

USER MODE – interface between


the user and the system
Controls running applications and
file accessing
KERNEL MODE – everything
running in the background that
controls resource accessing,
hardware functions and processing
program instructions.
System calls are used to change
mode from User to Kernel.
Resource Manager view, Process view
and hierarchical view of an OS
•The operating system controls the hardware and coordinates
its use among the various application programs for the various
users.
•3 views of operating system are
•1. Resource manager view
•2. Process view
•3. Hierarchical view
•OS provides environment within which other programs can do
useful work
User view
Varies according to the interface being used
1. Single user computers – the maximum amount of work can
be done, easy to use with good performance
2. Multi-user computers – share resources – maximize
resource utilization to assure that all available CPU time,
memory and I/O are used efficiently
3. Handheld computers – touch screens, resource poor
smartphones and tablets, optimized for usability and battery life
4. Embedded computers home devices and automobiles, run
without user intervention
System View
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
Operating System Definition (Cont)
No universally accepted definition
“Everything a vendor ships when you order an operating
system” is good approximation
◦ But varies wildly
“The one program running at all times on the computer”
is the kernel. Everything else is either a system program
(ships with the operating system) or an application
program
Kernel is first part of OS to load in the protected area of
main memory to prevent the data.
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
◦ Loads operating system kernel and starts
execution
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 devices 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
Common Functions of Interrupts
Interrupt transfers control to the interrupt service routine
generally, through the interrupt vector, which contains the
addresses of all the service routines
Interrupt architecture must save the address of the interrupted
instruction
Incoming interrupts are disabled while another interrupt is being
processed to prevent a lost interrupt
A trap is a software-generated interrupt caused either by an error
or a user request
An operating system is interrupt driven
5. Interrupts
Types:
Hardware – trigger an interrupt by sending signal
to the CPU
Software - trigger an interrupt by executing a
special operation called a system call
Interrupt driven I/O cycle
5. Interrupt Handling
The operating system preserves the state of the
CPU by storing registers and the program counter
Determines which type of interrupt has occurred:
◦ polling
◦ vectored interrupt system
Separate segments of code determine what action
should be taken for each type of interrupt
Polled interrupt vs Vectored interrupt
Polled interrupt is an inefficient method of data transfer,
spending much time checking the ready condition of a
computer's devices.
vectored interrupt, send a signal that includes the identity
of the device.
All input/output in modern computers is done by interrupt-
driven I/Os, which interrupt the process when they are
ready to transfer data.
The processor will perform other tasks while waiting for
an interrupt.
Interrupt Timeline
I/O Structure
After I/O starts, control returns to user program only upon I/O completion
◦ Wait instruction idles the CPU until the next interrupt
◦ Wait loop (contention for memory access)
◦ At most one I/O request is outstanding at a time, no simultaneous I/O processing

After I/O starts, control returns to user program without waiting for I/O
completion
◦ System call – request to the operating system to allow user to wait for I/O completion
◦ Device-status table contains entry for each I/O device indicating its type, address, and
state
◦ Operating system indexes into I/O device table to determine device status and to
modify table entry to include interrupt
Direct Memory Access Structure
Used for high-speed I/O devices able to
transmit information at close to memory
speeds
Device controller transfers blocks of data
from buffer storage directly to main memory
without CPU intervention
Only one interrupt is generated per block,
rather than the one interrupt per byte
Storage Structure
Main memory – only large storage media that the CPU
can access directly
Secondary storage – extension of main memory that
provides large nonvolatile storage capacity
Magnetic disks – 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
Storage Hierarchy
Storage systems organized in hierarchy
◦ Speed
◦ Cost
◦ Volatility
Caching – copying information into faster
storage system; main memory can be viewed as
a last cache for secondary storage
Storage-Device
Hierarchy
Caching
Important principle, performed at many levels in a computer (in
hardware, operating system, 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 used directly from the cache (fast)
If not, data copied to cache and used there

Cache smaller than storage being cached


Cache management important design problem
Cache size and replacement policy
2. Generations of OS
Generations of OS
The First Generation (1945's to early 1955's)
No Operating System
Substitutes for mechanical computing systems
All programming was done in absolute machine
language, often by wiring up plug-boards to control
the machine’s basic functions.
Example − Type of operating system and devices
used is Plug Boards.
Generations of OS
The Second Generation (1955-1965)
The Batch processing system was introduced in the second
generation, where a job or a task that can be done in a series, and then
executed sequentially.
In this generation, the computer system is not equipped with an
operating system, but several operating system functions exist like
FMS and IBSYS.
Example − Type of operating system and devices used is Batch
systems.
First operating system was introduced in the early 1950's.It was called
GMOS
Created by General Motors for IBM's machine the 701.
Single-stream batch processing systems, It only executed one job at
a time, and data was sent in batches or groups
Generations of OS
The Third Generation (1965-1980)
Introduction of multiprogramming, serve multiple users at
once through an online terminal to a computer.
Development of Minicomputer
The Fourth Generation (1980-Present Day)
Development of PCs, computers are connected to one
another
Graphical User Interface (GUI), distributed computing
wearable devices - Smart Watches, Smart Glasses,
VRGears, and others
Birth of Windows/MaC OS
3. Types of OS
Types of Operating Systems
1. Batch Operating System
2. Multiprogramming Operating System
3. Time-Sharing OS
4. Multiprocessing OS
5. Distributed OS
6. Network OS
7. Real Time OS
8. Embedded OS
1. Batch Operating System
The users of this type of operating system does 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
There is an operator which takes similar jobs having the same
requirement and groups them into batches.
1. Batch Operating System cont..

Advantages of Batch Operating System:


 Processors of the batch systems know how long the job would be when it is
in queue
 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 sometimes costly
 The other jobs will have to wait for an unknown time if any job fails

Examples of Batch based Operating System:


IBM's MVS
2. Multiprogramming Operating System:
This type of OS is used to execute more than one job
simultaneously by a single processor.
 It increases CPU utilization by organizing jobs so that the CPU
always has one job to execute.
Multiprogramming operating systems use the mechanism of job
scheduling and CPU scheduling.
3. Time-Sharing Operating Systems
Each task is given some time to execute so that all the tasks work
smoothly.
These systems are also known as Multi-tasking Systems.
The task can be from a single user or different users also.
 The time that each task gets to execute is called quantum.
 After this time interval is over OS switches over to the next task.
3. Time-Sharing Operating Systems cont..

Advantages of Time-Sharing OS:


Each task gets an equal opportunity
Fewer chances of duplication of software
CPU idle time can be reduced
Disadvantages of Time-Sharing OS:
Reliability problem
One must have to take care of the security and integrity of
user programs and data
Data communication problem
Examples of Time-Sharing Oss
Multics (Multiplexed Information and Computing Service),
Unix, etc.
4. Multiprocessor operating systems
Multiprocessor operating systems are also known as parallel OS or tightly
coupled OS.
Such operating systems have more than one processor in close
communication that shares the computer bus, the clock, and sometimes
memory and peripheral devices.
It executes multiple jobs at the same time and makes the processing faster.
It supports large physical address space and larger virtual address space.
If one processor fails then other processors should retrieve the interrupted
process state so the execution of the process can continue.
 Inter-processes communication mechanism is provided and implemented in
hardware.
5. Distributed Operating System
Various autonomous interconnected computers communicate with each other
using a shared communication network.
 Independent systems possess their own memory unit and CPU.
These are referred to as loosely coupled systems.
Examples:- Locus, DYSEAC
6. Network Operating System
These systems run on a server and provide the capability
to manage data, users, groups, security, applications, and
other networking functions.
 These types of operating systems allow shared access of
files, printers, security, applications, and other networking
functions over a small private network.
The “ other" computers arc called client computers, and
each computer that connects to a network server must be
running client software designed to request a specific
service.
popularly known as tightly coupled systems.
6. Network Operating System
Advantages of Network Operating System:
 Highly stable centralized servers
 Security concerns are handled through servers
 New technologies and hardware up-gradation are easily
integrated into the system
 Server access is possible remotely from different locations
and types of systems
6. Network Operating System
Disadvantages of Network Operating System:
 Servers are costly
 User has to depend on a central location for most
operations
 Maintenance and updates are required regularly
Examples of Network Operating System are:
Microsoft Windows Server 2003/2008/2012, UNIX,
Linux, Mac OS X, Novell NetWare, and BSD, etc.
7. 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.
8. Embedded Operating System
An embedded operating system is one that is built into the circuitry of an
electronic device.
Embedded operating systems are now found in automobiles, bar-code
scanners, cell phones, medical equipment, and personal digital
assistants.
The most popular embedded operating systems for consumer products,
such as PDAs, include the following:
 Windows XP Embedded
 Windows CE .NET:- it supports wireless communications, multimedia
and Web browsing. It also allows for the use of smaller versions of
Microsoft Word, Excel, and Outlook.
 Palm OS:- It is the standard operating system for Palm-brand PDAs
as well as other proprietary handheld devices.
 Symbian:- OS found in “ smart” cell phones from Nokia and Sony
Ericsson
Popular types of OS
Desktop Class
Windows
OS X
Unix/Linux
Chrome OS

Server Class
Windows Server
Mac OS X Server
Unix/Linux

Mobile Class
Android
iOS
Windows Phone
4. OS Services
Operating System Services
A View of Operating System Services
Process Management
A process is a program in execution. It is a unit of work
within the system.
Program is a passive entity,
Process is an active entity.
Process needs resources to accomplish its task
◦ CPU, memory, I/O, files
◦ Initialization data
Process Management
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying
location of next instruction to execute
◦ Process executes instructions sequentially, one at a time, until
completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating
system running concurrently on one or more CPUs
◦ Concurrency by multiplexing the CPUs among the processes /
threads
Process Management Activities
The operating system is responsible for the following
activities in connection with process management:
•Creating and deleting both user and system processes
•Suspending and resuming processes
•Providing mechanisms for process synchronization
•Providing mechanisms for process communication
•Providing mechanisms for deadlock handling
Memory Management
All data in memory before and after processing
All instructions in memory in order to execute
Memory management determines what is in memory when
Optimizing CPU utilization and computer response to users
Memory management activities
Keeping track of which parts of memory are currently being used
and by whom
Deciding which processes (or parts thereof) and data to move into
and out of memory
Allocating and deallocating memory space as needed
Storage Management
OS provides uniform, logical view of information
storage
◦ Abstracts physical properties to logical storage
unit - file
◦ Each medium is controlled by device (i.e., disk
drive, tape drive)
◦ Varying properties include access speed,
capacity, data-transfer rate, access method
(sequential or random)
File management
◦ Files usually organized into directories
◦ Access control on most systems to determine
who can access what
◦ File management activities include
◦ Creating and deleting files and directories
◦ Primitives to manipulate files and directories
◦ Mapping files onto secondary storage
◦ Backup files onto stable (non-volatile) storage
media
Device Management or
I/O Management
Device controllers are components on the
motherboard (or on expansion cards) that act
as an interface between the CPU and the
actual device.
Device drivers, which are the operating
system software components that interact
with the devices controllers.
Device Management or
I/O Management
A special device (inside CPU) called the
Interrupt Controller handles the task of
receiving interrupt requests and prioritizes
them to be forwarded to the processor.
Deadlocks can occur when two (or more)
processes have control of different I/O resources
that are needed by the other processes, and they
are unwilling to give up control of the device.
Device management activities
Keeps tracks of all devices connected to system.
Designates a program responsible for every device
known as Input/output controller.
Decides which process gets access to a certain
device and for how long.
Allocates devices in an effective and efficient way.
Deallocates devices when they are no longer
required.
Mass-Storage Management
Usually disks used to store data that does
not fit in main memory or data that must be
kept for a “long” period of time
Proper management is of central
importance
Entire speed of computer operation hinges
on disk subsystem and its algorithms
Mass-Storage Management
OS activities
Free-space management
Storage allocation
Disk scheduling
Some storage need not be fast
Tertiary storage includes optical storage, magnetic tape
Still must be managed
Varies between WORM (write-once, read-many-times)
and RW (read-write)
Performance of Various Levels of Storage

Movement between levels of storage hierarchy can be explicit or


implicit
Migration of data from Disk to Register

Multitasking environments must be careful to use the most


recent value, no matter where it is stored in the storage hierarchy

Multiprocessor environment must provide cache coherency in


hardware such that all CPUs have the most recent value in their
cache
Distributed environment situation even more complex
Several copies of a datum can exist
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
◦ Huge range, including denial-of-service, worms, viruses, identity theft, theft of
service
Systems 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 with all files, processes of that user to determine access
control
◦ Group identifier (group ID) allows set of users to be defined and controls
managed, then also associated with each process, file
◦ Privilege escalation allows user to change to effective ID with more rights
User Interface Mechanism
A user interface (UI) controls how you enter
data and instructions and how information is
displayed on the screen
There are two types of user interfaces
1. Command Line Interface
2. Graphical user Interface
Command-line interface
The user types commands represented by short keywords or
abbreviations or presses special keys on the keyboard to enter
data and instructions
Graphical User Interface
With a graphical user interface (GUI), you interact with menus and
visual images
Desktop Class Operating
Systems:-
Platform: the hardware required to run a particular operating
system
◦ Intel platform (IBM-compatible)
◦ Windows
◦ DOS
◦ UNIX
◦ Linux
◦ Macintosh platform
◦ Mac OS
◦ iPad and iPhone platform
◦ iOS
Ms-DOS
Single User Single Tasking OS.
It had no built-in support for networking, and users had to
manually install drivers any time they added a new hardware
component to their PC.
DOS supports only 16-bit programs.
Command line user interface.
So, why is DOS still in use? Two reasons are its size and
simplicity. It does not require much memory or storage space for
the system, and it docs not require a powerful computer.
Microsoft Windows
The graphical Microsoft operating system designed for Intel-
platform desktop and notebook computers.
Best known, greatest selection of applications available.
Current editions include Windows 7, 8, 8.1 and 10.
Mac OS
User-friendly, runs on Mac hardware. Many applications available.
Current editions include: Sierra, High Sierra, Mojave, Catalina & Big Sur
—Version XI(Released in Nov 2020)
Linux
Linux: An open-source, cross-platform operating system that runs
on desktops, notebooks, tablets, and smartphones.
◦ The name Linux is a combination Linus (the first name of the first
developer) and UNIX (another operating system.

Users are free to modify the code, improve it, and redistribute it,
Developers are not allowed to charge money for the Linux kernel
itself (the main part of the operating system), but they can charge
money for distributions (distros for short).
Google Chrome OS
Chrome OS. Is a popular thin client operating system.
Thin client A computer with minimal hardware, designed for a
specific task. For example, a thin web client is designed for using
the Internet.
Server Operating Systems
Windows Server
◦ Familiar GUI interface for those experienced with Windows

UNIX
◦ Very mature server capabilities, time-tested, large user community,
stable

Linux
◦ Free, customizable, many free services and utilities available
Windows Server
UNIX
Tablet and Phone Operating
Systems
System-on-chip (SoC): An operating system that comes preinstalled
on a chip on a portable device such as a smartphone.
Popular SoC operating systems:
 iOS: for iPad, iPhone
 Android: for a variety of tablets and phones

Downloadable applications (apps) from an App store, for example:


 Apple App Store
 Google Play Store
iOS on the iPhone and iPad
The Apple-created operating system for Apple tablets and phones.
The current stable version, iOS 14, was released to the public on
September 16, 2020.
Android
Android, a popular OS for smartphones and tablets, is based on
Linux Kernel.
◦ Developed by Google

Current versions include:


◦ Android 8 Oreo
◦ Android 9 Pie
◦ Android 10
◦ Android 11 (released on Sep, 2020)
5. System Calls
System Calls
System call is the programmatic way in which a computer
program/user application requests a service from the kernel
of the operating system on which it is executed.
Application program is just a user process. Due to security
reasons, user applications are not given access to privileged
resources(the ones controlled by OS).
When they need to do any I/O or have some more memory
or spawn a process or wait for a signal/interrupt, it
requests the operating system to facilitate all these. This
request is made through System Call.
System calls are also called software interrupts.
System Calls
•Programming interface to the services provided by the
OS
•Typically written in a high-level language (C or C++)
•Mostly accessed by programs via a high-level
Application Program Interface (API) rather than direct
system call use
•Three most common APIs are Win32 API for Windows,
POSIX API for POSIX-based systems (including
virtually all versions of UNIX, Linux, and Mac OS X),
and Java API for the Java virtual machine (JVM)
Example of System Calls
System call sequence to copy the contents of one file to another
file
Example of Standard API
Consider the ReadFile() function in the
Win32 API—a function for reading from a file

A description of the parameters passed to ReadFile()


◦ HANDLE file—the file to be read
◦ LPVOID buffer—a buffer where the data will be read into and written from
◦ DWORD bytesToRead—the number of bytes to be read into the buffer
◦ LPDWORD bytesRead—the number of bytes read during the last read
◦ LPOVERLAPPED ovl—indicates if overlapped I/O is being used
System Call Implementation
Typically, a number 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 and any return
values
The caller need 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
◦ Managed by run-time support library (set of functions built into libraries included with
compiler)
API – System Call – OS Relationship
Standard C Library Example
C program invoking printf() library call, which calls write() system
call
System Call Parameter Passing
more information is required than simply identity of desired
system call
◦ Exact type and amount of information vary according to OS and call

Three general methods used to pass parameters to the OS


◦ Simplest: pass the parameters in registers
◦ In some cases, may be more parameters than registers
◦ Parameters stored in a block, or table, in memory, and address of
block passed as a parameter in a register
◦ This approach taken by Linux and Solaris
◦ Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system
◦ Block and stack methods do not limit the number or length of
parameters being passed
Parameter Passing via Table
Types of System Calls
Process control
File management
Device management
Information maintenance
Communications
Protection
Examples of Windows and Unix System Calls
MS-DOS execution

(a) At system startup (b) running a


program
FreeBSD Running Multiple Programs
System Programs
System programs provide a convenient environment for
program development and execution. The can be divided
into:
◦ File manipulation
◦ Status information
◦ File modification
◦ Programming language support
◦ Program loading and execution
◦ Communications
◦ Application programs

Most users’ view of the operation system is defined by


system programs, not the actual system calls
System Programs
Provide a convenient environment for program development and execution
◦ Some of them are simply user interfaces to system calls; others are
considerably more complex
File management - Create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories
Status information
◦ Some ask the system for info - date, time, amount of available
memory, disk space, number of users
◦ Others provide detailed performance, logging, and debugging
information
◦ Typically, these programs format and print the output to the terminal or
other output devices
◦ Some systems implement a registry - used to store and retrieve
configuration information
System Programs (cont’d)
File modification
◦ Text editors to create and modify files
◦ Special commands to search contents of files or perform transformations of the text

Programming-language support - Compilers, assemblers, debuggers


and interpreters sometimes provided
Program loading and execution- Absolute loaders, relocatable loaders,
linkage editors, and overlay-loaders, debugging systems for higher-
level and machine language
Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems
◦ Allow users to send messages to one another’s screens, browse web pages, send
electronic-mail messages, log in remotely, transfer files from one machine to
another
6. Basic architectural concepts of an OS
Architecture of OS
1. Monolithic OS
2. Layered OS
3. Microkernal OS
4. Networked and Distributed OS
1. Monolithic OS
Entire OS is working in kernel space in supervisor mode
Functional calls were used to communicate with other components
Unrestricted access to the computer system.
Example – OS/360, VMS, Linux
MS-DOS Layer Structure
UNIX

UNIX – limited by hardware functionality,


the original UNIX operating system had
limited structuring. The UNIX OS
consists of two separable parts
◦ Systems programs
◦ 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
Monolithic System
Architecture
2. Layered OS
•Groups components that performs similar
functions into layers
•Communicates layers above and below it
•Lower level layers provides services to higher
level ones
•Example – Windows XP, Linux
Layered Operating System
2. Layered OS
Monolithic Vs layered OS
Features Monolithic Layered Operating
System

Definition It is one in which the A layered operating


complete operating system that has divided
system operates in the into multiple layers,
kernel space. and each layer serves
as a specific task.

Number of levels There are mainly three There are multiple


layers in the monolithic layers in layered
operating system. operating systems.
Microkernel System Structure
Moves as much from the kernel into “user” space
Communication takes place between user modules using
message passing
Benefits:
 Easier to extend a microkernel
 Easier to port the operating system to new architectures
 More reliable (less code is running in kernel mode)
 More secure
Detriments:
 Performance
overhead of user space to kernel space
communication
Mac OS X Structure
Microkernel Vs Monolithic kernel
Modules
Most modern operating systems implement
kernel modules
Uses object-oriented approach
Each core component is separate
Each talks to the others over known
interfaces
Each is loadable as needed within the kernel
Overall, similar to layers but with more flexible
Linux, Solaris etc.,
Multiprocessor systems
Multicore Systems
Clustered Systems
Multiple systems working together
◦ sharing storage via a storage-area
network (SAN)
◦ Provides a high-availability service
which survives failures
◦ Asymmetric clustering has one machine in hot-
standby mode
◦ Symmetric clustering has multiple nodes running
applications, monitoring each other
◦ Some clusters are for high-performance
computing (HPC)
◦ Applications must be written to use parallelization
◦ Distributed lock manager (DLM) - avoid
conflicting operations
7. Concept of Virtual Machine
A virtual machine (VM) is a virtual environment which
functions as a virtual computer system with its own
CPU, memory, network interface, and storage, created
on a physical hardware system.
VMs are isolated from the rest of the system, and
multiple VMs can exist on a single piece of hardware,
like a server. Executed on a host computer or a
server.
It has its own operating system and software that will
facilitate the resources to virtual computers.
7. Concept of Virtual Machine
Characteristics of virtual machines
Multiple OS systems use the same hardware
and partition resources between virtual
computers.
Separate Security and configuration identity.
Ability to move the virtual computers
between the physical host computers as
holistically integrated files.
7. Concept of Virtual Machine
VMware Architecture
The Java Virtual Machine

You might also like