0% found this document useful (0 votes)
3 views66 pages

OS Introduction

Uploaded by

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

OS Introduction

Uploaded by

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

CSL3030

Operating Systems
Sidharth Sharma
Autumn 2025
Grading Policy

Theory: 75%
Midsem: 25%
Endsem: 40% [Full Syllabus]
Quizzes (2): 5% [before midsem] + 5% [after midsem]
---------------------------------------------------------------------------
Lab: 25%
In-lab assignments: 10% (2.5% x 4)
Final lab coding exam + viva: 10%
Lab attendance: 5%
General Information
Textbook
1. Operating System Concepts, 8th Ed, by Silberschatz, Galvin, and Gagne
2. Design of the Unix Operating System, by Maurice Bach

I will use materials from other books as and when needed


What is an Operating System?

● User-centric definition
● A program that acts as an intermediary between
a user of a computer and the computer hardware
● Defines an interface for the user to use services
provided by the system
● Provides a “view” of the system to the user
● System-centric definition
● Resource allocator – manages and allocates
resources
● Control program – controls the execution of user
programs and operations of I/O devices
Computer System Structure
● The computer system can be divided into four components:
● Hardware – provides basic computing resources
4 CPU, memory, I/O devices
● Operating system
4 Controls and coordinates the use of the 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
4 Word processors, compilers, web browsers, database
systems, video games
● Users
4 People, machines, other computers
Abstract View of System
Components
What Operating Systems Do
• Depends on the point of view

• Users want convenience, ease of use and good


performance
• Don’t care about resource utilization

• But shared computers such as mainframe or


minicomputer must keep all users happy

• Handheld computers are resource-poor, optimized for


usability and battery life
• Some computers have little or no user interface, such as
embedded computers in devices and automobiles
Operating System Definition

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
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 the 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
• Device controller informs CPU that it has
finished its operation by causing an interrupt
Storage Definitions and Notation Review

The basic unit of computer storage is the bit. A bit can contain one of two
values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent:
numbers, letters, images, movies, sounds, documents, and programs, to name a
few. A byte is 8 bits, and on most computers it is the smallest convenient chunk
of storage. For example, most computers don’t have an instruction to move a bit
but do have one to move a byte. A less common term is word, which is a given
computer architecture’s native unit of data. A word is made up of one or more
bytes. For example, a computer that has 64-bit registers and 64-bit memory
addressing typically has 64-bit (8-byte) words. A computer executes many
operations in its native word size rather than a byte at a time.

Computer storage, along with most computer throughput, is generally measured


and manipulated in bytes and collections of bytes.
A kilobyte, or KB, is 1,024 bytes
a megabyte, or MB, is 1,0242 bytes
a gigabyte, or GB, is 1,0243 bytes
a terabyte, or TB, is 1,0244 bytes
a petabyte, or PB, is 1,0245 bytes

Computer manufacturers often round off these numbers and say that a
megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking
measurements are an exception to this general rule; they are given in bits
(because networks move data a bit at a time).
Storage Hierarchy

Storage systems organized in hierarchy


Speed
Cost
Volatility
Caching – copying information into faster
storage system; main memory can be viewed
as a cache for secondary storage
Device Driver for each device controller to
manage I/O
Provides uniform interface between controller and
kernel
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
Direct Memory Access (DMA)
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
How a Modern Computer Works

A von Neumann architecture


Computer-System Architecture

• Most systems use a single general-purpose processor


• Most systems have special-purpose processors as well
• Multiprocessors systems growing in use and importance
Also known as parallel systems, tightly-coupled systems
Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability – graceful degradation or fault tolerance
Two types:
4. Asymmetric Multiprocessing – each processor is assigned a
specific task (mostly used in embedded systems)
5. Symmetric Multiprocessing – each processor performs all tasks
All processor communicates to each other using shared
memory.
Symmetric Multiprocessing Architecture
Clustered Systems
• Like multiprocessor systems, but multiple systems
working together
• Usually sharing storage via a storage-area network (SAN)
• Provides a high-availability service that 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
• Some have distributed lock manager (DLM) to avoid
conflicting operations
Clustered Systems
Operating System Structure
Multiprogramming (Batch system) 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

Timesharing (multitasking) is logical extension in which CPU


switches jobs 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 executing in memory
 process
If several jobs ready to run at the same time CPU scheduling
Memory Layout for Multiprogrammed System
Operating-System Operations
Interrupt-driven (hardware and software)
• Hardware interrupt by one of the devices
• Software interrupt (exception or trap):
• Software error (e.g., division by zero)
• Request for operating system service
• Other process problems include infinite
loop, processes modifying each other or
the operating system
Operating-System Operations
(cont.)
Dual-mode operation allows OS to protect itself
and other system components
User mode and kernel mode
Mode bit provided by hardware
• Provides ability to distinguish when system is
running user code or kernel code
• Some instructions designated as privileged,
only executable in kernel mode
• System call changes mode to kernel, return
from call resets it to user
Transition from User to Kernel Mode
Tasks of Operating Systems
• Process Management

• Memory Management

• I/O Management

• File Management

• Storage Management
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 termination requires reclaim of any reusable
resources
• 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

• To execute a program all (or part) of the instructions


must be in memory
• All (or part) of the data that is needed by the program
must be in memory.
• Memory management determines what is in memory
and 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-System management
• Files usually organized into directories
• Access control on most systems to determine who can
access what
• OS 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
Performance of Various Levels of Storage

Movement between levels of storage hierarchy can


be explicit or implicit
I/O Subsystem

• One purpose of OS is to hide peculiarities of hardware


devices from the user
• I/O subsystem responsible for
• Memory management of I/O including buffering (storing
data temporarily while it is being transferred), caching
(storing parts of data in faster storage for performance),
spooling (the overlapping of output of one job with input
of other jobs)
• General device-driver interface
• Drivers for specific hardware devices
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
A View of Operating System
Services
User Operating System Interface - CLI

• CLI or command interpreter allows direct command


entry
• Sometimes implemented in the kernel, sometimes by
systems program
• Sometimes multiple flavors are implemented – shells
• Primarily fetches a command from the user and
executes it.
• In one approach, the command interpreter itself
contains the code to execute the command.
• For example, a command to delete a file may cause
• the command interpreter jumps to a section of its code
that sets up the parameters and makes the appropriate
system call.
• An alternative approach—used by UNIX, among other
operating systems—implements most commands
through system programs.
Bourne Shell Command Interpreter
User Operating System Interface - GUI

• User-friendly desktop metaphor interface


• Usually mouse, keyboard, and monitor
• Icons represent files, programs, actions, etc
• Various mouse buttons over objects in the interface cause
various actions (provide information, options, execute
function, open directory (known as a folder)
• Invented at Xerox PARC
• Many systems now include both CLI and GUI interfaces
• Microsoft Windows is GUI with CLI “command” shell
• Apple Mac OS X is “Aqua” GUI interface with UNIX kernel
underneath and shells available
• Unix and Linux have CLI with optional GUI interfaces (CDE,
KDE, GNOME)
Touchscreen Interfaces

• Touchscreen devices
require new interfaces
• Mouse not possible or
not desired
• Actions and selection
based on gestures
• Virtual keyboard for text
entry
• Voice commands.
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


Programming Interface (API) rather than direct system call use

• The three most common APIs are Win 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 Standard API
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 the 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
System Call Parameter Passing
• Often, 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
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
Types of System Calls

• File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
• Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Types of System Calls (Cont.)
• Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
• Communications
• create, delete communication connection
• send, and receive messages if the message passing
model to hostname or process name
• From client to server
• Shared-memory model create and gain access to
memory regions
• transfer status information
• attach and detach remote devices
Types of System Calls (Cont.)

• Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Examples of Windows and Unix System Calls
Standard C Library Example
C program invoking printf() library call, which calls
write() system call
Operating System Structure
General-purpose OS is a very large program

Various ways to structure


• Simple structure – MS-DOS
• More complex -- UNIX
• Layered – an abstraction
• Microkernel -Mach
Simple Structure -- MS-DOS

• 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
• Written for Intel 8088
Non Simple 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
Beyond simple but not fully layered
Unix Kernel
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.

• Careful planning for defining layers.

• Less efficient (because of hierarchical


structure)
Microkernel System Structure
• Moves as much from the kernel into user space
• Mach example of microkernel
• Mac OS X kernel (Darwin) partly based on Mach
• 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)
• Detriments:
• Performance overhead of user space to kernel space
communication
Microkernel System Structure
Modules
• Many modern operating systems implement
loadable kernel modules
• Uses an object-oriented approach
• Each core component is separate
• Dynamically links additional services boot time
or run time
• 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
Solaris Modular Approach

Any module can call any other module

No message-passing required
Hybrid Systems
• Most modern operating systems are actually not one
pure model
• Hybrid combines multiple approaches to address
performance, security, usability needs
• Linux and Solaris kernels in kernel address space, so
monolithic, plus modular for dynamic loading of
functionality
• Windows mostly monolithic, plus microkernel for
different subsystem personalities
• Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa
programming environment
• On next slide is the kernel consisting of Mach microkernel
and BSD Unix parts, plus I/O kit and dynamically loadable
modules (called kernel extensions)
Mac OS X Structure
iOS

• Apple mobile OS for iPhone, iPad


• Structured on Mac OS X, added
functionality
• Does not run OS X applications natively
• Also runs on different CPU
architecture (ARM vs. Intel)
• Cocoa Touch Objective-C API for
developing apps
• Media services layer for graphics, audio,
video
• Core services provides cloud computing,
databases
• Core operating system, based on Mac OS
X kernel
Android
• Developed by Open Handset Alliance (mostly Google)
• Open Source
• Similar stack to IOS
• Based on Linux kernel but modified
• Provides process, memory, and device-driver
management
• Adds power management
• Runtime environment includes a core set of libraries and
Dalvik virtual machine
• Apps developed in Java plus Android API
• Java class files compiled to Java bytecode then
translated to executable then runs in Dalvik VM
• Libraries include frameworks for web browser (webkit),
database (SQLite), multimedia, smaller libc
Android Architecture

You might also like