OS_Chapter-1
Chapter-1
[Link]
An operating system is software that manages a computer’s hardware. It also provides a
basis for application programs and acts as an intermediary between the computer user and the
computer hardware.
In order to explore the role of an operating system in a modern computing environment, it is
important first to understand the organization and architecture of computer hardware. This
includes the CPU, memory, and I/O devices,as well as storage. A fundamental responsibility
of an operating system is to allocate these resources to programs.
A computer system can be divided roughly into four components: the hardware, the
operating system, the application programs,and a user (Figure 1.1).
The hardware— the central processing unit (CPU), the memory, and the input/output (I/O)
devices—provides the basic computing resources for the system. The application programs
such as word processors, spreadsheets,compilers, and web browsers—define the ways in
which these resources are used to solve users’ computing problems. The operating system
controls the hardware and coordinates its use among the various application programs for the
various users.
User View: The user’s view of a computer depends on the interface being used. Example: A
personal computer (PC) or laptop with a monitor, keyboard, and [Link] systems are
designed for a single user to use all [Link] goal is to maximize the user’s productivity
or [Link] operating system (OS) in this setup focuses mainly on:
o Ease of use – making the system user-friendly.
o Performance – ensuring smooth operation.
1
OS_Chapter-1
o Security – protecting the system and data.
Resource utilization (sharing of hardware/software resources) is not a concern, since
only one user accesses the system.
Overall, personal computers prioritize convenience and performance over resource-
sharing efficiency.
Mobile devices (smartphones, tablets) are increasingly replacing desktops and laptops
for many users.
These devices are usually connected via cellular or wireless networks.
User interface:
o Uses a touchscreen for interaction (taps, swipes).
o Some devices support voice recognition (e.g., Siri).
Embedded computers:
o Found in home appliances, automobiles, etc.
o Have minimal or no direct user interaction.
o May use keypads or indicator lights to show status.
o Designed to operate automatically without user intervention.
System View: The operating system (OS) is the program most closely connected to the
[Link] acts as a resource allocator – manages:
o CPU time
o Memory space
o Storage space
o I/O devices
The OS allocates resources efficiently and fairly among users and programs.
The OS is also a control program – it:
o Controls execution of user programs.
o Prevents errors and misuse of the system.
o Manages and controls I/O device operations.
2. Computer-System Organization
A modern computer system includes:
One or more CPUs.
Multiple device controllers (for disk, audio, graphics, etc.).
A common bus that connects components and shared memory.
Device controller:
Manages a specific type of device.
May control multiple devices (e.g., USB hub).
Has local buffer storage and special-purpose registers.
Handles data transfer between peripheral devices and its buffer.
Device driver:
2
OS_Chapter-1
Software that communicates with the device controller.
Provides a uniform interface between hardware and the OS.
Parallel execution:
CPU and device controllers can run simultaneously.
Both compete for memory access.
A memory controller synchronizes access to shared memory.
1.2.1 Interrupts
During I/O operations, the device driver starts the process by loading commands into the
device controller’s registers. The device controller checks these commands and begins the
required action (e.g., reading from keyboard).Data is transferred from the device to the
controller’s local [Link] completing the operation, the controller notifies the device
driver that the task is done.
The device driver then:Passes the data (if it was a read operation), or Returns status info
(e.g., “write complete” or “device busy”).The notification from the controller to the driver is
done through an interrupt.
Interrupts are signals sent by hardware to the CPU (usually through the system bus)
to get its [Link] system bus is the main communication path between computer
[Link] help hardware and the operating system interact efficiently.
How an interrupt works: 1. Hardware sends an interrupt signal to the CPU.
[Link] pauses its current task.
3. CPU jumps to a fixed memory location containing the address of the interrupt service
routine (ISR).
[Link] ISR executes to handle the event.
[Link] done, the CPU returns to the previous task and continues from where it stopped.
3
OS_Chapter-1
1.2.2 Implementation:
Interrupt mechanism process:
1. The CPU has an interrupt-request line it checks after every instruction.
2. When a device controller raises an interrupt, it sends a signal on this line.
3. The CPU detects the signal, reads the interrupt number, and uses it as an index
in the interrupt vector table.
4. The CPU jumps to the corresponding interrupt handler (service routine).
5. The interrupt handler:
Saves the current CPU state.
Identifies the cause of the interrupt.
Performs the required processing.
Restores the saved state.
Returns control to the previously running program.
Modern interrupt-handling features:
1. Defer interrupts during critical operations.
2. Efficiently dispatch to the correct interrupt handler.
3. Support multilevel interrupts to handle priority levels (high vs. low priority).
These advanced features are managed by the CPU and interrupt controller hardware in
modern systems.
4
OS_Chapter-1
1.2.2 Storage Structure1.2.2 Storage Structure
1.2.3 Storage Structure
The CPU can execute instructions only from memory, so programs must be loaded into
memory before running. Most programs run from main memory (RAM), which is rewritable
and typically made of dynamic RAM (DRAM). RAM is volatile – it loses data when power is
turned [Link] startup, a bootstrap program runs first to load the operating [Link] RAM
can’t store the bootstrap program, it is kept in nonvolatile memory like EEPROM or other
firmware. Firmware is permanent storage, used rarely for writing and retains data even
without power.
Memory and Its Operation
Memory is an array of bytes, each with a unique address.
Load instruction: moves data from memory → CPU register.
Store instruction: moves data from CPU register → memory.
The CPU automatically fetches instructions from memory using the program
counter.
Instruction Execution Cycle (von Neumann architecture)
1. Fetch instruction from memory → instruction register.
5
OS_Chapter-1
2. Decode the instruction.
3. Fetch operands (if needed) from memory.
4. Execute the instruction.
5. Store result back in memory (if required).
Memory sees only a stream of addresses; it doesn’t know if they are for data or
instructions.
Limitations of Main Memory:
1. Main memory is usually too small to store all needed programs and data
permanently.
2. Main memory, as mentioned, is volatile—it loses its contents when power
is turned off or otherwise lost.
The wide variety of storage systems can be organized in a hierarchy (Figure1.6) according to
storage capacity and access [Link] shown in the figure, in addition to differing in speed and
capacity, the various storage systems are either volatile or nonvolatile. Volatile storage, as
mentioned earlier, loses its contents when the power to the device is removed,so data must be
written to nonvolatile storage for safekeeping.
6
OS_Chapter-1
1.2.4 I/O Structure
A large portion of operating system code is dedicated to managing I/O, both because of its
importance to the reliability and performance of a system and because of the varying nature
of the devices.
The form of interrupt-driven I/O is fine for moving small amounts of data but can produce
high overhead when used for bulk data movement.
Direct Memory Access (DMA): used to improve data transfer efficiency.
Process:
1. CPU sets up buffers, pointers, and counters for the I/O device.
2. The device controller transfers a block of data directly between the device and main
memory.
3. The CPU is not involved in the transfer process.
Advantages:
Only one interrupt per data block, not per byte (reduces CPU overhead).
The CPU can perform other tasks while the transfer happens.
High-end systems:
Use a switch-based architecture instead of a shared bus.
Allows multiple components to communicate simultaneously.
Makes DMA even more efficient.
7
OS_Chapter-1
DEFINITIONS OF COMPUTER SYSTEM COMPONENTS
• CPU—The hardware that executes instructions.
• Processor—A physical chip that contains one or more CPUs.
• Core—The basic computation unit of the CPU.
• Multicore— Including multiple computing cores on the same CPU.
• Multiprocessor— Including multiple processors.
Although virtually all systems are now multicore, we use the general term CPU when
referring to a single computational unit of a computer system and core as well as multicore
when specifically referring to one or more cores on a CPU.
1.3 Computer-System Architecture
A computer system can be organized in a number of different ways,which we can categorize
roughly according to the number of general-purpose processors used.
1.3.1 Single-Processor Systems
Earlier computer systems had a single processor with one CPU and one processing
[Link] core executes instructions and contains registers for local data storage. The
main CPU runs general-purpose instructions and handles process execution. Systems
also included special-purpose processors, such as:
o Disk controllers
o Keyboard controllers
o Graphics controllers
These processors:Have a limited instruction set,Do not run processes,May be managed by the
operating system (OS sends tasks and monitors status).Example:Disk-controller processor
handles disk scheduling and Keyboard microprocessor converts keystrokes into signals for
the [Link] special-purpose processors are built into hardware and operate autonomously
(OS cannot directly control them).
A system with only one general-purpose CPU core is still a single-processor system,
o Even if it has several special-purpose processors.
o However, modern systems rarely remain single-processor — most are
multiprocessor or multicore.
1.3.2 Multiprocessor Systems
In symmetric multiprocessing (SMP), multiple processors work together and can perform any
task, including operating system and user processes. Each processor has its own registers and
cache, but all share the same main memory. This allows several processes to run at once,
improving speed. If one processor is busy and another is idle, sharing data and resources
helps balance the workload and keep the system efficient.
8
OS_Chapter-1
The definition of multiprocessor has evolved over time and now includes 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.
In Figure 1.9, In a dual-core design, two processing cores are built on the same processor
chip. Each core has its own register set and local (L1) cache for quick data access. Both
cores share a larger level 2 (L2) cache, which is common to the chip. This setup is widely
used because local caches are smaller and faster, while shared caches help the core
9
OS_Chapter-1
efficiently share data.
In a multiprocessor system, adding more CPUs increases computing power, but too many
CPUs can cause bus contention, slowing performance. To overcome this, figure 1.10
systems use Non-Uniform Memory Access (NUMA), where each CPU (or group of CPUs)
has its own local memory connected through a fast local bus, and all CPUs share a common
system interconnect. This design allows faster access to local memory and better
scalability. However, accessing remote memory (memory of another CPU) is slower,
causing latency. Operating systems reduce this delay through smart scheduling and
memory management. NUMA is widely used in servers and high-performance
computing systems for better scalability.
10
OS_Chapter-1
1.3.3 Clustered Systems
Another type of multiprocessor system is a clustered system, which gathers together
multiple CPUs. Clustered systems differ from the multiprocessor systems. Clustered
systems are made up of two or more individual systems (nodes) connected together;
each node is usually a multicore system.
They are loosely coupled systems. Nodes are connected via a Local Area Network
(LAN) or a high-speed interconnect like InfiniBand. They share storage.
Mainly used to provide high availability — services continue even if one or more
nodes [Link] through redundancy and cluster management software.
Types of Clustering:
1. Asymmetric Clustering:
o One node is active, another in hot standby mode.
o Standby node becomes active if the main server fails.
2. Symmetric Clustering:
o All nodes run applications and monitor each other.
o More efficient but requires multiple applications to manage.
Clusters can also be used for parallel processing to increase computational power.
Applications must be designed for parallelization—dividing tasks among multiple
nodes and combining [Link] Cluster Forms:
Parallel Clusters: Multiple hosts access the same shared data.
WAN Clusters: Clusters connected over a wide-area network.
1.4 Operating-System Operations
1.4.1 Multiprogramming and Multitasking
Multiprogramming allows multiple programs to run at the same time to make better use of
the CPU and system resources. Since a single program cannot keep the CPU and I/O devices
busy all the time, the operating system keeps several processes (programs in execution) in
memory simultaneously.
11
OS_Chapter-1
It selects one process to execute, and when that process needs to wait for an I/O operation,
the CPU switches to another process instead of sitting idle. This ensures that the CPU is
always working on some task as long as at least one process is ready to execute.
Multiprogramming increases CPU utilization and overall system efficiency while allowing
users to run multiple programs at once.
It can be compared to a lawyer managing multiple cases—while one case is waiting, the
lawyer works on another, ensuring no time is wasted.
Multitasking is an extension of multiprogramming where the CPU switches rapidly between
multiple processes to give the appearance that they are running simultaneously. This frequent
switching provides quick response times, making the system feel interactive to the user.
When a process runs, it usually executes for a short time before needing input or output (I/O).
Since interactive I/O—like typing on a keyboard, moving a mouse, or touching a screen—
operates at human speed, it can be slow. During this waiting time, the CPU switches to other
tasks, keeping the system responsive and efficient.
Rather than let the CPU sit idle as this interactive input takes place, the operating system will
rapidly switch the CPU to another process.
1.4.2 Dual-Mode and Multimode Operation
In order to ensure the proper execution of the system, we must be able to distinguish between
the execution of operating-system code and user-defined code. The approach taken by most
computer systems is to provide hardware support that allows differentiation among various
modes of execution.
Computer systems require two modes of operation: user mode and kernel mode (also called
supervisor, system, or privileged mode). A mode bit in the hardware indicates the current
mode: 0 for kernel mode and 1 for user mode. This distinction allows the system to know
whether a task is running on behalf of the operating system or a user application. Normal user
12
OS_Chapter-1
programs run in user mode, but when a program requests an OS service through a system
call, the system switches to kernel mode to execute the requested service safely.
The dual-mode operation helps protect the operating system from faulty or malicious user
programs and prevents users from interfering with each other. This is done by designating
certain instructions as privileged instructions, which can only be executed in kernel mode.
If a user program tries to execute a privileged instruction in user mode, the hardware treats it
as illegal and traps it to the operating system. Examples of privileged instructions include
switching to kernel mode, controlling I/O devices, managing timers, and handling interrupts.
1.5 Resource Management
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.
1.5.1 Process Management
The operating system is responsible for the following activities in connection with process
management:
• Creating and deleting both user and system processes
• Scheduling processes and threads on the CPUs
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
1.5.2 Memory Management
The operating system is responsible for the following activities in connection with memory
management:
• Keeping track of which parts of memory are currently being used and
which process is using them
13
OS_Chapter-1
• Allocating and deallocating memory space as needed
• Deciding which processes (or parts of processes) and data to move into
and out of memory
1.5.3 File-System Management
The operating system is responsible for the following activities in connection with file
management:
• Creating and deleting files
• Creating and deleting directories to organize files
• Supporting primitives for manipulating files and directories
• Mapping files onto mass storage
• Backing up files on stable (nonvolatile) storage media
1.5.4 Mass-Storage Management
• Protection The operating system is responsible for the following activities in connection
with secondary storage management:
• Mounting and unmounting
• Free-space management
• Storage allocation
• Disk scheduling
• Partitioning
1.5.5 Cache Management
Caching is an important principle of computer systems. Here’s how it [Link] is
normally kept in some storage system (such as main memory).As it is used, it is copied into a
faster storage system the cache on a temporary basis. When we need a particular piece of
information, we first check whether it is in the cache. If it is, we use the information directly
from the cache. If it is not, we use the information from the source, putting a copy in the
cache under the assumption that we will need it again soon.
Because caches have limited size, cache management is an important design problem. Careful
selection of the cache size and of a replacement policy can result in greatly increased
performance.
1.5.6 I/O System Management
The I/O subsystem consists of several components:
• A memory-management component that includes buffering, caching, and spooling
• A general device-driver interface
• Drivers for specific hardware devices
14
OS_Chapter-1
1.6 Computing Environments
[Link] Computing
Computing environments have evolved beyond traditional setups. Offices now use web
portals, network computers (thin clients), and mobile devices that connect via wireless or
cellular networks, providing easy access and portability. At home, faster network connections
allow multiple devices, including PCs, printers, and servers, to be connected securely, often
protected by firewalls. Overall, web technologies and improved connectivity have blurred the
lines between office, home, and mobile computing.
2 Mobile Computing
Mobile computing involves using portable, lightweight devices like smartphones and tablets.
Historically, these devices sacrificed screen size, memory, and functionality for mobility, but
modern devices now rival laptops in features. Mobile devices support email, web browsing,
multimedia, photography, and HD video, and leverage unique hardware like GPS,
accelerometers, and gyroscopes for navigation, gaming, and augmented-reality applications.
Connectivity is provided via Wi-Fi (IEEE 802.11) or cellular networks. While mobile devices
have limited storage, processing speed, and cores compared to desktops, they continue to
grow in capability. The dominant mobile operating systems are Apple iOS and Google
Android.
3 Client –Server Computing
Modern network architecture often uses client–server systems, where servers handle requests
from client systems.
Compute servers: Execute actions requested by clients and return results.
Example: A database server responding to data queries.
o File servers: Provide a file-system interface for clients to create, read, update,
or delete files.
Example: A web server delivering web pages or multimedia content to clients.
15
OS_Chapter-1
4 Peer-to-Peer Computing
In peer-to-peer systems, all nodes are considered peers and can act as clients or servers
depending on whether they are requesting or providing a service. Unlike client–server
systems, P2P avoids server bottlenecks by distributing services across multiple nodes.
Joining the network: A node must join the P2P network to provide and request
services.
Service discovery:
1. Centralized lookup: Nodes register their services with a central directory;
clients query it to find providers.
2. Decentralized discovery: Nodes broadcast requests to find service providers
directly, using a discovery protocol.
This structure enables scalable and distributed access to resources without relying on a single
server.
16
OS_Chapter-1
5 Cloud Computing
Cloud computing is a type of computing that delivers computing, storage,and even
applications as a service across a [Link] are actually many types of cloud
computing, including the following:
• Public cloud—a cloud available via the Internet to anyone willing to pay for the services
• Private cloud—a cloud run by a company for that company’s own use
• Hybrid cloud—a cloud that includes both public and private cloud components
• Software as a service (SaaS)—one or more applications (such as word processors or
spreadsheets) available via the Internet
• Platform as a service (PaaS)—a software stack ready for application use via the Internet (for
example, a database server)
• Infrastructure as a service (IaaS)—servers or storage available over the Internet.
17
OS_Chapter-1
6 Real-Time Embedded Systems
Embedded systems are the most common type of computers, found in devices like cars,
robots, microwaves, and home appliances. They perform specific, limited tasks and often
have minimal user interfaces, focusing on monitoring and controlling hardware. Some
embedded systems run general-purpose OSs like Linux, while others use special-purpose
embedded operating systems. Their role is growing rapidly, with smart homes and IoT
devices enabling centralized control and remote automation.
Most embedded systems use real-time operating systems (RTOS), which must process data
within strict time limits to function correctly. Real-time systems are used in control
applications like industrial automation, medical imaging, and automotive systems, where
delayed responses can cause system failure. These systems differ from regular computers,
where timing is important but not critical.
18