Logo/
Sai sanjana Reddy

Shared by Sai sanjana Reddy

Log in

Make a lecture like this from your own PDF

Drop a PDF, slides or notes here. You'll sign up, then yours starts.

0:00 / 3:30

0:00 / 3:30Memory Allocation
First Fit, Best Fit and Worst Fit Memory Allocation
Sai sanjana Reddy

Shared by Sai sanjana Reddy

Summary

Full transcript

0:00Memory allocation is the process of assigning available memory space to processes that need to run. When several free blocks are available, the operating system needs a rule for choosing one. In this lesson, we compare three rules: First Fit chooses the first suitable block, Best Fit chooses the smallest suitable block, and Worst Fit chooses the largest suitable block. We will use the same process and the same original memory blocks for each strategy, so the differences in their decisions are easy to see.

0:29Here is the fixed example. The free memory blocks are B1 = 100 KB, B2 = 500 KB, B3 = 200 KB, B4 = 300 KB, and B5 = 600 KB. The processes are P1 = 212 KB, P2 = 417 KB, P3 = 112 KB, and P4 = 426 KB. For the demonstrations, we focus on P1, which requires 212 KB. No allocation has occurred yet, and each strategy starts from these original free-block values.

1:11First Fit examines the blocks from the beginning of the list. P1 needs 212 KB, so B1 = 100 KB is too small. The scan continues to B2 = 500 KB, which is suitable because it can hold 212 KB. First Fit stops immediately at this first suitable block. Therefore, the allocation is P1 → B2. The important point is that First Fit does not compare every possible block after finding a valid choice.

1:41Now reset the memory to the original free-block values. Best Fit does not stop at the first valid choice. For P1 = 212 KB, the suitable candidates are B2 = 500 KB, B4 = 300 KB, and B5 = 600 KB. Best Fit compares these candidates and selects the smallest suitable block. Among 500 KB, 300 KB, and 600 KB, the smallest is B4 = 300 KB. Therefore, the result is P1 → B4.

2:16Reset the memory blocks again to their original values. Worst Fit considers the same suitable candidates for P1: B2 = 500 KB, B4 = 300 KB, and B5 = 600 KB. This time, the rule is to choose the largest suitable block. Of the three candidates, B5 = 600 KB is largest. The resulting allocation is P1 → B5. Thus, Best Fit and Worst Fit inspect the same candidates, but apply opposite size preferences.

2:48Using the same P1 = 212 KB and the same original free blocks, the three strategies produce different choices. First Fit selects the first suitable block, so P1 goes to B2 = 500 KB. Best Fit selects the smallest suitable block, so P1 goes to B4 = 300 KB. Worst Fit selects the largest suitable block, so P1 goes to B5 = 600 KB. Remember the rule first, smallest suitable, and largest suitable. Thank you for learning. References: the provided memory-allocation source. AI TOOL USED: CapCut AI Video Generator and AI Voice-over.

Ask AI about this video

Answers cite the source. Free account, no credit card.