• recategorized by
12,069 views
33 33 votes

A computer installation has $1000k$ of main memory. The jobs arrive and finish in the following sequences.

    Job 1 requiring 200k arrives
    Job 2 requiring 350k arrives
    Job 3 requiring 300k arrives
    Job 1 finishes
    Job 4 requiring 120k arrives
    Job 5 requiring 150k arrives
    Job 6 requiring 80k arrives
  1. Draw the memory allocation table using Best Fit and First Fit algorithms.

  2. Which algorithm performs better for this sequence?

5 Answers

Best answer
49 49 votes

Initial there is $1000k$ main memory available.

Then job $1$ arrive and occupied $200k$, then job $2$ arrive, occupy $350k$, after that job $3$ arrive and occupy $300k$ (assume continuous allocation ) now free memory is $1000-850(200+350+300)= 150k$ (till these jobs first fit and best fit are same)

Now, job $1$ is finished. So, that space is also free. So, here $200k$ slot and $150k$ slots are free.

Now, job $4$ arrives which is $120k$.

Case 1:

  • First fit, so it will be in $200$ k slot (free slot ) and now free is $= 200-120=80k$,
  • Now $150k$ arrive which will be in $150$ $k$ slot
  • Then, $80k$ arrive which will occupy in $80k$ slot $(200-120)$ so, all jobs will be allocated  successfully.

Case 2:

  • Best fit : $120 k$ job will occupy best fit free space which is $150k$ so, now remaining $150-120=30k$,
  • Then $150k$ job arrive it will be occupied in $200k$ slot, which is best fit for this job. So, free space $=200-150= 50$,
  • Now, job $80k$ arrive, but there is no continuous $80k$ memory free. So, it will not be allocated successfully.

So, first fit is better.

• edited by
1 1 vote
Yes in this case First Fit algorithm will willperform better than Best Fit as in case of BEST FIT last job is not allocated due to non- availability of Contiguous memory.
0 0 votes

JOB 6 WILL NOT BE SCHEDULED BY BEST FIT ALGORITHM AND THERE WILL BE EXTERNAL FRAGMENTATION . 

HERE FIRST FIT PERFORMS BETTER THAN BEST FIT ALGORITHM BECAUSE IT SCHEDULES ALL THE JOBS AND THERE IS NO WASTAGE SPACE ALL THE SPACE OF 1000K UTILIZED PROPERLY. 

0 0 votes

 

A. Memory Allocation Tables

 

First Fit Algorithm

Always allocates the first hole that is big enough.

 

EventActionMemory Layout (1000k Total)
InitialStart[Hole: 1000k]
Job 1 (200k)Allocate[Job 1: 200k] [Hole: 800k]
Job 2 (350k)Allocate[Job 1: 200k] [Job 2: 350k] [Hole: 450k]
Job 3 (300k)Allocate[Job 1: 200k] [Job 2: 350k] [Job 3: 300k] [Hole: 150k]
Job 1 finishesFree 200k[Hole: 200k] [Job 2: 350k] [Job 3: 300k] [Hole: 150k]
Job 4 (120k)Allocate[Job 4: 120k] [Hole: 80k] [Job 2: 350k] [Job 3: 300k] [Hole: 150k]
Job 5 (150k)Allocate[Job 4: 120k] [Hole: 80k] [Job 2: 350k] [Job 3: 300k] [Job 5: 150k]
Job 6 (80k)Allocate[Job 4: 120k] [Job 6: 80k] [Job 2: 350k] [Job 3: 300k] [Job 5: 150k]

 

 


 

Best Fit Algorithm

Allocates the smallest hole that is big enough.

 

EventActionMemory Layout (1000k Total)
InitialStart[Hole: 1000k]
Job 1 (200k)Allocate[Job 1: 200k] [Hole: 800k]
Job 2 (350k)Allocate[Job 1: 200k] [Job 2: 350k] [Hole: 450k]
Job 3 (300k)Allocate[Job 1: 200k] [Job 2: 350k] [Job 3: 300k] [Hole: 150k]
Job 1 finishesFree 200k[Hole: 200k] [Job 2: 350k] [Job 3: 300k] [Hole: 150k]
Job 4 (120k)Allocate[Hole: 200k] [Job 2: 350k] [Job 3: 300k] [Job 4: 120k] [Hole: 30k]
Job 5 (150k)Allocate[Job 5: 150k] [Hole: 50k] [Job 2: 350k] [Job 3: 300k] [Job 4: 120k] [Hole: 30k]
Job 6 (80k)WaitCannot fit. Largest holes are 50k and 30k.

 

 


 

B. Conclusion

First Fit performs better for this sequence.

  • First Fit: Successfully allocated all 6 jobs. By placing Job 4 in the first available 200k slot, it left a 150k slot at the end which was perfectly sized for Job 5.
  • Best Fit: Failed to allocate Job 6. It "optimally" placed Job 4 in the 150k slot (leaving 30k) and Job 5 in the 200k slot (leaving 50k). This fragmented the memory such that the 80k required for Job 6 was not available in a single contiguous block.
Position:
Show:

Related questions

28 28 votes
3 answers 3 answers
137k
137k views
Kathleen asked Oct 8, 2014
136,743 views
The head of a moving head disk with $100$ tracks numbered $0$ to $99$ is currently serving a request at track $55$. If the queue of requests kept in FIFO order is $$10, 7...
24 24 votes
1 answers 1 answer
6.9k
6.9k views
Kathleen asked Oct 8, 2014
6,937 views
Consider the following program segment for concurrent processing using semaphore operators $P$ and $V$ for synchronization. Draw the precedence graph for the statements $...
52 52 votes
2 answers 2 answers
21.5k
21.5k views
Kathleen asked Oct 8, 2014
21,497 views
If the overhead for formatting a disk is $96$ bytes for a $4000$ byte sector,Compute the unformatted capacity of the disk for the following parameters:Number of surfaces:...
14 14 votes
2 answers 2 answers
5.1k
5.1k views
go_editor asked Feb 12, 2018
5,126 views
What is the equivalent minimal Boolean expression (in sum of products form) for the Karnaugh map given below?