Operating System 1 : Chapter 5 : EXAM PREPARATION : TYBCS : SPPU

 Chapter 5 Memory Management

1 mark


e) What do you mean by page hit?

Answer: A page hit occurs when a requested page is already present in the main memory (RAM). It indicates that the required data or instruction is available in the current working set, resulting in faster access times.


j) What is virtual memory?

Answer:  Virtual memory is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates an "illusion" to users of a very large (main) memory."


f) What is physical address space?

Answer: The physical address space refers to the actual locations in the physical memory (RAM) where data is stored. It represents the range of memory addresses directly accessible by the computer's hardware.


h) What is page?

Answer: In virtual memory systems, a page is a fixed-length contiguous block of virtual memory. It serves as the smallest unit of data that can be transferred between the main memory (RAM) and secondary storage, such as a hard disk.


(e) Define cache memory.

Answer: Cache memory is a small-sized, high-speed type of volatile computer memory that provides high-speed data access to a processor and stores frequently used computer programs, applications, and data.


4 mark


(b) What is role of valid and invalid bit in demand paging ?

Answer: Definition: In demand paging, the valid and invalid bits are used to track the status of pages in the page table.


Valid Bit:

Functionality: The valid bit acts like a flag that tells us whether a particular page is currently residing in the main memory (RAM) or not.


Representation: If the valid bit is set to 1, it means the page is already in RAM, and you can directly access it without the need to bring it in from secondary storage (like a hard disk).


Invalid Bit:

Functionality: The invalid bit is like another flag, but it indicates the opposite – it tells us if a page is currently not in the main memory.


Representation: If the invalid bit is set to 0, it means the page is not in RAM, and you would need to bring it in from secondary storage. This process is usually triggered by a page fault.


Role :

Valid and invalid bits aid in efficient use of memory by determining which pages are resident in RAM.

Help manage the demand-paging mechanism, optimizing the transfer of pages between main memory and secondary storage.



(iii) Write benefits of virtual machine. [2]

Answer: Benefits of Virtual Machine:


1) Resource Isolation : Virtual machines provide a level of isolation, allowing multiple operating systems or applications to run independently on the same physical hardware.

2) Hardware Independence : Virtual machines abstract hardware, making applications less dependent on specific hardware configurations and facilitating portability.

(i) List various dynamic allocation memory management methods. 

Answer: 

First Fit : Allocates the first available block that is large enough for the requested size.

Best Fit : Allocates the smallest available block that satisfies the request.

Worst Fit : Allocates the largest available block, potentially leading to fragmentation.

Next Fit : Similar to first fit but starts searching from the last allocated block.


c) List out functions of memory management.

Answer: Address Mapping : Translate logical addresses to physical addresses.

Allocation : Assign memory portions to processes.

Deallocation : Free up memory resources when processes release them.

Protection : Prevent unauthorized access to memory regions.

Sharing : Enable shared access to specific memory areas.


d) Explain paging in brief.

Answer:  Explanation:


Definition : Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory.

Page Size : Memory is divided into fixed-size pages, and processes are divided into corresponding fixed-size page frames.

Page Table : A page table is used to map logical addresses to physical addresses.


Advantages: 

1) Reduces External Fragmentation: External fragmentation occurs when memory becomes scattered, leaving small pockets of unusable space. Paging organizes memory into fixed-size blocks (pages), reducing scattered gaps and minimizing external fragmentation.



2) Allows for Non-Contiguous Memory Allocation: Unlike older systems that required continuous memory blocks, paging enables the allocation of memory in non-contiguous segments. Each program or process can be divided into pages and stored wherever there is available space.



Q. What is advantage of paging with segmentation model.

Answer: 

Advantage of Paging with Segmentation Model:


1) Explanation: Combining paging and segmentation in memory management offers the benefits of both approaches.

2) Paging Benefit (a): Reduces external fragmentation by organizing memory into fixed-size pages.

Segmentation Benefit (b): Provides a logical structuring of memory based on segments for different program components.

Combined Advantage (c): Enables efficient use of memory by reducing fragmentation while offering a flexible and logical organization for programs.

3) Example : Think of it as having book chapters (segments) organized in a structured way (segmentation) within a fixed-size notebook (paging).



b) Write short note on logical address and physical address binding with diagram


c) Consider a reference string 3,2,1,0,3,2,4,3,2,1,0,4 No. of frames = 3. Find out the number of page faults using i) LRU ii) OPT.


c) Consider the following reference string and find out the total number of page faults using OPT and FIFO. Assume no of frames are 3 1,2,3,4,2,1,5,6,2,1,2,3,7,6,3,2,1,2,3


b) Describe segmentation in detail.

Answer: 

Explanation:

Segmentation divides memory into logical segments based on program structure, fostering modular program design.


Components:

Each segment represents a functional unit (code, data, stack), enhancing program organization.


Advantages:

Facilitates modular program design, easy sharing of code/data, and provides protection mechanisms.


 Challenges:

May lead to fragmentation, both internal and external, which must be managed.




(iii) What is page table ? What are its contents ? [2]

Answer: Page Table : A data structure used in virtual memory systems.

Contents :

-Page Number : Maps to logical page numbers.

-Frame Number : Corresponding physical frame location.

-Valid Bit : Indicates whether the page is in RAM.

-Protection Bits : Specify read/write/execute permissions.


(b) Write a note on segmentation hardware. 

Answer: 


(c) Explain the indexed allocation and linked allocation method of disk space management.



 (a) What is Fragmentation ? Explain types of fragmentation with suitable example.

Answer: Fragmentation refers to the phenomenon where unallocated memory exists, affecting system efficiency by creating unused or scattered spaces in the memory structure.


Q. Explain internal and external fragmentation in detail.

Answer: 

Types of Fragmentation:

1) Internal Fragmentation:

Definition: Internal fragmentation occurs within allocated memory blocks, leading to wasted space.

Explanation: When a memory block is allocated to a process, it may be larger than the actual data it contains. As a result, the extra space within the block, although allocated, remains unused.

Example: Imagine a scenario where a file system allocates a fixed-size block of 8 KB for each file, but a file only requires 5 KB. The remaining 3 KB within the block is wasted, contributing to internal fragmentation.


2) External Fragmentation:

Definition: External fragmentation involves unallocated spaces scattered throughout the memory, making it challenging to use the memory efficiently.

Explanation: Over time, as processes are allocated and deallocated memory, small gaps or blocks of unused memory are left scattered across the system. These small spaces, individually insufficient to fulfill the memory requirements of new processes, collectively contribute to external fragmentation.

Example: Picture a memory layout where small gaps exist between allocated blocks of memory. If a new process needs a space larger than any of these gaps but smaller than the total available memory, it cannot be accommodated due to the scattered nature of the free spaces, leading to inefficient memory usage.


(b) What is external fragmentation ? What are various ways to avoid external fragmentation ?