Professional Documents
Culture Documents
Syllx Akash OS
Syllx Akash OS
Syllx Akash OS
Sf a request from process P, for (0, 4, 2, 0) arrives, Can it be granted nmediately? After allocated process P, request it will subtract from the available. So ew available comes (1, 1,0, 0) Step 1: Safety for process P, Need, =(0,0,0,0) Ifneed, < Available if [(0, 0, 0, 0) < (1, 1, 0, 0)) (true) Process P, will execute. - Available = Available + Allocation =(1, 1, 0,0) + (0,0, 1, 2) =(1,1,1,2) Step 2: Safety for process P, Need, = (0, 7, 5, 0) ifneed, < Available if (0, 7, 5, 0)< (1,1, 1,2)) Process P, must wait? Step 3: Safety for process P; Need, = (1,0, 0, 2) ifneed, < Available if (1, 0, 0, 2) < (1, 1, 1, 2)) (true) 88 P, will execute. wailable = Available + Allocation (1, 1, 1, 2) + (1,3, 5, 4) 2016-15 1. = (0,0, 2, 0) ‘need, < Available ((0, 0, 2,0) < (2,4, 6, 6))Sixth Semester, Operating System 16-2016 =(2, 4,6, 6) + (0, 6, 3, 2) = (2, 10, 9, 8) Step 5: Safety for process P, Need, = (0, 6, 4, 2) ifneed, < Available if ((0, 6, 4,2) < (2, 10,9, 8)] Process P, will execute. Available = Available + Allocation = (2, 10, 9, 8) + (0, 0, 1, 4) = (2, 10, 10, 12) Step 6: Safety for p rocess P, need, = (0,7, 5, 0) ifneed, < Available if ((0, 7, 5, 0) < (2, 10, 10, 12))} Process P, will execute. Available = Available + Allocation = (2, 10, 10, 12) + (1, 0, 0,0) = (3, 10, 10, 12) Safety Sequence =
Hence the new system state is safe, so we can immediately grant the request rocess P, Q.3.(6) Explain various file allocation strategies (i) Contiguous ~ (i) Linked (iii) Indexed ‘Ans: (i) Contiguous Allocation: With contiguous allocation, each file has to oee contiguous blocks on the disk. The location of a file is defined by the disk address of first block and its length. Both sequential access and direct/Random access are suppa by the contiguous allocation. The disadvantage of contiguous allocation is thati often difficult to find free space for a new file. Moreover, one is often not sure of thes required while creating a new tue. The various methods adopted to find space fora file suffer from external fragmentation. (ii) Linked Allocation: In linked allocation, each file is a linked list off blocks. The directory contains a pointer to the first and (optionally the last) blockd file, For example, a file of 5 blocks which starts at block 4, might continue at bla then block 16, block 10, and finally block 27. Each block contains a pointer to the! block and the last block contains a NIL pointer. The value -1 may be used for, differentiate it from block 0. j With linked allocation, each directory entry has a pointer to the first disk By the file. This pointer is initialized to nil (the end-of-list pointer value) to si; block and writes to that block s empty file. A write to a file removes the first free new block is then linked to the end of the'file. To read a file, the pointers # P followed from block to block. $i There is no external fragmentation with linked allocation. Any free well i e size” used to satisfy a request. Notice also that there is no need to declare tht