Week 10 Os
Week 10 Os
First-Fit Algorithm:
Process 212k: Placed in the 500k partition (remaining: 500k - 212k = 288k)
Process 417k: Placed in the 600k partition (remaining: 600k - 417k = 183k)
Process 112k: Placed in the 200k partition (remaining: 200k - 112k = 88k)
Process 426k: Cannot be placed in any available partition
Best-Fit Algorithm:
Process 212k: Placed in the 300k partition (remaining: 300k - 212k = 88k)
Process 417k: Placed in the 600k partition (remaining: 600k - 417k = 183k)
Process 112k: Placed in the 100k partition (remaining: 100k - 112k = -12k, with
internal fragmentation)
Process 426k: Cannot be placed in any available partition
Worst-Fit Algorithm:
Process 212k: Placed in the 600k partition (remaining: 600k - 212k = 388k)
Process 417k: Placed in the 600k partition (remaining: 600k - 417k = 183k)
Process 112k: Placed in the 500k partition (remaining: 500k - 112k = 388k)
Process 426k: Placed in the 600k partition (remaining: 600k - 426k = 174k)
Among the three algorithms, the Best-Fit algorithm makes the most efficient use
of memory. It selects the partition that minimizes internal fragmentation by
finding the closest fit to the size of the process.
The logical address consists of two components: the page number and the offset
within the page. The page number is used as an index into the page table, which
is a data structure maintained by the operating system. The page table contains
the base address of each page in physical memory.
mathematica
Copy code
+------------------------+
| Page Table |
+------------------------+
| Page Number | Frame Number |
+------------------------+
| ... | ... |
+------------------------+
| Page Number | Frame Number |
+------------------------+
The frame number obtained from the page table is combined with the offset to
form the physical address, which represents the actual location in physical
memory where the data resides.
The Translation Lookaside Buffer (TLB) is a hardware cache that stores recently
used page table entries. Its purpose is to improve the efficiency of the address
translation process by reducing the number of memory accesses required.
The TLB is a small, high-speed memory located between the CPU and the page
table. It holds a subset of the page table entries that have been recently
accessed. Each entry in the TLB contains a page number, frame number, and
additional control bits.
When a process generates a logical address, the TLB is first checked. If the
page number is found in the TLB, it is referred to as a TLB hit, and the
corresponding frame number is retrieved. This avoids the need to access the page
table, saving time and improving performance.
If the page number is not found in the TLB, it is referred to as a TLB miss. In
this case, the page table must be accessed to retrieve the frame number, and the
TLB is updated with the new entry for future reference.
The TLB uses a cache replacement algorithm (such as Least Recently Used) to
manage its limited size. When the TLB becomes full, the least recently used
entry is evicted to make room for a new entry.
External fragmentation is a memory management issue that occurs when free memory
blocks are scattered throughout the system, making it difficult to allocate
contiguous blocks of memory to satisfy process memory requests. It can lead to
inefficient memory utilization and can limit the ability to allocate larger
processes.
Identify the locations of allocated and free memory blocks in the system.
Determine the total amount of free memory available.
Move the allocated processes as close together as possible, eliminating any gaps
between them.
Slide the free memory blocks towards one end of the memory, consolidating them
into a single