A computer has 1000 K of main memory. The jobs arrive and finish in th...
First Fit
- In the First Fit memory allocation algorithm, the operating system allocates the first available block that is large enough to accommodate a job.
- This means that the system will allocate the job to the first hole in memory that is big enough to hold it.
- In the given sequence of jobs and memory requirements, Job 1 arrives first and requires 200 K of memory.
- Since there is no allocated memory yet, Job 1 is allocated the first available block of 200 K in the main memory.
- Job 2 arrives next and requires 350 K of memory. This job is allocated the next available block of 350 K in the memory.
- Job 3 arrives and requires 300 K of memory. It is allocated the next available block of 300 K in memory.
- Job 1 finishes, and its previously allocated block of 200 K becomes available.
- Job 4 arrives and requires 120 K of memory. The First Fit algorithm will allocate this job to the first available block that is large enough to hold it. In this case, it will allocate the job to the 200 K block previously allocated to Job 1.
- Job 5 arrives and requires 150 K of memory. It is allocated the next available block of 150 K in memory.
- Job 6 arrives and requires 80 K of memory. It is allocated the next available block of 80 K in memory.
Best Fit
- In the Best Fit memory allocation algorithm, the operating system allocates the smallest available block that is large enough to accommodate a job.
- This means that the system will search for the smallest hole in memory that is big enough to hold the job and allocate it there.
- In the given sequence of jobs and memory requirements, Job 1 arrives first and requires 200 K of memory.
- Since there is no allocated memory yet, Job 1 is allocated the first available block of 200 K in the main memory.
- Job 2 arrives next and requires 350 K of memory. This job is allocated the next available block of 350 K in the memory.
- Job 3 arrives and requires 300 K of memory. It is allocated the next available block of 300 K in memory.
- Job 1 finishes, and its previously allocated block of 200 K becomes available.
- Job 4 arrives and requires 120 K of memory. The Best Fit algorithm will search for the smallest hole that can accommodate the job, which in this case is the 200 K block previously allocated to Job 1. The job is allocated there.
- Job 5 arrives and requires 150 K of memory. The Best Fit algorithm will search for the smallest hole that can accommodate the job, and it finds a 150 K block available. The job is allocated there.
- Job 6 arrives and requires 80 K of memory. The Best Fit algorithm will search for the smallest hole that can accommodate the job, and it finds an 80 K block available. The job is allocated there.
Performance Comparison
- In this particular sequence of jobs and memory requirements, the First Fit algorithm performs better than the Best Fit algorithm.
- The First Fit algorithm allocates the jobs to the first available blocks, resulting in efficient memory utilization.
- The Best Fit algorithm, on the other hand, searches for the smallest holes which may lead to fragmentation and inefficient memory
A computer has 1000 K of main memory. The jobs arrive and finish in th...
Main memory = 1000K Job 1 requiring 200 K arrives Job 2 requiring 350 K arrives Job 3 requiring 300 K arrives and assuming continuous allocation: Free memory = 1000 − 850(200 + 350 + 300) = 150 K (till these jobs first fit and best fit are same) Since, job 1 finishes, Free memory = 200 K and 150 K Case 1: First fit Job 4 requiring 120 K arrives Since 200 K will be the first slot, so Job 4 will acquire this slot only. Remaining memory = 200 - 120 = 80 K Job 5 requiring 150 K arrives It will acquire 150 K slot Job 6 requiring 80 K arrives It will occupy 80 K slot, so, all jobs will be allocated successfully. Case 2: Best fit Job 4 requiring 120 K arrives It will occupy best fit slot which is 150 K. So, remaining memory = 150 − 120 = 30 K Job 5 requiring 150 K arrives It will occupy 200 K slot. So, free space = 200 − 150 = 50 K Job 6 requiring 80 K arrives There is no continuous 80 K memory free. So, it will not be able to allocate. So, first fit is better. Option (A) is correct.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).