COSC 4330: Operating Systems Sample Exam 2 Questions (10 points) Define thrashing. What is the relationship between the working sets of active processes and thrashing? (10 points) A computer has six tape drives, with n processes competing for them. Each process may need to two drives. For which values of n is the system deadlock-free? Justify your answer. (18 points) Consider the following reference string generated by a process that has been allocated 3 page frames in main memory: 1 2 3 4 2 1 5 1 2 4 4 3 5 2 1 2 1 For the three page replacement algorithms shown below, complete the table to indicate which pages are in main memory after each reference. For working set, assume delta is 3. (Be careful! Your first mistake in a column may cause all succeeding answers to be wrong.) Reference --------------- Memory Contents --------------- working set LRU OPT (12 points) Consider the following code to clear an array with 50 rows and 50 columns. \begin{verbatim} for j := 0 to 49 do for i := 49 downto 0 do a[i,j] := 0; \end{verbatim} Suppose you are given the following: The rows are stored in contiguous blocks of memory and the elements in a row are stored in contiguous words. Memory consists of frames that hold 250 array elements each. Only 8 frames of memory may be allocated to array storage. Initially, no part of the array is in memory. (a) Suppose that as page faults occur, the OS replaces pages on a FIFO basis. s on a FIFO basis. How many page faults does the above code cause? (b) Describe a page replacement strategy other than OPT that would minimize the number of page faults caused by the above code. How many page faults occur with your strategy in effect? (5 points) All things being equal, why do we prefer to replace an unmodified page rather than a modified one during page replacement? (5 points) Explain why small page sizes require keeping the page table in main memory rather than in hardware registers or a cache? (5 points) A computer has 100 GB (gigabyte) of physical memory (disk) and a page size of 2 KB (kilobyte). 1 GB = 1,000 MB = 1,000,000 KB. How many entries are there in the largest page table? (15 points) Given the following information for an assembly language program: Process code size = 3126 bytes, Page size = 1042 bytes Instruction at memory location 532: Load 1, 2098 Instruction at memory location 1156: Add 1, 4087 Instruction at memory location 2086: Sub 1, 1052 Data at memory location 1052: 015672 Data at memory location 2098: 114321 Data at memory location 4087: 077435 (a) How many pages are needed to store the entire process code? Show calculations. (b) Compute the page number and displacement for each of the byte e byte addresses where the data is stored (recall that page numbering starts at 0). (c) Are page numbers and displacements legal for this process? Explain.