Tuesday, April 5, 2011

CASE # 6

WHY IS THERE IS NO TRANSITION FOR
READY TO WAITING
 AND
WAITING TO RUNNING?


The diagram explains that the job before execution will be called or stayed as in ready state. When execution or during execution the said job is now in the running state. If during the execution an interrupt will occur, it will be sent back to in a ready state. But if not, the job’s execution will continue until it is done in its execution. Yet, if during the execution an input/output request page fault will be seen, the CPU will then sent the said job to waiting state. Then as the CPU send a command or a signal for the job on the waiting state to be processed again, from waiting state the job will then change to ready state.

From ready to waiting state:

            In the diagram, we could see that there is no transition to ready state to waiting state. Well, there is no transition for ready to waiting state due to all failed required devices are to be sent to hold. A job can be in the ready state when the said job is okay in all aspects. When it is now ready the CPU then execute the job or from ready state it is now in the running state. It is impossible to have a transition from ready to waiting because from ready state the job will automatically be sent on a running state. If during the execution (like what I have said awhile ago) an interrupt issued, because in executing jobs we cannot say that there will be no interruption, from the running state will turn back to ready state. After the interruption the job that is sent back to ready state will be loaded or executed again.

From waiting to running:

            It is impossible for a transition from waiting to running state, if we look at the diagram. Why? Because the CPU cannot send signals to job in the waiting state to automatically send in the running state whatever happens. It only means that a job can be on the running state if and only if it is ready or in the ready state. During at the waiting state, the CPU can only send signals that command the job to be at the ready state before its actual execution or the running state.   



CASE # 5

There are a lot of types of allocating memory in a computer. Memory allocation is a process where jobs are saved in the memory of the computer. One of these is what we call the fixed partition.

            Fixed Partition is a memory allocation scheme which is most basic. In fixed partition, the main memory of the computer is partitioned with a static or constant size. The process in allocating memory of this type is quite simple. As long as the job finds a partition in the memory that fits him. The job will automatically be allocated. But in this type of allocation scheme, it has the biggest rate of having an internal fragmentation or the wasted memory.

            There are also three methods for free space allocation: best-fit allocation, first-fit allocation, and worst-fit allocation. In best-fit allocation, the job is required to look for a memory block or a partition in the memory which has the least memory waste. In first-fit allocation, the job will automatically be allocates in the first partition that where it will be fitted. Because of this, the allocation process will be faster. And in worst-fit allocation, alike with best-fit allocation, the jobs look for a partition in the memory which has the biggest memory waste.

            Here, we will be loading jobs in the memory using the fixed partition. There will be 10 jobs that are needed to be loaded: Job1 [100k], Job2 [10k], Job3 [35k], Job4 [15k], Job5 [23k],
Job6 [6k], Job7 [25k], Job8 [55k], Job9 [88k], and Job10 [100k]. They must be loaded in a memory with five partitioned memory blocks. Block1 [50k], Block2 [200k], Block3 [70k], Block4 [115k], Block5 [15k]. We will be loading them using the three methods.

(a. Best-Fit Allocation)
           
            In best-fit, job1 will be looking first, but because it is best-fit, jobs will all try every block of memory and will look for the least memory waste. Job1 will try first. In block1 their sizes are incompatible because job one has a size of 100k. Then job1 will try the second block. There, memory waste is 100k. Then block3, their sizes are not compatible so the job will proceed to block4. There, the memory waste is 15k, less than the second block. Job 1 will proceed to block5, but because of incompatible sizes, job1 will check which block will have the least memory waste. As we all know, in block 4 the memory waste is lesser than block2. So job1 will be allocated in block4. Next in the process is job2. Job2 again check all the blocks of who has the least internal fragmentation like what job1 did. After that job2 will found out that block5 with a memory waste of 5k has the least so job2 will be loaded to block5. Same process, job3 will check and found out that block1 with 16k internal fragmentation has the least memory waste so job3 will be loaded to block1. Job4 will found out after checking each block that block3 with a memory waste of 55k will be the least, so, job4 will be loaded to block3. Job5 will check and block1 has the least but block1 was already occupied by job3 so job5 will be loaded to block2 with a memory waste of 177k because all of the blocks were occupied. The remaining jobs will wait until the turn over of the jobs will end and be allocated. After loading, job’s2 and 4 will end their turnaround. And that will lead job6 to try the two empty blocks and block5 have the least so job6 will be loaded to block5 with a fragmentation of 9k. Then job7’s turn, because job7 cannot be loaded in block5, job7 will be loaded in block3 with 16k internal fragmentation. Because all blocks are occupied, the other jobs will wait. After loading job’s 3, 5 and 7, the other jobs will have the chance to be loaded. Job8 will be loaded to block3 with an internal fragmentation of 15k. Then, job9 will be loaded in block2; though block4 has the least, job9 still can’t be loaded in block4 because it is occupied by job1. Until job1 ended its turnover, job10 will be having the chance to be loaded. Job10 searched and found out that block4 has the least memory waste. After that, job8 will end its turnover. Next will be job9 after 3rd turnaround. Until, job10 will end on its third turnaround.

(b. First-Fit Allocation)

             In fist-fit, the first job is needed to allocate or need to be loaded in the first block where it is fit. Job1 is fitted in the second block with 200k. Job2 will be loaded in the first block with 50k. Job3 will be loaded in block3 with 70k. Job4 will be loaded in block4 with 115k. Job5 doesn’t fit in block5 so job5 will wait and job6 with 6k can be loaded in the fifth block with 15k. Job2 ended so job5 will be loaded in the first block with 50k.Job4 ended and job7 will be loaded in the fourth block with 15k. Because job8 doesn’t fit in the fifth block, job8 will wait, and block5 will remain empty. Then, job3 will end and job8 will be loaded in block3 with 70k. Job9 is loaded in block4 with 115k. But job10 still cannot be loaded and still wait that made block5 empty. Job’s 5 and 1 will end and put job10 in the second block with 200k but block5 remains empty. After that, block’s 1, 3 and 5 are empty block because job8 ended. After its third turnaround, job9 will end and ended block3 empty.

(c. Worst-Fit Allocation)

            In worst-fit, job1 will check all empty blocks on which have the biggest memory waste. So, job1 will be loaded in block2 with a memory waste of 100k, bigger than any blocks. Job2 will again check and found block4 having 105k as a memory waste. Job3 will be loaded in boock3 with a memory waste of 35k. Job4 will be loaded in block1 with a waste of 35k. Job5 cannot be loaded because it needed more than 23k memory but block6, an empty block, only have 15k that made job5 to wait. But job6 with 6k can be loaded in block6 with a memory waste of 9k. Job’s4 and 2 have both ended and job5 will be the next. Job5 will be loaded in block4 with a memory of 92k. Job7 will be loaded in block1 with a memory waste of 25k. Job8 cannot be loaded in block5 that lead block5 to be an empty block. Job7 will end but job9 still cannot be loaded due to incompatible memory needed and put job9 to still wait. Block’s 1 and 5 are empty blocks. After job1 ended, job9 will be loaded in block2 with a memory waste of 112k. And at the same time job5 will also end that put job10 in block4 with a memory waste of 15k. Job8 will end first and afterwards, job’s 9 and 10 will together ends their turnarounds.

CASE # 4