os short notes
os short notes
1. Mutual Exclusion Condition: The resources involved are non-shareable. Only one process
at a time can use a resource. Explanation: At least one resource (thread) must be held in a
non-shareable mode, that is, only one process at a time claims exclusive control of the
resource. If another process requests that resource, the requesting process must be delayed
until the resource has been released.
2. Hold and Wait Condition: A process holding at least one resource is waiting to acquire
additional resources held by other processes. Explanation: There must be a process that is
holding a resource already allocated to it; while waiting for additional resources that are
currently being held by other processes.
4. Circular Wait Condition: The processes in the system form a circular list or chain; where
each process in the list is waiting for a resource held by the next process in the list.
Explanation: A set {P0, P1, …., Pn} of waiting processes must exist such that P0 is waiting for
resource held by P1, P1 is waiting for a resource held by P2,…..Pn-1 is waiting for a resource
held by Pn and Pn is waiting for a resource held by P0.
Deadlock recovery involves breaking the deadlock cycle once it has been detected. Common
methods include:
• Process Termination: Kill one or more processes involved in the deadlock. You can
either:
• Resource Preemption: Temporarily take resources away from some processes and
give them to others. Requires rollback and tracking resource usage carefully.
• Process Rollback: Roll back one or more processes to a previous safe state and
restart them later.
• Linked List: Free blocks are linked together like a list; traversal is needed to find
suitable blocks.
• Grouping: Stores the address of a set of free blocks in a block, and that block
contains the address of the next group.
• Counting: Maintains the address of the first free block and the number of contiguous
free blocks. Useful if free blocks tend to be contiguous.
Disk scheduling refers to the way the OS decides the order in which disk I/O requests are
handled. Because disk head movement is slow compared to memory, efficient scheduling
improves system performance. Common algorithms include:
4. What is deadlock?
A deadlock is a situation where a group of processes are blocked forever, each waiting for a
resource that another process holds. It arises when four conditions hold simultaneously:
1. Mutual Exclusion Condition: The resources involved are non-shareable. Only one process
at a time can use a resource. Explanation: At least one resource (thread) must be held in a
non-shareable mode, that is, only one process at a time claims exclusive control of the
resource. If another process requests that resource, the requesting process must be delayed
until the resource has been released.
2. Hold and Wait Condition: A process holding at least one resource is waiting to acquire
additional resources held by other processes. Explanation: There must be a process that is
holding a resource already allocated to it; while waiting for additional resources that are
currently being held by other processes.
System architectures describe how components are structured in an OS. Examples include:
• Monolithic Architecture: All services run in kernel space (e.g., traditional UNIX).
• Layered Architecture: OS is divided into layers, each built on the one below.
8. What is kernel?
The kernel is the core part of an operating system. It directly interacts with hardware and
manages system resources. Its responsibilities include:
What is a Kernel?
Definition:
A kernel is the core component of an operating system (OS) that manages communication
between hardware and software, controls system resources, and ensures efficient and
secure system operations.
1. Process Management
2. Memory Management
3. Device Management
How It Works:
• The kernel receives these requests, talks to the hardware, and returns the result to
the app.
Types include:
• Monolithic Kernel
• Microkernel
• Hybrid Kernel
9. What are the features of mobile operating systems?
Mobile OSes are optimized for portability, battery efficiency, and user interaction. Key
features include:
• Touchscreen support
• Clustered Systems: Multiple systems work together closely, like one system.
• Cloud Computing Systems: Resources are delivered as services over the internet.
In a Resource Allocation Graph (RAG), a request edge is a directed edge from a process to a
resource.
• Denoted as: P → R
• These edges indicate that the process is blocked, waiting for the resource to become
available.
A safe state in deadlock handling is one where the system can allocate resources to all
processes in some sequence without leading to deadlock.
• In a safe state, the OS can avoid deadlock by carefully scheduling resource allocation.
• Safe state ≠ deadlock-free, but if in a safe state, deadlock can be avoided.
13. List the names of any two disk allocation methods of disk space
1. Contiguous Allocation
Description:
Each file is stored in a single contiguous block of disk space.
Advantages:
• Simple to implement.
Disadvantages:
2. Linked Allocation
Description:
Each file is stored as a linked list of disk blocks, where each block contains a pointer to the
next.
Advantages:
• No external fragmentation.
Disadvantages:
1. Seek Time – Time to move the disk arm to the desired track.
2. Rotational Latency – Time for the disk to rotate the desired sector under the
read/write head.
3. Transfer Time – Time to read/write the data once the sector is located.
• Shared resources
• Concurrency
• Fault tolerance
Size scalability refers to the ability of a system (especially distributed systems) to handle
growth in the number of users, nodes, or services without performance loss.
E.g., Adding more servers to a cloud service without slowing it down.
1. Layered Architecture
2. Client-Server Model
3. Peer-to-Peer Model
4. Object-Based Architecture
5. Microkernel Architecture
• A CPU design principle where instructions are simple and execute in a single cycle.
• ARM uses RISC to achieve high performance with low power consumption, making
it ideal for mobile devices.
20. Write any two special service requirements of mobile operating system
1. Energy Efficiency – Mobile OS must manage power efficiently to extend battery life.
2. Mobility & Connectivity – Must support mobile networks (e.g., LTE, Wi-Fi) and
enable seamless transitions.
• A claim edge is a dashed edge from a process to a resource, indicating that the
process may request the resource in the future.
1. Transparency
Definition:
Transparency means hiding the complexity and internal workings of the distributed system
from users and applications, making it appear as a single, unified system.
Types of transparency include:
• Access Transparency: Users can access resources without knowing their physical
location.
• Replication Transparency: Users are unaware of the fact that multiple copies of
resources exist.
2. Scalability
Definition:
Scalability refers to the ability of a distributed system to handle growth — in terms of users,
data, and computing resources — without significant performance degradation.
Scalability involves:
2. Familiar Interface – UI similar to Windows desktop OS, reducing learning curve for
users.
3. Enterprise Features – Better suited for business users with enhanced security and
device management.
SCAN vs LOOK:
• SCAN (Elevator Algorithm): The disk arm moves in one direction fulfilling requests
until it reaches the end, then reverses direction.
• LOOK: Similar to SCAN but reverses direction at the last request instead of going to
the physical end of the disk.
LOOK vs C-LOOK:
• C-LOOK: Services in one direction only, then jumps to the beginning without servicing
requests on the return.
SCAN vs C-SCAN:
• C-SCAN: Services in one direction only and goes back to start unserviced, providing
uniform wait time.
In centralized architecture, a single system or server provides services to all users. All
decisions and data are stored in this central node.
Definition:
A Centralized System Architecture is an organizational model in which all processing,
control, and data storage are handled by a single central system (or server), and all user
devices (clients or terminals) rely on it for computing services.
Explanation:
In this architecture:
• Clients are usually simple terminals or thin clients with minimal processing
capabilities.
• All requests, processing, and responses happen through the central system.
Real-World Example:
• Old mainframe systems used in banks or universities, where user terminals were
connected to a powerful central server.
• Modern example: Web-based apps where the logic and data are hosted on a single
centralized cloud server.
Advantages:
2. Centralized control
Disadvantages:
3. Network Dependency
Use Cases:
pgsql
CopyEdit
Users/Clients
| | |
v v v
+-------------------+
| Central Server |
+-------------------+
29. Define:
Seek Time
Seek time is the time it takes for the disk drive’s read/write head to move to the track or
cylinder where the desired data is stored.
Rotational Latency
Rotational latency is the time it takes for the desired sector of the disk to rotate under the
read/write head after the head is in position.
Example: For a disk spinning at 7200 RPM, one full rotation takes ~8.33 ms, so average
rotational latency is ~4.17 ms.
• Resource sharing
• Scalability
• Fault tolerance
When accessing data in a file, the access method defines how the operating system and
application interact with the file contents. Two of the most common file access methods are:
Definition:
• Data is accessed in a linear, sequential order, one record after another.
Characteristics:
• Data must be read or written from the beginning to the desired location.
• Suitable for devices like magnetic tapes or for file types like log files, audio/video
streams.
Example:
CopyEdit
Advantages:
• Simple to implement
• Good for files that are always processed from beginning to end (e.g., media files)
Disadvantages:
Definition:
• Allows reading/writing to any part of the file without reading the data before it.
Characteristics:
• Suitable for databases, ISAM, hard disks, and files that require updates frequently.
Exampl
fseek(file, record_number * sizeof(record), SEEK_SET);
Advantages:
Disadvantages:
• Not all storage devices support direct access (e.g., magnetic tape)
Comparison Table
Mobile Operating Systems (like Android, iOS, KaiOS, HarmonyOS) are designed specifically
for portable, battery-powered, wireless-connected devices such as smartphones, tablets,
and wearables.
Compared to desktop OS, mobile OS must operate under unique constraints and serve
special requirements. Here's a detailed explanation:
• Mobile devices are always connected, making them more vulnerable to attacks.
• Must include:
o Secure boot
o App permissions
o Encrypted storage
• Mobile devices rely on battery power, so the OS must optimize energy use.
• Features include:
o CPU throttling
o Sleep/idle modes
o Cellular (4G/5G)
o Wi-Fi, Bluetooth
o NFC
o Seamless handoff between networks (e.g., from Wi-Fi to mobile data)
4. Real-Time Responsiveness
• Essential for:
o Gaming
o Multimedia streaming
o Real-time messaging
5. Touchscreen-Centric UI
• Includes:
o Notifications
7. Sensor Integration
o Accelerometer
o Gyroscope
o GPS
o Proximity sensor
• Must provide APIs for apps to use these safely and efficiently.
• OS must:
o Backup
o Push notifications
In Summary
Strategy:
The system assigns a global ordering (priority) to all resources. Processes are required to
request resources in increasing order of enumeration. If a process needs multiple resources,
it must request them in the defined order.
Example:
• Suppose the system has resources R1, R2, and R3 with an order: R1 < R2 < R3.
• If a process holds R2, it can only request R3, not R1.
Pros:
• Simple to implement.
Cons:
• Not always practical (especially if the process doesn’t know what resources it will
need in advance).
Strategy:
The system allows resources to be preempted (i.e., taken away) from a process. If a process
holding some resources requests another resource that cannot be immediately allocated,
the system may force it to release its current resources and retry later.
Example:
• Now R1 becomes available to others, and P1 must retry its request sequence later.
Pros:
Cons:
Delivers computing services (storage, servers, networking, software) over the internet.
• On-demand availability
• Scalable
• Pay-as-you-go model
1. Mutual Exclusion
3. No Preemption
4. Circular Wait
Example: Two processes each holding one resource and requesting the other's.
A relative path is a file or directory path related to the current working directory.
Example:
./folder/file.txt (relative to current directory)
1. Contiguous
2. Linked
3. Indexed
Used to avoid deadlocks. Processes declare max resource needs. OS only allocates if system
stays in a safe state.
Steps:
1. Work = Available
• Create/Delete File
• Create/Delete Directory
• Rename
• List contents
• Starvation: Requests far from the current head position may never be served if closer
requests keep arriving.
Problem with SSTF (Shortest Seek Time First) Disk Scheduling Algorithm
SSTF selects the I/O request that is closest to the current head position, minimizing seek
time for each request.
• If new, nearby requests keep coming in, farther requests might never get serviced.
Example:
• If requests keep arriving near 50–60, the 120 request might never be chosen.
2. Unfairness
4. No Real-Time Guarantees
• Real-time systems that require predictable access times may fail under SSTF.
• Head may keep jumping back and forth if new requests appear on either side.
• This leads to increased wear and inefficiency, especially on traditional hard drives.
• While it minimizes the next seek, it doesn’t guarantee the optimal overall schedule
(as compared to algorithms like LOOK or SCAN).
o Process management
o Memory management
o Device drivers
o Power management
o Networking
• A set of C/C++ libraries that provide standard interfaces for hardware vendors.
• Allows the Android system to communicate with hardware devices like camera, GPS,
audio, etc.
a) Native Libraries
• Includes:
o Activity lifecycle
o Window management
o Content providers
o Location services
o Telephony
sql
CopyEdit
|----------------------------------------------------|
| Applications Layer |
|----------------------------------------------------|
|----------------------------------------------------|
|----------------------------------------------------|
|----------------------------------------------------|
|----------------------------------------------------|
|----------------------------------------------------|
|----------------------------------------------------|
The goals of distributed systems are what guide their design and operation. These goals
ensure that the system functions efficiently, reliably, and transparently across multiple
independent components.
1. Transparency
Transparency means hiding the complexity of the distributed nature from users and
applications. There are several types:
Type Description
Access Transparency Users can access remote resources as if they were local.
Location Transparency Users don’t need to know the physical location of a resource.
Failure Transparency The system hides failures and continues to operate smoothly.
2. Scalability
The system must continue to operate correctly even when parts fail. This involves:
4. Performance
The system should provide fast response times and efficient processing by:
6. Resource Sharing
7. Openness (Interoperability)
• Open standards (like TCP/IP, REST, SOAP) help systems communicate smoothly.
Summary Table:
Goal Description
A RAG is a directed graph used to represent the state of resource allocation in a system.
• Nodes:
• Edges:
Example Scenario
Let’s say:
• Processes: P1, P2
Step-by-step Example
1. P1 holds R1 → Edge from R1 → P1 (assignment)
nginx
CopyEdit
P1 → R2
↑ ↓
R1 P2
↑ ↓
P2 → R1
• R1 is assigned to P1 → R1 → P1
• R2 is assigned to P2 → R2 → P2
• P1 is waiting for R2 → P1 → R2
• P2 is waiting for R1 → P2 → R1
Deadlock Detection:
nginx
CopyEdit
P1 → R2 → P2 → R1 → P1
Symbol Meaning
Would you like a visual graph (image or diagram) of this example? I can generate one for
a. Resource Sharing
• Multiple users and systems can share hardware, software, and data across the
network.
b. Scalability
d. Performance
e. Geographic Distribution
g. Flexibility
A deadlock occurs when processes are stuck waiting for resources held by each other, and
none can proceed. Prevention strategies avoid this by breaking one of the deadlock
conditions.
1. Mutual Exclusion
3. No Preemption
4. Circular Wait
• Processes must request resources in increasing order (e.g., R1 < R2 < R3).
c. Eliminate No Preemption
• Not always possible, but where feasible, design resources to be sharable (like read-
only files).
68. Sequential & Direct File Access
These are two file access methods that define how data is read from or written to files on
disk:
1⃣ Sequential Access
Definition:
• Data is accessed in order, one record after another (like reading a tape).
Suitable For:
Advantages:
• Simple to implement.
Disadvantages:
Definition:
• Data can be read or written at any position in the file directly using a position index
or block number.
Suitable For:
Advantages:
Disadvantages:
Disk allocation methods are techniques used by the operating system to allocate disk space
to files stored on a storage device. The goal is to manage space efficiently, avoid
fragmentation, and allow fast access to files.
1⃣ Contiguous Allocation
Definition:
Allocates a single continuous block of space on the disk for each file.
Advantages:
Disadvantages:
• Difficult to grow files – if next blocks are used, file must be moved.
Example:
A 5 3
B 8 2
2⃣ Linked Allocation
Definition:
Each file is a linked list of disk blocks; each block contains data and a pointer to the next
block.
Advantages:
• No fragmentation.
Disadvantages:
Example:
3⃣ Indexed Allocation
Definition:
Each file has its own index block, which contains pointers to all the disk blocks used by the
file.
Advantages:
• No external fragmentation.
Disadvantages:
Example:
5 → 8 → 11 → 14 → 20
Comparison Table:
File Size Limit Limited by space No limit (theoretically) Depends on index size
1. Seek Time
• Definition: Time taken by the disk’s read/write head to move to the track where the
required data is stored.
• Types:
o Full Stroke Seek Time: Time to move from the innermost to the outermost
track.
o Average Seek Time: Typical time taken to locate any random track (commonly
used in specs).
• Definition: Time the disk takes to rotate and position the desired sector under the
read/write head.
• Formula:
• Definition: Rate at which data can be read from or written to the disk.
• Types:
4. Access Time
• Definition: Total time to access data from the disk.
• Formula:
This is the true measure of how long it takes to start reading or writing data.
6. Disk Throughput
• Related to: Transfer rate, file system efficiency, and I/O patterns.
Even though the system consists of multiple separate components, it appears to users and
applications as a single coherent system.
2. Resource Sharing:
Components share hardware (like printers), data (files, databases), or processing
power.
3. Concurrency:
Multiple processes can run simultaneously across different nodes.
4. Scalability:
The system can grow by adding more nodes without much reconfiguration.
5. Fault Tolerance:
If one node fails, others can take over its responsibilities to avoid total system failure.
6. Transparency:
The user does not need to know where services or data are located. This includes:
2. Distributed Architecture:
Resources are spread out across multiple locations but are interconnected through a
network (often the internet).
3. Scalability:
New nodes can easily be added to the grid, allowing it to grow based on demand.
4. Heterogeneity:
Nodes in the grid can have different operating systems, hardware, or configurations.
5. Task Scheduling:
A central system or middleware manages how tasks are broken down and distributed
across the grid.
6. Fault Tolerance:
If one node fails, tasks can be redistributed to other nodes without stopping the
entire process.
5. Results are sent back to the central system and compiled into the final output.
Real-World Examples:
• Scientific Research:
SETI@home (Search for Extraterrestrial Intelligence) used idle home computers to
analyze radio signals from space.
• Medical Research:
Folding@home simulates protein folding to help understand diseases like Alzheimer's
or cancer.
• Finance:
Risk analysis and modeling that require processing vast amounts of data.
• Engineering/Graphics:
Complex 3D rendering for movies or simulations.
Size scalability refers to the ability of a distributed system to grow in size — such as adding
more users, devices, nodes, or services — without degrading performance or reliability.
• Data centers
• Global networks
• Cloud environments
As users and data grow exponentially, systems must be able to scale to handle:
• More requests
• More storage
1. Incremental Growth
o The system should allow adding new resources (e.g., nodes or servers)
without major disruption.
o Example: Adding new servers to a cloud system like AWS or Google Cloud.
2. Load Distribution
3. Decentralized Control
o Finding data or services must remain fast, even as the system grows.
o System performance should not drop sharply when more nodes or clients are
added.
o Example: Adding 1000 users should not make a website 10x slower.
• Horizontal Scaling: Add more machines (not just upgrade existing ones).
Example:
• The system becomes more efficient as it grows — a sign of excellent size scalability.
1. Layered Architecture
Structure:
• System is organized in layers, each layer built upon the one below it.
• Each layer performs specific functions and interacts only with adjacent
layers.
Example Layers:
• Hardware
• Communication
• Middleware
• Services
• Applications
Advantages:
Disadvantages:
2. Client-Server Architecture
Structure:
Example:
• A distributed file system: client requests a file → server delivers the file.
Advantages:
• Simple to implement and understand
• Centralized control and security
• Scalable with added servers
Disadvantages:
• Server can become a bottleneck
• Single point of failure unless redundancy is used
Structure:
• All nodes (peers) are equal, each acting as both client and server.
• No central coordination.
Example:
Advantages:
• Highly scalable
• No central point of failure
• Efficient resource utilization
Disadvantages:
• Complex coordination
• Less control over security and consistency
4. Object-Based Architecture
Structure:
Example:
Advantages:
• Good for complex systems
• Natural mapping with object-oriented design
Disadvantages:
• Communication overhead
• Performance can degrade with many objects
5. Microkernel Architecture
Structure:
Advantages:
• High modularity and security
• Easy to update or replace components
• Better fault isolation
Disadvantages:
The SCAN algorithm, also called the elevator algorithm, moves the disk head in one
direction, servicing all pending requests, and then reverses direction to service requests on
the return path — just like an elevator picking up people going up, then coming back down.
If a request arrives just after the head has passed its position, it must wait until the head
goes to the end and comes back.
Example:
• A request at 49 just arrives — it must wait for the head to reach 199 and return to
49.
When the number of pending requests is small, SCAN may cause the head to move long
distances unnecessarily.
Requests near the ends of the disk (e.g., near cylinder 0 or 199) can get less frequent
service if most requests are near the center.
• These edge requests might be serviced only once every full pass.
• The head travels all the way to the end of the disk, even if there are no requests at
the extreme end.
• This can lead to unnecessary seek time.
LOOK is a better alternative that avoids going to the end if there are no pending requests.
• SCAN's performance can suffer in scenarios where many requests are clustered in
one area.
6. No Priority Handling
• Real-time constraints
• Similar to SCAN, but still may cause unfair wait time to lower-priority requests.
• LOOK is a variant of the SCAN (Elevator) disk scheduling algorithm. In LOOK, the disk
arm only moves as far as the last request in each direction, instead of going all the
way to the end of the disk (like in SCAN).
• The head moves toward the end of the disk but stops at the last request in that
direction.
• It "looks ahead" for pending requests and doesn't go to the disk's physical end unless
there's a request.
• If requests keep coming in the direction the head is moving, requests in the opposite
direction may wait longer.
• LOOK can sometimes lead to unfair scheduling: requests near the current head
position are served faster than those further away.
• Lower-priority requests may experience higher wait time due to the head favoring
nearer or more recent requests.
• Like SCAN, when the head changes direction, it takes extra time to reverse and start
moving the other way.
• In many cases, C-LOOK provides better performance because it eliminates the back-
and-forth motion and provides a more uniform wait time.
• LOOK may result in slightly longer average seek times compared to C-LOOK in large
queue systems.
• Unlike SCAN, which simply goes to the end, LOOK requires the system to check for
pending requests in the direction before moving.
•
79. Banker's Algorithm Example
Given:
• Use algorithm to find if system is in safe state (Let me know if you'd like a solved
numerical example!)
• FCFS: 10 → 22 → 20 → 2 → 40
Let me know if you'd like illustrated diagrams, examples, or help solving Banker's algorithm
or disk scheduling problems!
4o
You said:
yes
ChatGPT said:
1. Banker’s Algorithm
2. Disk Scheduling Algorithms (for FCFS, SSTF, SCAN, LOOK, C-SCAN, C-LOOK)
Given:
Process Max Allocation Need
P0 753010 743
P1 322200 122
P2 902302 600
P3 222211 011
P4 433002 431
Available Resources: 3 3 2
Start:
• Work = Available = (3 3 2)
Step-by-step:
Safe Sequence: P1 → P3 → P0 → P2 → P4
a) FCFS (First-Come-First-Serve)
Steps:
1. From 53 → 65 (12)
2. From 65 → 67 (2)
3. From 67 → 37 (30)
4. From 37 → 14 (23)
5. From 14 → 98 (84)
6. 98 → 122 (24)
Movement:
= |53-37| + |37-14| + |14-0| + |0-65| + |65-67| + |67-98| + |98-122| + |122-124| + |124-
183|
= 16 + 23 + 14 + 65 + 2 + 31 + 24 + 2 + 59 = 236 cylinders
d) LOOK
Go only as far as the last request in each direction (no edge of disk).
Descending first: 53 → 37 → 14
Then reverse: 65 → 67 → 98 → 122 → 124 → 183
e) C-SCAN
Movement:
= (65-53) + (67-65) + (98-67) + (122-98) + (124-122) + (183-124) + (199-183) + (199-0) + (14-
0) + (37-14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 23 = 382 cylinders
f) C-LOOK
Movement =
12 + 2 + 31 + 24 + 2 + 59 + (183-14) + 23 = 273 cylinders
1.