Sunday, May 15, 2011

CS323: Case Study 3


Load the following jobs into memory using fixed partition following a certain memory allocation method (a. best-fit, b. first-fit, c. worst-fit).

Memory Block
Size
Block 1
50K
Block 2
200K
Block 3
70K
Block 4
115K
Block 5
15K








a. Job1 (100k) f. Job6 (6k)
turnaround: 3 turnaround: 1

b. Job2 (10k) g. Job7 (25k)
turnaround: 1 turnaround: 1

c. Job3 (35k) h. Job8 (55k)

turnaround: 2 turnaround: 2

d. Job4 (15k) i. Job9 (88k)

turnaround: 1 turnaround: 3

e. Job5 (23k) j. Job10 (100k)

turnaround: 2 turnaround: 3

*turnaround – how long it will stay in the memory.






a.)BEST-FIT






>> We will first allocate job 1. Since job 1 has 100 k in size, in searching for its location the only possible block that can accommodate job 1 are blocks 2 and 4. In best fit method, the smallest difference between the block size and job size will be the block that the job will be allocating. So in job 1, block 4 has a smaller wasted memory than block 2 which means job 1 will be allocated in block 4. Job 2 with 10 k size can be accommodated by the five blocks and the smallest wasted memory among all the five blocks is block 5 with a memory waste of 5 k. Block 1 will accommodate job 3 since it has the smallest memory waste. Job 4 will be in block 3 since block 5 has already job 2 in it. Job 5 will occupy block 2 even though it will have a memory waste of 177 k. Though it’s a very large memory waste, job 5 has no choice because block 2 can accommodate its memory. Those first five jobs can be seen in column a. In column b, job 2 and job 4 has already finished its job since they both have a turnaround of 1. Since job 2 and 4 left the memory, the jobs on waiting list can now be accommodated. Job 6 has 6 k as we can see in table 1, block 5 has the smallest memory waste and since job 2 is already finish, job 6 now will occupy block 5.  Now Job 7 is left with block 3 because block 1 which has only 25 k memory waste is still occupied by job 3. In column c, job 3 and job 5 with a turnaround of 2 is already finished. Job 8 will be occupying block 3 because it ill only give 15 k of memory waste. Though job 9’s smallest memory waste is block 4, block 4 is still busy with job 1 which means job 9 will be accommodated by block 2. In column d, job 1 is already finished with its turnaround of three. Job 10 can now be accommodated by block 4. On the next column e it shows that job 8 with turnaround of 2 is already finished and job 10 which will be its 2nd turnaround and job 9 on its 3rd turnaround. Since in column e job 9 is in its 3rd turnaround, job 10 will be left in this column still continuing its job until this column. And in by column g all jobs are already finished. 

b.)FIRST-FIT



>>In first fit method, the first block that can accommodate the size of the job will be the block that will accept the job. No matter how large or small the memory waste will be. In this table in column a, job 1 with 100 k size will be allocated by block 2 with a size of 200 k. Job 2 with 10 k can now be accommodate by block 1 with 50 k. unlike with the first job that will need a 100 k. next will be the job 3. Job 3 size is 35k, when it goes to the first free block which is block 3, it will be enough to accommodate that job because block 3 has 70 k which is greater than the size of job 3. Job 4 with 15 k will now be allocated in block 4 with 115 k in size. Though there is an exact size in the block 5, it is still not allowable since we are using first fit. The remaining block now is block 5 with 15 k only. Job 5 needs 23 k so this means job 5 will be put in waiting list. Job 6 with 6 k of memory will be accommodated by block 5. In column b, job 2, 4 and 6 is now finished with its turnaround of 1. Job 5 now one the waiting list will now occupy block 1 and job 7 will be occupying block 4. Block 5 is left unoccupied because the last 3 jobs on the waiting list have a greater memory size than block 5. In column c, job 3 with a turnaround of 2 and job 7 with turnaround of 1 will finished. Making way for job 8 to occupy block 3 and job 9 to occupy block 4. On the next column job 1 is finished, this will allow job 10 to enter in the memory. The next column is just the same with jobs finished at the end of their turnaround. 





C.)WORST-FIT





>>Worst fit is the completely the opposite of best fit because in worst fit the block with largest memory that is wasted will be the location of that certain job. Job 1 is occupying block 2 with 100 k of memory waste. This goes with the jobs 2, 3 and 4. Job 5 can only occupy the first four blocks so the next job which is job six that can be accommodated by block 5 will now enter in the memory, leaving job 5 in the waiting list.  In column b jobs 2,4 and 6 are already finished with turnaround of 1. Job 5 can now occupy block 4 since it has the huge size of wasted memory while job 7 will occupy block 1 that is only available with its size that a block can accommodate. In the next column which is c, job 7 and job 3 is already finished. Job 8 will now enter in the memory though it is the smallest memory waste, job 8 should enter the memory because there is an available space for it. Column d shows job 1 and job 5 is finished. This will allow job 9 and job 10 to enter and execute. Since job 9 and job 10 has the same turnaround they will end up together. 

No comments:

Post a Comment