OS Mini
OS Mini
2
in the ready queue. Proper scheduling not only increases
system performance but also enhances user experience
by minimizing wai ng me and response delays. Here's
a detailed look at some widely-used scheduling
algorithms, their characteris cs, and their applicability in
different scenarios.
effect.
Suitability:
o Best suited for batch systems or applications that
3
execution. It can operate in preemptive mode (Shortest
Remaining Time First, SRTF) or non-preemptive mode.
Characteristics:
o Minimizes average waiting time, making it optimal
in theory.
o It requires knowledge of process burst times
workloads.
Disadvantages:
o Difficult to implement in real-world scenarios due
mechanisms.
Suitability:
o Ideal for systems with batch jobs or predictable
4
A small quantum increases context-switching
overhead.
A large quantum behaves like FCFS.
Advantages:
o Prevents starvation, ensuring all processes get CPU
time.
o Ideal for interactive systems, providing a sense of
responsiveness to users.
Disadvantages:
o Overhead due to frequent context switching if the
Advantages:
o Allows prioritization of critical or time-sensitive
tasks.
Disadvantages:
o Starvation issues can arise unless aging is
5
Processes are divided into multiple queues based on
characteristics like priority or type (foreground vs.
background). Each queue can use a different scheduling
algorithm.
Characteristics:
o A hybrid approach combining multiple scheduling
techniques.
o Queues are managed separately, with priorities
Disadvantages:
o Complex implementation and management.
Suitability:
o Useful in mixed environments with diverse
deallocation.
3. Supports Virtual Memory:
o Paging enables the use of disk storage as an
wasted space.
2. Translation Overhead:
o Address translation using page tables introduces
9
1. Logical Representation:
o Segments align with the logical structure of
memory.
3. Protection and Sharing:
o Different segments can have different access
10
mechanisms to allocate and access the actual data stored on
the disk. Examples include FAT32, NTFS, EXT4, and APFS.
A critical aspect of a file system is its file allocation method,
which determines how files are stored on the disk. Efficient
allocation is crucial for fast access, optimal disk space usage,
and minimizing fragmentation.
File Allocation Methods
The most common file allocation methods are contiguous
allocation, linked allocation, and indexed allocation. Each
has its own approach to organizing file data on storage, along
with associated benefits and drawbacks.
1. Contiguous Allocation
In contiguous allocation, a file is stored in consecutive
blocks on the disk. The file system needs to know the starting
block and the file's size for access.
Advantages:
Fast Access: Since the blocks are stored sequentially,
reading a file is very efficient, as the disk head doesn’t
need to move much.
Simplicity: Easy to implement as it requires minimal
metadata—just the starting block and file size.
Disadvantages:
External Fragmentation: Over time, free blocks can
become scattered, making it difficult to find contiguous
space for new files.
Dynamic File Sizes: If a file grows beyond its allocated
blocks, it may need to be relocated entirely, causing
overhead.
11
Poor Space Utilization: Due to fragmentation, disk
space may be wasted despite having free blocks.
Use Case: Contiguous allocation is suitable for systems where
file sizes are predictable and do not change, like CD-ROMs or
multimedia storage.
2. Linked Allocation
In linked allocation, each file is a linked list of disk blocks.
Each block contains a pointer to the next block in the
sequence. The directory entry only stores the address of the
first block.
Advantages:
No External Fragmentation: As files do not need
contiguous storage, any free block on the disk can be
used.
Flexible File Sizes: Files can easily grow or shrink as
needed, with new blocks simply appended to the chain.
Disadvantages:
Slow Random Access: To access a specific block, the
system must traverse the pointers sequentially, which is
inefficient for large files.
Pointer Overhead: Each block requires space for a
pointer, reducing the amount of usable disk space.
Reliability Issues: If a pointer becomes corrupted, the
rest of the file may become inaccessible.
Use Case: Linked allocation works well for sequential access
patterns, such as log files or backup systems.
3. Indexed Allocation
12
In indexed allocation, a separate block, called an index
block, stores pointers to all the blocks containing the file's
data. The directory entry stores the address of the index block.
Advantages:
Direct Access: Allows for fast random access, as the
system can directly retrieve any block by looking up the
index.
No External Fragmentation: Blocks do not need to be
contiguous, and any free block can be used.
Efficient Growth: Files can grow dynamically without
relocation.
Disadvantages:
Overhead of Index Blocks: Storing the index block for
every file consumes additional disk space.
Limited File Size: The number of blocks a file can use is
limited by the size of the index block (though this can be
mitigated by multi-level indexing).
Use Case: Indexed allocation is ideal for systems requiring
random access and efficient file growth, like general-purpose
operating systems (e.g., Linux EXT4 or NTFS).
---------------------------------------------------------------------------
-------------------------------------
6. Difference between program and Process.
Program Process
The process is an
The program contains a
instance of an executing
set of instructions
program.
13
Program Process
designed to complete a
specific task.
14
Program Process
In addition to program
data, a process also
The program has two
requires additional
logical components: code
information required for
and data.
the management and
execution.
The process is a
Program contains
sequence of instruction
instructions
execution.
15
Key Functions of the Kernel
1. Process Management:
o Manages the creation, scheduling, and termination
of processes.
o Ensures fair CPU time allocation using scheduling
algorithms.
2. Memory Management:
o Allocates memory to processes and deallocates it
after use.
o Implements virtual memory and paging mechanisms
operations.
4. File System Management:
o Handles file operations like reading, writing, and
directory creation.
o Organizes files in structured formats like FAT,
NTFS, or EXT4.
5. System Security and Access Control:
o Ensures that unauthorized programs do not access
6. Interrupt Handling:
o Responds to hardware or software-generated
interrupts.
o Ensures the system remains responsive under high
16
8. What is scheduling policies? FCFS and round robin
policies.
Scheduling Policies
Scheduling policies are strategies used by operating systems
to manage the execution of processes by the CPU. These
policies are crucial in determining the order of process
execution, optimizing CPU utilization, and ensuring fairness,
responsiveness, and efficiency. A good scheduling policy
aims to minimize waiting time, turnaround time, and response
time while maximizing throughput.
Two commonly used scheduling policies are First-Come,
First-Served (FCFS) and Round Robin (RR). Both have
distinct characteristics, advantages, and drawbacks, making
them suitable for different scenarios.
First-Come, First-Served (FCFS) Scheduling Policy
Definition
FCFS is the simplest scheduling policy where processes are
executed in the order of their arrival in the ready queue. The
17
process that arrives first is executed first and runs to
completion before the next process begins.
Characteristics:
1. Non-preemptive: Once a process starts execution, it
cannot be interrupted until it finishes.
2. Queue-Based: Operates like a standard FIFO (First-In-
First-Out) queue.
Advantages:
1. Simplicity:
o Easy to implement as it requires minimal system
overhead.
2. Predictable Behavior:
o Processes are executed in the order they arrive,
2. Cyclic Execution:
o Processes are executed in a cyclic manner, giving
20