Unit 4 Answer Key
Unit 4 Answer Key
Unit 4 Answer Key
The difference between memory The unused spaces formed between non-contiguous
allocated and required space or memory memory fragments are too small to serve a new
5. is called Internal fragmentation. process, which is called External fragmentation.
Advantages:
Easy to implement
Little OS overhead
Disadvantages:
Internal Fragmentation
External Fragmentation
It is a part of Contiguous allocation technique. It is used to alleviate the problem faced by Fixed Partitioning. In contrast with
fixed partitioning, partitions are not made before the execution or during system configure.
Initially RAM is empty and partitions are made during the run-time according to process’s need instead of
partitioning during system configure.
Number of partitions in RAM is not fixed and depends on the number of incoming
Advantages:
No Internal Fragmentation
Disadvantages
Difficult Implementation
External Fragmentation
The mapping from virtual to physical address is done by the memory management unit (MMU) which is a hardware
device and this mapping is known as paging technique.
The Physical Address Space is conceptually divided into a number of fixed-size blocks, called frames.
The Logical address Space is also spitted into fixed-size blocks, called pages.
Page number(p): Number of bits required to represent the pages in Logical Address Space or Page number
Page offset(d): Number of bits required to represent a particular word in a page or page size of Logical Address
Space or word number of a page or page offset.
Frame number(f): Number of bits required to represent the frame of Physical Address Space or Frame number frame
Frame offset(d): Number of bits required to represent a particular word in a frame or frame size of Physical Address
= 1 K words (assumption)Space or word number of a frame or frame offset.
Initially, all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults
0 is already there so —> 0 Page fault. when 3 came it will take the place of 7 because it is not used
for the longest duration of time in the future.—>1 Page fault. 0 is already there so —> 0 Page
fault. 4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are already available in the
memory.
Optimal page replacement is perfect, but not possible in practice as the operating system cannot
know future requests. The use of Optimal Page replacement is to set up a benchmark so that other
replacement algorithms can be analyzed against it.
3. Least Recently Used: In this algorithm, page will be replaced which is least recently used.
Example-3: Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4 page
frames. Find number of page faults.
B) Solve by using LRU page replacement algorithm.
Initially, all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults
0 is already their so —> 0 Page fault. when 3 came it will take the place of 7 because it is least
recently used —>1 Page fault
0 is already in memory so —> 0 Page fault.
4 will takes place of 1 —> 1 Page Fault
Now for the further page reference string —> 0 Page fault because they are already available in the
memory.
36. Explain the concept of paging. How does it work, and what are its
advantages and disadvantages?
Paging is a memory management scheme that eliminates the need for contiguous allocation of
physical memory. This scheme permits the physical address space of a process to be non –
contiguous.
The mapping from virtual to physical address is done by the memory management unit
(MMU) which is a hardware device and this mapping is known as paging technique.
The Physical Address Space is conceptually divided into a number of fixed-size blocks,
called frames.
The Logical address Space is also spitted into fixed-size blocks, called pages.
Page Size = Frame Size
Page number(p): Number of bits required to represent the pages in Logical Address Space or
Page number
Page offset(d): Number of bits required to represent a particular word in a page or page size of
Logical Address Space or word number of a page or page offset.
Frame number(f): Number of bits required to represent the frame of Physical Address Space
or Frame number frame
Frame offset(d): Number of bits required to represent a particular word in a frame or frame
size of Physical Address Space or word number of a frame or frame offset.
Paging Hardware
Every address generated by CPU mainly consists of two parts:
1. Page Number(p)
where,
Page Number is used as an index into the page table that generally
contains the base address of each page in the physical memory.
Page offset is combined with base address in order to define the physical
memory address which is then sent to the memory unit.
If the size of logical address space is 2 raised to the power m and page
size is 2 raised to the power n addressing units then the high order m-n bits
of logical address designates the page number and the n low-order bits
designate the page offset.
where p indicates the index into the page table, and d indicates the
displacement within the page. The Page size is usually defined by the hardware.
The size of the page is typically the power of 2 that varies between 512 bytes and
16 MB per page.
Assuming main memory size 16 KB and frame size is 1 KB hence the main
memory will be parted/divided into the collection of 16 frames of 1 KB each.
There are 4 processes in the system that is P1, P2, P3 and P4 having 4 KB each.
Each process is parted/divided into pages of 1 KB each by which one page can
be stored in one frame.
Initially, all the frames are empty therefore pages of the processes will get
stored in the contiguous way.
We can see in following diagram, frames, pages and the mapping between the
two.
Analyze the basic concept of segmentation in detail.
Assuming that, P2 and P4 are moved to waiting state after some time. Now, 8
frames become empty and hence other pages can be loaded in that empty place.
The process P5 of size 8 KB i.e.-of 8 pages is waiting inside the ready queue.
37
Analyze the
Analyze the basic
basic concept
concept of segmentation
of segmentation in detail.in detail.
Characteristics-
In segmentation, secondary memory and main memory are divided into partitions of unequal
size.
The size of partitions depend on the length of modules.
The partitions of secondary memory are called as segments.
Example” Segment Table- table that stores the information about each
segment of the process.
segment table.
38. Develop the following algorithms for Contiguous Memory Allocation for
the given input:First Fit , Best Fit and Worst Fit
Block Size[] = {100, 500, 200, 300, 600}
Process Size[] = {212, 417, 112, 426}
First-Fit Memory Allocation : First job claims the first available memory with space
more than or equal to it’s size.
Input : blockSize[] = {100, 500, 200, 300, 600};
processSize[] = {212, 417, 112, 426};
Output:
Process No. Process Size Block no.
1 212 2
2 417 5
3 112 2
4 426 Not Allocated
Best-Fit Memory Allocation: closest-fitting free partition in the memory
Input : blockSize[] = {100, 500, 200, 300, 600};
processSize[] = {212, 417, 112, 426};
Output:
Process No. Process Size Block no.
1 212 4
2 417 2
3 112 3
4 426 5
Worst-Fit Memory Allocation: always search for the largest hole/partition, and then
the
process is placed
Input : blockSize[] = {100, 500, 200, 300, 600};
processSize[] = {212, 417, 112, 426};
Output:
Process No. Process Size Block no.
1 212 5
2 417 2
3 112 5
4 426 Not Allocated
39.What is MMU? Describe the role of MMU in mapping logical address to
physical address?
The physical hardware of a computer that manages its virtual memory and caching functions is called
the memory management unit (MMU). The MMU is sometimes housed in a separate Integrated Chip
(IC), but it is typically found inside the central processing unit (CPU) of the computer. The MMU
receives all inputs for data requests and decides whether to retrieve the data from ROM or RAM
storage.
The process requires physical memory to run because the logical address is a virtual address. The
Physical Address is never utilised by the User. The Memory Management Unit (MMU) maps the
logical address that the user programme creates to the physical address. Important Points about
Logical and Physical Addresses in Operating Systems
The use of logical addresses provides a layer of abstraction that allows processes to access
memory without knowing the physical memory location.
Logical addresses are mapped to physical addresses using a page table. The page table
contains information about the mapping between logical and physical addresses.
The MMU translates logical addresses into physical addresses using the page table. This
translation is transparent to the process and is performed by hardware.
The use of logical and physical addresses allows the operating system to manage memory
more efficiently by using techniques such as paging and segmentation.
A) Compare and contrast paging and segmentation.(4M)
Logical Address Space is set of all logical Physical Address is set of all physical
Address
addresses generated by CPU in reference to addresses mapped to the corresponding
Space
a program. logical addresses.
User can view the logical address of a User can never view physical address of
Visibility
program. program.
The user can use the logical address to The user can indirectly access physical
Access
access the physical address. address but not directly.
Editable Logical address can be change. Physical address will not change.
3. Page size is determined by hardware. Here, the section size is given by the user.
5. Paging could result in internal fragmentation. Segmentation could result in external fragmentation.
Paging comprises a page table which encloses the base While segmentation also comprises the segment table which encloses segment number and
7.
address of every page. segment offset.
8. Page table is employed to keep up the page data. Section Table maintains the section data.