Operating Systems Overview and Functions
Operating Systems Overview and Functions
UNIT I
[Link]
ASSISTANT PROFESSOR(SRG)
COMPUTER SCIENCE & ENGINEERING
1
Course Overview
UNIT - 1
UNIT - 2
UNIT - 3
UNIT - 4
UNIT - 5
3
I
I T
UN
Unit I
⮚ Operating Systems Overview: Introduction –
Computer System Organization – Computer System
Architecture – Operations – Resource Management –
Security and Protection – Virtualization – Computing
Environments. Operating Systems Structures: Services
– User and OS Interface – System Calls – Linkers and
Loaders – Operating system Structure – Building and
Booting OS.
4
5
6
7
Popular Operating systems
8
9
I
I T
UN What is an Operating System?
⮚ A program that acts as an intermediary 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
10
I
UN
I T 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 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
11
I
I T Abstract View of Components of
UN
Computer
12
I T
I
What Operating Systems Do?
UN ⮚ Depends on the point of view
⮚ Users want convenience, ease of use and good performance
⮚ Don’t care about resource utilization
⮚ But shared computer such as mainframe or minicomputer must
keep all users happy
⮚ Operating system is a resource allocator and control program making
efficient use of HW and managing execution of user programs
⮚ Users of dedicated systems such as workstations have dedicated
resources but frequently use shared resources from servers
⮚ Mobile devices like smartphones and tablets are resource poor,
optimized for usability and battery life
⮚ Mobile user interfaces such as touch screens, voice recognition
⮚ Some computers have little or no user interface, such as embedded
computers in devices and automobiles
⮚ Run primarily without user intervention
13
I
UN
I T Operating System Definition
⮚ “The one program running at all times on the computer” is the kernel,
part of the operating system
⮚ Everything else is either
⮚ A system program (ships with the operating system, but not part
of the kernel) , or
⮚ An application program, all programs not associated with the
operating system
⮚ Today’s OSes for general purpose and mobile computing also include
middleware – a set of software frameworks that provide additional
services to application developers such as databases, multimedia,
graphics
14
I
I T
UN
Unit I
⮚ Operating Systems Overview:: Introduction –
Computer System Organization – Computer System
Architecture – Operations – Resource Management –
Security and Protection – Virtualization – Computing
Environments. Operating Systems Structures: Services –
User and OS Interface – System Calls – Linkers and
Loaders – Operating system Structure – Building and
Booting OS.
15
I
UN
I T 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
⮚ operating systems have a device driver for each device
controller.
⮚ CPU moves data from/to main memory to/from local buffers
⮚ To ensure orderly access to the shared memory, a memory
controller synchronizes access to the memory.
⮚ Device controller informs CPU that it has finished its
operation by causing an interrupt
Device driver and Device controller
Interrupts
⮚ The interrupt is a signal emitted by
hardware or software when a process or
an event needs immediate attention. It
alerts the processor to a high-priority
process requiring interruption of the
current working process
⮚ Interrupts are mechanisms used by a
computer system to handle asynchronous
events.
⮚ They allow a device or program to signal
the CPU to stop its current task and
execute a specific routine to address the
event.
⮚ Enabling efficient multitasking and
responsive hardware interactions.
I
T
UN
I
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
⮚ A trap or exception is a software-generated interrupt caused either by an error
or a user request
⮚ An operating system is interrupt driven
I
UN
I T Interrupt Timeline
I
UN
I T Interrupt Handling Process
• A interrupt-request line is used by the CPU to sense interrupts after every
instruction execution.
• The CPU detects a signal on the interrupt-request line from the device controller.
Interrupt Handling Process:
•The CPU reads the interrupt number, uses it as an index into the interrupt vector,
and jumps to the corresponding interrupt handler.
• The interrupt handler:
• Saves the current state.
• Identifies the cause of the interrupt.
• Performs the necessary processing.
• Restores the saved state.
• Executes a return-from-interrupt instruction to resume the previous task.
• The device controller raises an interrupt.
• The CPU catches and dispatches the interrupt to the handler.
• The interrupt handler services the device and clears the interrupt.
I
UN
I T Interrupt-driven I/O Cycle
I
UN
I T Interrupt Handling
⮚ CPUs have two interrupt request lines.
⮚ Nonmaskable
⮚ Maskable
⮚ Nonmaskable interrupt - This type of interrupt cannot be ignored by the CPU,
hence the name "nonmaskable."
⮚ It is typically reserved for critical, high-priority events that must be addressed
immediately and cannot be deferred, even for the sake of critical instructions or
low-level processes.
⮚ Maskable interrupt : a maskable interrupt can be turned off, or "masked," by
the CPU when it is executing certain critical operations that must not be
interrupted.
• Interrupt priority levels - to differentiate low-priority with high priority
• Interrupts are used to handle asynchronous events
I
UN
I T Interrupt vector for Intel processors
I
UN
I T Interrupt Chaining
In practice, computers often have more devices (and, consequently, more interrupt
handlers) than the number of entries in the interrupt vector table.
● For example, if the table has only 256 entries, but the system has 500 devices capable
of generating interrupts, there aren't enough entries to assign each device its own
unique vector.
Solution :
Interrupt chaining:
Many systems use a technique called interrupt chaining:
○ Each entry in the interrupt vector table points to the head of a linked list of
interrupt handlers.
○ When an interrupt occurs, the system uses the interrupt vector to locate the
appropriate list.
○ The interrupt handlers in the list are called one by one until the correct handler
identifies itself as the one capable of servicing the interrupt.
I
I T
UN Storage Structure
⮚ Main memory – only large storage media that the CPU can access directly
⮚ Random access - Typically volatile
⮚ Secondary storage – extension of main memory that provides large nonvolatile
storage capacity
⮚ Hard Disk Drives (HDD) – 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
⮚ Non-volatile memory (NVM) devices– faster than hard disks, nonvolatile
⮚ Becoming more popular as capacity and performance increases, price drops
I
UN
I T 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
I
UN
I T Storage-Device Hierarchy
Optical disk Magnetic tape
31
Computer Startup
37
I
UN
I T Computer-System Architecture
⮚ A computer system can be organized in a number of
different ways.
⮚ Based on the number of general-purpose processors used
⮚ Single-Processor Systems
⮚ Multiprocessor Systems
⮚ Clustered Systems
I
UN
I T Single-Processor Systems
⮚ If there is only one general-purpose CPU with a single
processing core, then the system is a single-processor
system.
⮚ The core is the component that executes instructions and
registers for storing data locally.
⮚ The one main CPU with its core is capable of executing a
general-purpose instruction set, including instructions from
processes and special-purpose processors (Device-specific
processors such as disk, keyboard, and graphics
controllers)
I
UN
I T Single-Processor Systems
⮚ All of these special-purpose processors do not run processes.
⮚ Sometimes, they are managed by the operating system, in that the
operating system sends them information about their next task
and monitors their status.
⮚ A disk-controller microprocessor receives a sequence of requests
from the main CPU core and implements its own disk queue
and scheduling algorithm. Thus reduces CPU overhead in disk
scheduling.
⮚ In other systems or circumstances, special-purpose processors are
low-level components built into the hardware. The operating
system cannot communicate with these processors; they do their
jobs autonomously.
I
UN
I T Multiprocessor Systems
⮚ Multiprocessor systems have two (or more) processors, each with a single-core
CPU.
⮚ The processors share the computer bus, the clock, memory, and peripheral
devices.
⮚ Also known as parallel systems, tightly-coupled systems (shared memory.)
⮚ Advantages include:
1. Increased throughput
2. Economy of scale
3. Increased reliability
⮚ Multicore systems, in which multiple computing cores reside on a single chip
⮚ Multicore systems can be more efficient than multiple chips with single cores
because on-chip communication is faster than between-chip communication
I
I T Symmetric multiprocessing architecture
UN
⮚ In symmetric multiprocessing, all
CPUs are peers, capable of performing
all tasks, including operating system
functions and user processes.
⮚ Each CPU has its own set of registers
and private cache.
⮚ Physical memory is shared among all
CPUs via the system bus.
Advantages:
● Parallel execution: N CPUs can handle
N processes simultaneously.
● Minimal performance degradation due
to task parallelism.
Challenges:
● Load imbalance (Some CPUs may remain idle while others are overloaded).
● Solution: Sharing data structures and resources dynamically can help balance workloads and improve efficiency.
I
I T A dual-core design with two cores on the
UN
same chip
The term "multiprocessor" encompasses
multicore systems, where multiple
processing cores are integrated onto a
single chip.
Advantages:
● Faster Communication: On-chip
communication between cores is faster
than between separate chips.
● Power Efficiency: Multicore chips
consume significantly less power than
multiple single-core chips, making
them ideal for mobile devices and
laptops.
Each core has its own register set and
local (L1) cache for rapid access.
I
I T Multiprocessor Systems
UN
Challenges with Scaling Multiprocessor Systems:
● Adding CPUs to a shared-memory system can initially boost performance.
● However, excessive CPUs lead to contention on the system bus, becoming a
bottleneck and degrading performance.
I
UN
I T NUMA multiprocessing architecture
Local Memory: Each CPU (or group of
CPUs) has its own local memory accessed
through a fast local bus.
Advantages of NUMA:
48
I
UN
I T Operating System Operations
⮚ Bootstrap program – simple code to initialize the system, load the kernel
⮚ Kernel loads
⮚ Starts system daemons (services provided outside of the kernel)
⮚ Kernel 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 – system call
⮚ Other process problems include infinite loop, processes modifying each
other or the operating system
I
UN
I T Multiprogramming
⮚ Single user cannot always keep CPU and I/O devices busy
⮚ OS supports to run multiple programs to keep either the CPU or the
I/O devices busy at all times.
⮚ In a multiprogrammed system, a program in execution is termed as
process.
⮚ Multiprogramming organizes jobs (code and data) so CPU always
has one to execute
⮚ General principle :
⮚ A subset of total jobs in system is kept in memory
⮚ One job selected and run via job scheduling
⮚ When job has to wait (for I/O for example), OS switches to
another job
I
UN
I T Multitasking (Timesharing)
⮚ A logical extension of Multiprogramming systems– the CPU
switches jobs so frequently providing the user with a fast response
time.
⮚ 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
⮚ If processes don’t fit in memory, swapping moves them in and
out to run
⮚ Virtual memory allows execution of processes not completely
in memory
I
I T Memory Layout for Multiprogrammed System
UN
I
UN
I T Dual-mode Operation
⮚ In order to ensure the proper execution of the operating system, we must be able
to distinguish between the execution of operating-system code and user defined
code - done by an hardware
⮚ Dual-mode operation allows OS to protect itself and other system components
⮚ User mode and kernel mode
⮚ Mode bit provided by hardware (0 – kernel and 1- user mode)
⮚ Provides ability to distinguish when system is running user code or kernel
code.
⮚ When a user is running 🢡 mode bit is “user”
⮚ When kernel code is executing 🢡 mode bit is “kernel”
⮚ How do we guarantee that user does not explicitly set the mode bit to “kernel”?
⮚ System call changes mode to kernel, return from call resets it to user
⮚ Some instructions designated as privileged, only executable in kernel mode
⮚ The instruction to switch to kernel mode is an example of a privileged
instruction
⮚ Increasingly CPUs support multi-mode operations
⮚ i.e. virtual machine manager (VMM) mode for guest VMs
I
UN
I T Dual-mode Operation
⮚ At system boot time, the hardware starts in kernel mode.
⮚ The operating system is then loaded and starts user applications
in user mode.
⮚ Whenever a trap or interrupt occurs, the hardware switches from
user mode to kernel mode
⮚ Thus, whenever the operating system gains control of the
computer, it is in kernel mode.
⮚ The system always switches to user mode before passing control
to a user program.
⮚ The dual mode of operation provides us with the means for
protecting the operating system from errant users—and errant
users from one another.
I
I T Transition from User to Kernel Mode
UN
I
UN
I T Timer
⮚ Timer to prevent infinite loop (or 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
I
I T
UN
Unit I
57
I
I T Resource Management
UN
⮚ An operating system is a resource manager.
⮚ The system’s CPU, memory space, file-storage space, and I/O devices
are among the resources that the operating system must manage.
⮚ Process Management
⮚ Memory Management
⮚ File System Management
⮚ Mass storage Management
⮚ Cache Management
I
UN
I T Process Management
⮚ A program can do nothing unless its instructions are executed by a CPU.
⮚ 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 the following to accomplish its task
⮚ Resources such as CPU, memory, I/O, files
⮚ Initialization data i.e. input
⮚ Process termination requires reclaiming 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. A multithreaded
process has multiple program counters, each pointing to the next instruction to
execute for a given thread
⮚
I
UN
I T Process Management Activities
⮚ A system consists of a collection of processes; some are operating-
system processes (those that execute system code), and the rest are user
processes (those that execute user code).
⮚ All these processes can potentially execute concurrently.
⮚ 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
I
UN
I T Memory Management
● Central to a computer's operation,
serving as a shared repository of data for
the CPU and I/O devices.
● Structured as a large array of bytes, each
byte with its own address.
● Allows the CPU to fetch instructions and
read/write data directly.
● Data from external storage, like disks,
must be transferred to main memory
before processing.
● 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
I
UN
I T Memory Management
⮚ 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
I
UN
I T File-system Management
⮚ A file is a collection of related information defined by its creator.
⮚ Files can store programs (source code or compiled objects), and data (numeric,
alphabetic, alphanumeric, or binary)
⮚ File formats can be freeform (e.g., text files), or formatted rigidly (e.g., MP3
music files).
⮚ Files organized into directories for easier access.
⮚ Access control on most systems to determine who can access what. i.e. through
read, write and append access
⮚ OS provides a 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)
I
UN
I T File-system Management
⮚ File-System management
⮚ 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
I
UN
I T Mass-Storage Management
⮚ The computer system must provide secondary storage to back up main memory.
Most modern computer systems use HDDs and NVM devices as the principal on-
line storage media for both programs and data.
⮚ Most programs—including compilers, web browsers, word processors, and
⮚ games—are stored on these devices until loaded into memory.
⮚ The programs then use the devices as both the source and the destination of their
processing.
⮚ Hence, the proper management of secondary storage is of central importance
⮚ to a computer system.
I
UN
I T 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
⮚ OS activities
⮚ Mounting and unmounting
⮚ Free-space management
⮚ Storage allocation
⮚ Disk scheduling
⮚ Partitioning
⮚ Protection
I
UN
I T Cache Management
1. Data is typically stored in a primary storage system, such as main memory (RAM) or a
database.
2. Temporary Copy in Cache: When data is accessed, it is copied into a faster, smaller
storage system called the cache. The cache is designed to be quickly accessible,
minimizing delays in retrieving frequently used data.
3. Cache Check: Before accessing the primary storage, the system checks if the required
information is already in the cache (known as a "cache hit").
○ Cache Hit: If the data is found in the cache, it is used directly from there, which is
much faster.
○ Cache Miss: If the data is not in the cache, it is retrieved from the source and then
stored in the cache for future use, based on the assumption that it will likely be
needed again soon.
4. Reusability: By storing frequently accessed data in the cache, systems can reduce
latency and improve efficiency, as retrieving data from the cache is faster than fetching
it from the original source.
I
UN
I T Caching
⮚ Important principle, performed at many levels in a computer (not only in hardware
but also in operating system -software)
⮚ Information in use copied from slower to faster storage temporarily
⮚ Cache smaller than storage being cached
⮚ Cache management important design problem
⮚ Cache size and replacement policy
I
I T Characteristics of Various Types of Storage
UN
72
I
UN
I T Protection and Security
⮚ In a multi-user, multi-process system, access to data must be regulated to ensure
safety and proper operation.
⮚ Mechanisms are implemented to ensure only authorized processes can operate on
resources like files, memory, CPU, and other components.
⮚ Memory-addressing hardware ensures that processes execute only within their
allocated address space, preventing unauthorized access.
⮚ The timer enforces time-sharing by ensuring no process can control the CPU
indefinitely, enabling fairness in resource usage.
⮚ Device-control registers are restricted from user access, ensuring the protection
and integrity of peripheral devices.
⮚ Advantages:
⮚ Protection Enhances Reliability
⮚ Early Error Detection
⮚ Risks of Unprotected Resources
⮚ Distinguishing authorized and unauthorized usage
I T
I Protection and Security
N
U ⮚ 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
I
I T
UN
Unit I
75
I
NI
U ⮚
T Virtualization
Virtualization is a technology that allows us to abstract the hardware of a
single computer (the CPU, memory, disk drives, network interface cards, and so
forth) into several different execution environments
⮚ Allows operating systems to run applications within other OSes
⮚ Vast and growing industry
⮚ Emulation used when source CPU type is different from target type (i.e.
PowerPC to Intel x86)
⮚ simulating computer hardware in software
⮚ Generally slowest method
⮚ Every machine-level instruction that runs natively on the source system must
be translated to the equivalent function on the target system
⮚ Virtualization – OS natively compiled for CPU, running guest OSes also
natively compiled
⮚ Consider VMware running WinXP guests, each running applications, all on
native WinXP host OS
⮚ VMM (virtual machine Manager) provides virtualization services
I
UN
I T Virtualization (cont.)
⮚ Use cases involve laptops and desktops running multiple OSes for
exploration or compatibility
⮚ Apple laptop running Mac OS X host, Windows as a guest
⮚ Developing apps for multiple OSes without having multiple
systems
⮚ Quality assurance testing applications without having multiple
systems
⮚ Executing and managing compute environments within data
centers
⮚ VMM can run natively, in which case they are also the host
⮚ There is no general-purpose host then (VMware ESX and Citrix
XenServer)
I
I T Computing Environments - Virtualization
UN
I
I T
UN
Unit I
79
I
I T
UN Computing Environments
⮚ Traditional
⮚ Mobile
⮚ Client Server
⮚ Peer-to-Peer
⮚ Cloud computing
⮚ Real-time Embedded
80
I
UN
I T Traditional Computing
⮚ Stand-alone general-purpose machines
⮚ In recent days, this environment have blurred as most systems
interconnect with others (i.e., the Internet)
⮚ Recent days , many organizations have portals that provide web
access to internal systems
⮚ Mobile computers can synchronize with PCs to allow very portable
use of company information.
⮚ Mobile devices can also interconnect via wireless networks
⮚ Networking becoming ubiquitous – even home systems use firewalls
to protect home computers from Internet attacks
81
I
UN
I T Mobile Computing
⮚ refers to computing on handheld smartphones and tablet computers
⮚ rich features support than traditional laptops… like e-mail ,
browsing , playing music and video, reading digital books, taking
photos, and recording and editing high-definition video, GPS chips,
accelerometers, and gyroscopes
⮚ A gyroscope is a device used for measuring or maintaining orientation and angular velocity- used
for inertial guidance systems installed in space launch vehicles, ballistic missiles, and orbiting
satellites
⮚ Accelerometers can be used to measure vibration on cars, machines, buildings, process control
systems and safety installations.
⮚ augmented-reality applications…especially for mobile devices
⮚ Two operating systems currently dominate mobile computing:
⮚ Apple iOS and
⮚ Google Android.
82
I
UN
I T Client Server
⮚ Client- generates request and Server - service the request
⮚ Distributed environment
⮚ Two categories :
• Compute-server system provides an interface to client to
request services (i.e., database)
• File-server system provides interface for clients to store and
retrieve files
83
General architecture
Peer-to-Peer Computing
⮚ Another type of distributed system
⮚ P2P does not distinguish clients and servers
- all nodes are considered peers
⮚ Each host act as client or server or both
⮚ Operation :
⮚ Node must join P2P network
⮚ Registers its service with central lookup
service on network, or
⮚ Broadcast request for service and respond
to requests for service via discovery
protocol
⮚ Voice over IP (VoIP) such as Skype
⮚ Hybrid approach
⮚ centralized login server, decentralized
peers and allows two peers to communicate
84
I
UN
I T Cloud Computing
⮚ Supports computing, storage, applications as a service through
network
⮚ Logical extension of virtualization
⮚ Amazon EC2(Amazon Elastic Compute Cloud) has thousands of servers, millions of VMs, huge
storage available across the Internet, pay based on usage
⮚ Types of clouds
⮚ Public cloud – available via Internet to anyone willing to pay
⮚ Private cloud – run by a company for the company’s own use
⮚ Hybrid cloud – includes both public and private cloud components
⮚ Types of services
⮚ Software as a Service (SaaS) – applications available via Internet (Google suite)
⮚ Platform as a Service (PaaS) – software stack ready for application use via the Internet (i.e., a
database server)
⮚ Infrastructure as a Service (IaaS) – servers or storage available over Internet (i.e., storage
available for backup)
85
I
UN
I T Real-Time Embedded Systems
87
I
UN
I T Operating System Services
⮚ Provides environment for execution of programs and services to programs and users
⮚ Set of services helpful to the user:
⮚ User interface - Varies between Command-Line (CLI), Graphics User Interface
(GUI), touch-screen
⮚ Program execution - 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 either for a file or an I/O device
⮚ File-system manipulation - Programs need to read and write files and directories,
create and delete them, search them, list file Information, permission management.
⮚ Communications – Processes may exchange information, on the same computer or
between computers over a network
⮚ Error detection – OS needs to be constantly aware of possible errors -For each error,
OS take appropriate action to ensure correct and consistent computing. Errors may
occur in the CPU and memory hardware, in I/O devices (a connection failure on a
network, or lack of paper in the printer), and in the user program (such as an arithmetic
88
overflow or an attempt to access an illegal memory location).
I
UN
I T Operating System Services…
⮚ Another set of services for efficient operation of the system itself
via resource sharing
⮚ Resource allocation - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
⮚ Logging - 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
89
I
I T A View of Operating System Services
UN
90
I
I T
UN Unit I
91
I
UN
I T User and OS Interface
⮚ Command Line interpreter (CLI)
⮚ Primarily user interacts with a command to OS
⮚ Linux, UNIX, and Windows – special program runs when we login in interactive systems
⮚ multiple CLIs called as shells – In Linux - C shell, Bourne-Again shell, Korn shell etc
⮚ Sometimes commands built-in, sometimes just names of programs (Linux)
⮚ Ex. Microsoft – MS-DOS, traditional Unix
⮚ Touch-Screen Interface
⮚ Smart phones and handheld tablet computers typically use a touch-screen interface
⮚ users interact by making gestures on the touch screen (pressing / swiping )
92
I
I T
UN
I
I T
UN Unit I
94
I
UN
I T System Calls
⮚ System calls provide an interface to the services made available by
an operating system.
⮚ available as functions written in C and C++, or assembly-language
( low-level tasks – direct hardware access)
⮚ Mostly accessed by programs via a high-level Application
Programming Interface (API) rather than direct use
⮚ Three most common APIs
⮚ Win32 API for Windows,
⮚ POSIX API for POSIX-based systems ( UNIX, Linux, and Mac
OS X)
⮚ Java API for the Java virtual machine (JVM)
95
I
UN
I T Why System calls?
⮚ Programs running in user space do not have the privileges to access
hardware or perform tasks that could affect the system's stability or
security. To perform such tasks, they need to request the OS to do it
on their behalf using system calls.
⮚ Example Python program to read a file
file_descriptor = open("[Link]", "r") # Open the file for
reading
data = file_descriptor.read() # Read the
file content
print(data) # Print the file
content
file_descriptor.close() # Close the file
⮚ System calls involved
open(), read(), write(), close()
I
UN
I T Example of System Calls
System call sequence to copy the contents of one file to another file [cp
[Link] [Link]]
97
I
I T Standard C library – System Call –relationship
UN
98
I
I T Handling of a user application invoking the
UN
open() system call
I
UN
I T Passing of parameters as a table
I
UN
I T Types of System Calls
⮚ Process control
⮚ File management
⮚ Device management
⮚ Information maintenance
⮚ Communication
⮚ Protection
10
1
I T
I
System calls …Process control
UN ⮚ 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
10
2
I
UN
I T System calls … File management
⮚ create file, delete file
⮚ open, close file
⮚ read, write, reposition
⮚ get and set file attributes
Windows Unix
10
3
I
UN
I T System calls … Device management
⮚ request device, release device
⮚ read, write, reposition
⮚ get device attributes, set device attributes
⮚ logically attach or detach devices
Windows Unix
10
4
I
NI System
T calls …Information maintenance
U
Windows
Unix
10
5
I
UN
I T System calls …Communication
■create, delete communication connection
■send, receive messages
■transfer status information
■attach and detach remote devices
Windows
Unix
10
6
I
UN
I T Protection
⮚ Get and set permissions
⮚ Allow and deny user access
Windows Unix
10
7
I #include <stdio.h>
I T
UN
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("[Link]", O_RDONLY); // System call 1
if (fd == -1) {
perror("Error opening file");
return 1;
}
char buffer[100];
int bytesRead = read(fd, buffer, sizeof(buffer)); // System call 2
if (bytesRead == -1) {
perror("Error reading file");
return 1;
}
write(1, buffer, bytesRead); // System call 3 (Write to stdout)
close(fd); // System call 4
return 0;
}
I
I T
UN Unit I
10
9
I
UN
I T Linkers and Loaders
⮚ To run a program, object file must be brought into main memory
⮚ object files that are designed to be loaded into any physical memory location
known as an relocatable object file
⮚ A linker combines several object files or libraries into a single binary executable
file
⮚ A loader is used to load the binary executable file into memory, where it is
eligible to run on a CPU core
⮚ An activity associated with linking and loading is relocation, which assigns final
addresses to the program parts and adjusts code and data in the program to match
those addresses
⮚ In reality, most systems allow a program to dynamically link libraries as the
program is loaded - Dynamically Linked Libraries (DLLs) - linking and loading
libraries that are in need
11
0
I
UN
I T Role of linker and loader
111
I
I T
UN Unit I
11
2
I
UN
I T Operating-System Structure
⮚ General-purpose OS is very large program
⮚ A common approach is to partition the task into small components,
or modules, rather than have one single system.
⮚ Various ways to structure OS design
⮚ Monolithic Structure
⮚ Layered Approach
⮚ Microkernel
⮚ Modules
⮚ Hybrid
11
3
I
UN
I T Monolithic
⮚ no structure at all - place all of the
functionality of the kernel into a
single, static binary file that runs in
a single address space.
⮚ common technique for designing
operating systems
⮚ E.g. original UNIX with 2 parts -
kernel and system programs
⮚ Adv
⮚ simplest
⮚ Less overhead in the system-call interface, and
communication within the kernel is fast
⮚ Disadv
⮚ Difficult to implement and extend.
114
Linux System Structure
Monolithic plus modular design
I
I T Layered Approach
UN
⮚ Tightly coupled vs Loosely
coupled
⮚ 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.
⮚ Debugging the lower level layers
⮚ With modularity, layers are
selected such that each uses
functions (operations) and services
of only lower-level layers
I
I T Microkernels
UN
⮚ Moves as much from the kernel into user space
⮚ Mach is an 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)
⮚ More secure
⮚ Detriments:
⮚ Performance overhead of user space to kernel space
communication
I
I T Microkernel System Structure
UN
I
I T Modules
UN
⮚ Many modern operating systems implement loadable
kernel modules (LKMs)
⮚ 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.
I
I T Hybrid Systems
UN
⮚ Most modern operating systems are 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
I
I T
UN Unit I
12
5
I
I T Building and Booting an
UN
Operating System
⮚ Operating systems generally designed to run on a class of systems
with variety of peripherals
⮚ Commonly, operating system already installed on purchased
computer
⮚ But can build and install some other operating systems
⮚ If generating an operating system from scratch
⮚ Write the operating system source code
⮚ Configure the operating system for the system on which it
will run
⮚ Compile the operating system
⮚ Install the operating system
⮚ Boot the computer and its new operating system
I T
I
Building and Booting Linux
UN
⮚ Download Linux source code ([Link]
⮚ Configure kernel via “make menuconfig”
⮚ Compile the kernel using “make”
⮚ Produces vmlinuz, the kernel image
⮚ Compile kernel modules via “make modules”
⮚ Install kernel modules into vmlinuz via “make
modules_install”
⮚ Install new kernel on the system via “make install”
I T
I
System Boot
UN
⮚ The process of starting a computer by loading the kernel is known as booting the
system
⮚ When power initialized on system, execution starts at a fixed memory location
⮚ Operating system must be made available to hardware so hardware can start it
⮚ Small piece of code – bootstrap loader, BIOS, stored in ROM or
EEPROM locates the kernel, loads it into memory, and starts it
⮚ Sometimes two-step process where boot block at fixed location loaded by
ROM code, which loads bootstrap loader from disk
⮚ Modern systems replace BIOS with Unified Extensible Firmware
Interface (UEFI)
⮚ Common bootstrap loader, GRUB, allows selection of kernel from multiple
disks, versions, kernel options
⮚ Kernel loads and system is then running
⮚ Boot loaders frequently allow various boot states, such as single user mode
I
UN
I T Course Outcome
On completion of the course, the students will be able to
⮚ CO1 : explain operating system structure, services and system calls and identify
appropriate system calls for a given service
⮚ CO2 : make use of process management strategies for scheduling processes
⮚ CO3 : apply different methods for process synchronization and deadlock handling
⮚ CO4 : make use of memory management strategies and apply page replacement
policies to address demand paging
⮚ CO5 : apply various disk scheduling algorithms and elaborate file systems
concepts
12
9