OS Important M-4
OS Important M-4
rd
3 SEM Exam – Important Questions
MODULE – 4
Paging is a memory management scheme used in operating systems to divide a process's logical
address space into fixed-sized blocks called pages. These pages are of equal size and are mapped
to physical frames in main memory. Paging provides a simple and efficient way to manage memory
by allowing processes to be allocated memory in smaller, fixed-size units.
Structure of the Page Table:
The structure of the page table varies depending on the memory management technique used.
Here are the most common techniques for structuring the page table:
Hierarchical Paging:
1. Problem Solving:
Divides large page tables into smaller pieces to manage the excessively large logical-address
space.
2. Multi-Level Hierarchy:
Utilizes a multi-level hierarchy where each level contains page table entries.
3. Reduced Memory Overhead:
Decreases memory overhead by storing only the necessary portions of the page table.
4. Address Space Management:
Facilitates efficient management of large address spaces by organizing page tables hierarchically.
5. Improved Access Time:
Enhances access time by allowing for faster retrieval of page table entries through the hierarchical
structure.
6. Scalability:
Offers scalability to handle increasingly large logical address spaces by dividing the page table
into smaller, manageable pieces.
Hashed Page-tables:
1. Memory Partitioning:
Main memory is divided into two partitions: one for the operating system (OS) and the
other for user processes.
2. Single Contiguous Section:
Each process occupies a single contiguous section of memory, ensuring efficient memory
management.
3. Memory Protection:
Memory protection is crucial to prevent user processes from accessing the OS and each
other's memory areas.
Implemented using relocation and limit registers:
Relocation register stores the smallest physical address.
Limit register defines the range of logical addresses accessible to a process.
4. Dynamic Address Mapping:
Memory Management Unit (MMU) dynamically maps logical addresses by adding the
value in the relocation register.
Ensures that each logical address falls within the defined limit register range.
5. CPU Scheduler Interaction:
When a process is chosen for execution, the dispatcher sets the relocation and limit
registers with appropriate values.
This mechanism protects the OS from the executing process by checking addresses against
these registers.
6. Dynamic OS Size:
The relocation-register scheme enables the OS size to change dynamically as needed.
Facilitates efficient memory utilization by allowing transient OS code to load and unload as
necessary.
7. Transient OS Code:
Transient OS code refers to code that is loaded and unloaded as required to conserve
memory space and reduce unnecessary swapping overhead.
Advantages:
Disadvantages:
1. Fragmentation Concerns:
Contiguous memory allocation may lead to fragmentation issues, particularly external
fragmentation, which can reduce memory utilization efficiency.
2. Limited Scalability:
This approach may have limitations in handling dynamic memory requirements and
variable-sized memory allocations, affecting system scalability.
3. Complexity with Memory Protection:
While relocation and limit registers offer memory protection, managing and updating
these registers for multiple processes may introduce complexity and overhead.
6.What is demand paging? Discuss with a neat diagram. Steps to handle the page fault
Ans:
Demand Paging:
Explanation:
In demand paging, the entire program or process does not need to be loaded into
memory before execution begins. Instead, only the necessary portions, typically
referred to as pages, are loaded into memory when required. This approach
optimizes memory usage by minimizing the amount of memory needed to initiate
program execution.
• Basic concept: Instead of swapping the whole process the pager swaps only the necessary
pages in to memory. Thus it avoids reading unused pages and decreases the swap time and
amount of physical memory needed
The steps to handle the page faults with neat diagram.
[For Reference]
File Attributes:
1. Name: The name of the file, which uniquely identifies it within a directory.
2. Type: The type of the file, which determines its format and how it can be interpreted
by applications (e.g., text file, image file, executable file).
3. Location: The location of the file in the file system, specified by its path.
4. Size: The size of the file in bytes, indicating the amount of data it contains.
5. Timestamps:
Creation Time: The time when the file was created.
Last Modified Time: The time when the file's contents were last modified.
Last Accessed Time: The time when the file was last accessed or read.
6. Permissions: The access permissions associated with the file, specifying which users
or groups are allowed to read, write, or execute the file.
7. Owner: The user or group that owns the file and has certain rights over it, such as
changing permissions or deleting the file.
File Operations:
1. Sequential Methods:
Simplest access method where information in the file is processed in order, one
record after another.
Read operations (next-reads) retrieve the next portion of the file, automatically
advancing a file pointer.
Write operations (write next) append data to the end of the file, advancing to the end
of the newly written material.
Allows resetting the file to the beginning and potentially skipping forward or
backward by a specified number of records.
2. Direct Access:
Utilizes fixed-length logical records for rapid reading and writing of records in any
order.
Views the file as a numbered sequence of blocks or records, akin to a disk model,
enabling random access.
Allows reading or writing blocks in any order, facilitating immediate access to large
amounts of data, such as databases.
Requires modifications to file operations to include block numbers as parameters,
replacing read next and write next with read n and write n.
3. Other Access Methods:
Constructed on top of direct access, typically involving the creation of an index for
the file.
The index functions like a book index, containing pointers to various blocks within
the file.
To locate a record, first search the index and then use the pointer to directly access
the desired record within the file.
1. Sequential Methods:
Read one after another.
Reading/writing in a fixed order.
Can reset to start or skip ahead.
Useful for processing data in order.
Operations: Read next, write next.
2. Direct Access:
Read/write in any order.
Treats file like numbered blocks.
No restriction on reading or writing order.
Suitable for quick access to large data.
Operations: Read block number, write block number.
3. Other Access Methods:
Built on direct access.
Involves creating an index.
Index points to different blocks.
Helps in finding records quickly.
Search index first, then access record.
10.What is thrashing? How it can be controlled?
Ans:
Thrashing:
1. Definition:
Thrashing occurs when a computer's operating system spends a significant amount of
time swapping data between memory (RAM) and storage (disk), instead of executing
useful tasks.
2. Causes:
Insufficient physical memory to accommodate the working set of active processes.
High demand for memory by multiple processes, leading to excessive paging activity.
Ineffective memory management policies or allocation strategies.
3. Symptoms:
Severe degradation in system performance.
Excessive disk activity as the system continuously swaps data between RAM and disk.
Increased response time for user interactions and application execution.
System becomes unresponsive or slow to execute tasks.
Controlling Thrashing - Simple Points: