Select the false statements: A Banker’s algorithm is deadlock prevention; B disallowing hold-and-wait prevents deadlock; C an assignment edge in a resource-allocation graph goes from process to resource; D a safe state permits every process to finish without deadlock.
Select all that apply
Answer & solution
Official answer: A, C
Givens and goal
Select the false statements: A Banker’s algorithm is deadlock prevention; B disallowing hold-and-wait prevents deadlock; C an assignment edge in a resource-allocation graph goes from process to resource; D a safe state permits every process to finish without deadlock.
Approach
Distinguish the standard algorithm categories, recall graph edge direction, and interpret safety as existence of a safe completion sequence.
Step-by-step solution
1. Deadlock prevention structurally rules out at least one necessary condition, such as hold-and-wait. Avoidance instead examines potential grants and declines those that would leave the system unsafe. 2. Banker’s algorithm is an avoidance algorithm: it checks whether a safe completion sequence remains after a proposed allocation. Calling it prevention in the standard technical taxonomy is false, so select A. 3. If no process may hold resources while waiting for more, the hold-and-wait condition cannot hold. Since that condition is necessary for resource deadlock, B is true and must not be selected. 4. A request edge goes process→resource; an assignment edge goes resource-instance→process to indicate ownership. C reverses assignment direction, so select C. 5. A safe state means there is an order in which each process can obtain its remaining declared maximum need, finish, and release resources for later processes. That establishes D in the conventional safe-allocation sense. 6. Therefore the false statements are A and C. “Safe” asserts a feasible completion sequence under controlled allocation, not that arbitrary future grants can never make the system unsafe.
Five processes share k identical resource instances. Each process needs at most two, requests or releases only one at a time, and can request its second only after receiving its first. Find the smallest k guaranteeing freedom from resource deadlock.
Answer & solution
Official answer: 6
Givens and goal
Five processes share k identical resource instances. Each process needs at most two, requests or releases only one at a time, and can request its second only after receiving its first. Find the smallest k guaranteeing freedom from resource deadlock.
Approach
Show an unsafe allocation for too few resources and prove that one additional resource always lets some process finish.
Step-by-step solution
1. With k=5, allocate one instance to each process. If all five then request a second, all five available instances are held and every process is waiting. No process can reach its maximum claim and finish: this is a possible deadlock. 2. Smaller positive capacities also fail to give a universal guarantee: the available instances can each be held by a different process waiting for its second, while the others wait for their first. Thus merely showing failure at five is consistent with the lower-capacity cases. 3. Now let k=6. If some process holds two instances, it has its complete maximum resource requirement and can finish without waiting for another instance, then release what it holds. 4. Otherwise each of the at most five processes holds at most one instance, so at most five are allocated. At least one of the six remains free. It can be granted as a second instance to a waiting holder, enabling that process to finish and release two. 5. Repeating the reasoning gives a safe sequence of completions, so a resource deadlock cannot arise. The smallest required capacity is 6.
This is the standard resource-deadlock model, assuming a process eventually completes when its maximum resource need is satisfied. It does not guarantee fair scheduling or rule out starvation caused by a scheduler.
A cache is physically addressed. An MMU has a TLB, and eviction of a page invalidates that page’s cache blocks. Which sequences cannot occur for a reference: A TLB miss/page-table hit/cache hit; B TLB hit/page-table miss/cache hit; C TLB miss/page-table miss/cache hit; D TLB miss/page-table miss/cache miss?
Select all that apply
Answer & solution
Official answer: B, C
Givens and goal
A cache is physically addressed. An MMU has a TLB, and eviction of a page invalidates that page’s cache blocks. Which sequences cannot occur for a reference: A TLB miss/page-table hit/cache hit; B TLB hit/page-table miss/cache hit; C TLB miss/page-table miss/cache hit; D TLB miss/page-table miss/cache miss?
Approach
Distinguish a missing cached translation from a nonresident page, and apply the cache invalidation condition.
Step-by-step solution
1. Interpret a page-table miss here as a nonresident page (a page fault), not as a cache miss while fetching the page-table entry. The cache is physically addressed, so the ordinary sequence first resolves virtual-to-physical translation and then accesses the referenced cache block. 2. A TLB miss can occur even when the page is resident: the translation may simply not be cached in the TLB. After a successful page-table lookup the data block may still be present in the cache. Therefore A is possible. 3. In a correctly maintained translation system, a TLB hit supplies a valid resident-page translation, and a page-table walk is not needed for that reference. It cannot simultaneously be the page-table-fault sequence described in B. Thus B is impossible. 4. If the referenced page is absent from memory, the stated invalidation rule prevents its data blocks from remaining valid in the cache. Therefore the page-fault-plus-cache-hit sequence C is impossible. A TLB miss, page fault and absence of the data block from cache, as in D, is possible.
Interpretation note: These are hit/miss conditions for the original reference before fault recovery. Fault servicing can populate memory or cache and then retry the instruction; hits on that later retry are not the same event sequence. Correct TLB invalidation is implicit in a functioning virtual-memory system.
Possible-state examples help separate the two misses. A resident page whose translation has been displaced from the small TLB, but whose recently used data still sits in cache, gives A. A never-loaded virtual page gives a TLB miss and page fault; since it has no valid physical cached block, its initial data access is also a cache miss, matching D. “Page-table miss” is not being used to mean that the page-table entry itself missed in a processor cache.
In main, for i=0; i<3; i++, the program calls fork(). The child (fork()==0) executes continue; the parent executes break. After the loop each process executes printf("Hello!"). All forks succeed. Count executions of printf.
Answer & solution
Official answer: 4
Step through it (9 steps)
Givens and goal
In main, for i=0; i<3; i++, the program calls fork(). The child (fork()==0) executes continue; the parent executes break. After the loop each process executes printf("Hello!"). All forks succeed. Count executions of printf.
Approach
Trace which process continues the loop after each fork rather than assuming every process performs all three iterations.
Step-by-step solution
1. Begin with process P0 at i=0. It forks child P1. P0 receives a nonzero return value, skips the child branch, executes break, and prints once. 2. P1 receives zero and executes continue. In a for loop, continue proceeds to the increment i++, then tests the condition. Thus P1 reaches i=1 and forks P2. P1 then breaks and prints once; P2 continues. 3. P2 reaches i=2 and forks P3. P2 breaks and prints once. P3 continues to the increment, giving i=3, where i<3 is false. P3 exits the loop normally and prints once. 4. The process structure is a chain P0→P1→P2→P3, with exactly three successful forks and four processes. Every one reaches the single printf once, so the answer is 4. 5. The execution order of the four prints is scheduling-dependent, but the count is not. The usual 2^3=8 doubling applies only when both parent and child continue forking on later iterations; here each parent immediately leaves the loop. There is also no pre-fork buffered print in the snippet whose output could be duplicated.
Actuator processes A require 6 CPU seconds and arrive at times 10,20,30,40,50. Controller processes C require 8 seconds and arrive at 11,22,33,44,55. FCFS scheduling is nonpreemptive and the first A starts at 10. Find the average waiting time of all ten processes to one decimal place.
Answer & solution
Official answer: 9.5
Step through it (19 steps)
Givens and goal
Actuator processes A require 6 CPU seconds and arrive at times 10,20,30,40,50. Controller processes C require 8 seconds and arrive at 11,22,33,44,55. FCFS scheduling is nonpreemptive and the first A starts at 10. Find the average waiting time of all ten processes to one decimal place.
Approach
Merge arrivals chronologically and use start=max(arrival, previous finish), wait=start−arrival for each row.
Step-by-step solution
1. The chronological order is A1,C1,A2,C2,A3,C3,A4,C4,A5,C5. FCFS serves them in exactly this order, without preempting a current process when a new one arrives. 2. Compute starts and finishes sequentially. For A1, start=10, finish=16 and wait=0. C1 arrived at 11 but must wait until 16, so its wait is 5 and finish is 24. Continue the same recurrence:
3. Total waiting time is 0+5+4+8+8+11+12+14+16+17=95 seconds. Divide by ten processes to get 95/10=9.5 seconds. 4. Waiting time excludes the process’s own CPU burst. Using finish−arrival would give turnaround time instead. There is no idle gap after the first process starts: at each completion, the next process in the table has already arrived.
Similar questions1 more → · asked again: GATE 2002, Q1.22
Identifying non-preemptive scheduling
CPU Scheduling
Tap to enlarge
Which CPU scheduling algorithm cannot be preemptive under its standard definition? A SRTF; B FCFS; C Round Robin; D Priority.
Your answer
Answer & solution
Official answer: B
Givens and goal
Which CPU scheduling algorithm cannot be preemptive under its standard definition? A SRTF; B FCFS; C Round Robin; D Priority.
Approach
Distinguish the order of selecting ready jobs from taking the CPU away mid-burst.
Step-by-step solution
1. FCFS serves ready processes in order of arrival. Once selected, a process continues until it finishes its CPU burst or voluntarily blocks. Standard FCFS does not preempt that burst. 2. SRTF chooses the smallest remaining execution time. If a shorter job arrives, it may preempt the current job; this is the preemptive form of shortest-job scheduling. 3. Round Robin explicitly preempts when a time quantum expires and places an unfinished process back in the ready queue. Priority scheduling can be defined either with immediate higher-priority preemption or with selection only at release points. 4. Thus B is the intended answer. A hardware interrupt or a process blocking for I/O is not, by itself, evidence that the scheduler uses a preemptive FCFS policy.
Three processes each execute: wait(A); print(*); X=X+1; if X==2 then {print($); signal(B);}; signal(A); wait(B); print(#); signal(B). Binary semaphores start A=1,B=0 and shared X=0. Each line is atomic. Which outputs are possible? A **$*###; B **$#*##; C **$##*#; D ***$###.
Select all that apply
Answer & solution
Official answer: A, B, C
Givens and goal
Three processes each execute: wait(A); print(*); X=X+1; if X==2 then {print($); signal(B);}; signal(A); wait(B); print(#); signal(B). Binary semaphores start A=1,B=0 and shared X=0. Each line is atomic. Which outputs are possible? A $*###; B **$#*##; C **$##*#; D *$###.
Approach
Find invariant ordering constraints, then exhibit schedules achieving each candidate.
Step-by-step solution
1. A protects the star and increment section. The first entrant prints a star and changes X from 0 to 1. The second prints another star and changes X to 2, then prints $ before releasing A. 2. The third entrant cannot print its star until that release. Therefore the dollar must occur immediately after the second star among these star/dollar events, and ***$### is impossible. Preempting the second process before $ does not help: it still holds A. 3. B initially blocks all hash printing. It is first signaled only after the dollar; each process that prints a hash then signals B for another. Thus no hash can precede $, while each process’s own star must precede its hash. 4. For A, let the first two processes complete their A sections, then let the third complete its A section before allowing any hash sections. For B, after the first two A sections allow one of those processes to print a hash, then allow the third star, then the remaining hashes. 5. For C, let both first and second processes print their hashes after $, delaying the third A section until afterward. The third then prints its star followed by its hash. These realize all A,B,C exactly. 6. Therefore select A,B,C. The invariant and the explicit schedules together establish both impossibility and feasibility; a single simulated scheduling order would not suffice.
A 16 GB disk uses 2 KB blocks. A linked-list bookkeeping scheme stores 32-bit free-block numbers in list blocks, each also reserving one 4-byte next pointer. With K=2¹⁰,G=2³⁰, compute the number of list blocks under the intended capacity-to-record-all-disk-blocks convention; the current free count is not specified.
Answer & solution
Official answer: 16417
Givens and goal
A 16 GB disk uses 2 KB blocks. A linked-list bookkeeping scheme stores 32-bit free-block numbers in list blocks, each also reserving one 4-byte next pointer. With K=2¹⁰,G=2³⁰, compute the number of list blocks under the intended capacity-to-record-all-disk-blocks convention; the current free count is not specified.
Approach
Compute entries per list block and round the required quotient upward.
Step-by-step solution
1. The disk has (16×2³⁰)/(2×2¹⁰)=2²³=8,388,608 blocks. A block number occupies 32/8=4 bytes. 2. Each list block holds 2048 bytes, but 4 are reserved for its successor pointer. The remaining 2044 bytes hold 2044/4=511 block numbers. Counting 512 would forget the link pointer. 3. The capacity calculation is ceil(8,388,608/511). Since 511×16,416=8,388,576, those blocks fall short by 32 entries; one additional block is required. Thus the answer is 16,417. 4. This preserves the official result under the full-disk bookkeeping-capacity convention. If the actual free count is F, the needed entry capacity is ceil(F/511), so an arbitrary partially occupied disk is not determined by the stated disk size alone. 5. If list-storage blocks themselves are excluded from the free-block population on the same disk, a different self-consistent accounting model applies. The official value should therefore not be presented as a universal current free-space measurement. The unspecified free count and accounting convention remain explicit qualifications.
A TLB reaches 1 MB with 4 KB pages. Virtual space is 64 GB and physical space 1 GB. Each entry stores a 4-bit process ID, virtual page number, physical frame number, and 2 control bits. Find the TLB size in bytes, with binary K,M,G.
Answer & solution
Official answer: 1536
Step through it (6 steps)
Givens and goal
A TLB reaches 1 MB with 4 KB pages. Virtual space is 64 GB and physical space 1 GB. Each entry stores a 4-bit process ID, virtual page number, physical frame number, and 2 control bits. Find the TLB size in bytes, with binary K,M,G.
Approach
Find entry count and entry width independently, then multiply.
Step-by-step solution
1. TLB reach is number of entries times page size. Therefore the number of entries is 2²⁰/2¹²=2⁸=256. 2. Virtual space 64 GB equals 2³⁶ bytes, requiring a 36-bit address. A 4 KB page has a 12-bit byte offset. The virtual page number therefore has 36−12=24 bits. 3. Physical space 1 GB equals 2³⁰ bytes, requiring a 30-bit address. Removing the same 12-bit offset leaves an 18-bit physical frame number. 4. One entry contains 4+24+18+2=48 bits, or 6 bytes. Total storage is 256×6=1536 bytes. 5. The page offset is not stored as part of a translation entry because it passes through unchanged. This answer includes exactly the specified fields and assumes no unmentioned padding, replacement information, or other implementation metadata.
Nonadjacent free holes have sizes 20,4,25,18,7,9,15,12 KB. Allocate a 16 KB process and then a 9 KB process by best fit. How many remaining holes are smaller than 8 KB?
Answer & solution
Official answer: 3
Givens and goal
Nonadjacent free holes have sizes 20,4,25,18,7,9,15,12 KB. Allocate a 16 KB process and then a 9 KB process by best fit. How many remaining holes are smaller than 8 KB?
Approach
At each arrival choose the smallest currently adequate hole, then update the list.
Step-by-step solution
1. For the 16 KB request the adequate holes are 18,20,25 KB. Best fit chooses 18 KB, leaving an 18−16=2 KB fragment. The 15 KB and smaller holes cannot accommodate it. 2. Afterward the hole sizes are 20,4,25,2,7,9,15,12 KB. For the 9 KB request, the 9 KB hole is an exact fit and is removed entirely; it does not remain as a zero-size hole. 3. The final positive hole sizes are 20,4,25,2,7,15,12 KB. Those strictly less than 8 KB are 4,2,7 KB, giving three holes. 4. No coalescing is performed because the original holes are nonadjacent and these operations only split or consume them. The answer is 3. Always recompute the available holes after the first allocation rather than assigning both requests independently to the original list.
A byte-addressable demand-paged machine has 32-bit logical addresses, 20-bit physical addresses, and 2048-byte pages. What is the maximum number of entries in a conventional page table? A 2^21; B 2^20; C 2^22; D 2^24.
Your answer
Answer & solution
Official answer: A
Step through it (5 steps)
Approach: Count virtual pages, because a conventional page table has one possible entry per virtual page. The page size is 2048=211 bytes, so the low 11 bits of a logical address identify a byte within its page. The remaining 32−11=21 bits identify the virtual page. There are therefore 221 possible virtual-page numbers, selecting A. Equivalently, the virtual address space has 232 bytes and dividing by 211 bytes per page gives 221 pages. Physical-address width is not the numerator in this calculation. It determines that physical memory can contain 220−11=29 frames and that a frame number needs 9 bits. Demand paging may leave many entries invalid or pages absent from physical memory, but that does not reduce the maximum number of distinct virtual pages the table must represent.
A process executes one scanf, then twenty loop iterations, each doing x=x+20 and one printf. Every I/O operation sends it to an I/O queue; context switches occur both on I/O requests and on returns. Excluding initial admission, how many times does it enter the ready queue during this program? Use the question’s stipulated blocking-I/O model.
Answer & solution
Official answer: 21
Approach: Count the state transitions into Ready rather than all context switches. The scanf causes one I/O request. The loop has exactly twenty iterations, so its printf causes twenty more requests. There are 21 I/O operations in all. Each request takes the process from Running to Blocked (the I/O queue); that transition does not enter the ready queue. When each I/O operation completes, the blocked process becomes eligible to run again and enters Ready once. Thus 21 completions produce 21 ready-queue entries. The initially admitted Ready entry is explicitly excluded, giving the answer 21 rather than 22. There can be two stipulated context-switch events around an I/O episode, but they must not both be counted as Ready entries. The intended model assumes no additional time-slice or priority preemptions; such unspecified events could add entries. It also treats library I/O as blocking regardless of real-world stdio buffering.
Four processes arrive at time 0 with CPU bursts P1=20, P2=16, P3=25, P4=10 ms. Scheduling is non-preemptive. M1 priority order is P1>P3>P2>P4; M2 order is P2>P3>P4>P1. A free processor chooses the highest-priority waiting process in its own order; a process runs on only one processor. Ignore switching overhead. Average waiting time? A 9.00; B 8.75; C 6.50; D 7.50 ms.
Your answer
Answer & solution
Official answer: A
Approach: Build a timeline of processor release events, selecting only among processes still waiting at each event. At t=0, M1 selects P1 and M2 selects P2. Neither process waits. Their completion times are 20 and 16 respectively. At t=16, M2 becomes free while P3 and P4 are waiting. M2 ranks P3 above P4, so P3 begins at 16 and finishes at 41. At t=20, M1 becomes free; P3 is already running and cannot be scheduled again, so M1 begins P4, which finishes at 30. Because all arrivals are at zero and scheduling is non-preemptive, waiting times equal start times: P1=0, P2=0, P3=16, P4=20. Their average is (0+0+16+20)/4=9.00 ms, option A. Completion times must not be averaged as waiting times, and priority orders are applied only to eligible waiting processes, not to processes already executing elsewhere.
Separating linked-allocation overhead from fragmentation
File Systems
Tap to enlarge
A 512 MiB disk uses 64 KiB blocks. Linked allocation reserves four bytes in every allocated block for a next-block pointer, including a four-byte NULL pointer in the last block. A file holds 1 MiB of data. With K=2^10 and M=2^20, how many bytes are unused because of internal fragmentation?
Answer & solution
Official answer: 65468
Approach: Subtract pointer storage from per-block data capacity before computing how many blocks are needed. A block is 64×1024=65536 bytes. Four bytes are reserved for the pointer, leaving 65532 bytes for file data. The file has 1048576 bytes. Sixteen blocks can hold only 16×65532=1048512 data bytes, which is 64 bytes too little. Therefore a seventeenth block is necessary. The first sixteen data regions are full and the last contains the remaining 64 file bytes. Its unused data area is 65532−64=65468 bytes. Equivalently, 17×65532−1048576=65468. The 17 pointer fields occupy 68 bytes, but those bytes are allocated structural overhead rather than unused data space. Counting total physical allocation minus file size would give 17×65536−1048576=65536; subtracting the pointer overhead leaves the required 65468. The last NULL pointer still consumes its specified four bytes.
Three page frames start empty. References are 1,3,2,4,2,3,1,2,4,3,1,4. A modified optimal replacement algorithm predicts only a window of four references including the current request, evicting the resident page used farthest in that window, or absent from it. Count page faults.
Answer & solution
Official answer: 6
Step through it (14 steps)
Approach: Simulate each request, and on a full-frame miss inspect only the allowed lookahead window. Requests 1,3,2 fill the empty frames and cause three faults, leaving {1,2,3}. At request 4 (position 4), the window is [4,2,3,1]. Among resident pages, 1 is used farthest away, so evict 1 and load 4: fault 4, frames {2,3,4}. The next requests 2 and 3 hit. At position 7, request 1 misses. The window [1,2,4,3] places resident 3 farthest in the future, so evict 3: fault 5, frames {1,2,4}. Requests 2 and 4 then hit. At position 10, request 3 misses. Only [3,1,4] remains. Resident 2 is absent from that window, so evict 2: fault 6, frames {1,3,4}. The last two requests, 1 and 4, hit. There are six faults, at positions 1,2,3,4,7,10. No replacement tie affects this trace. The current request is included in the four-reference horizon, so the prediction is of at most three additional future accesses, not four.
Processes P1,P2,P3,P4 arrive at times 0,1,2,8 ms and require 10,13,6,9 ms of CPU time respectively. Scheduling uses preemptive Shortest Remaining Time First with no context-switch cost. Find average turnaround time. Options: A. 22 ms; B. 15 ms; C. 37 ms; D. 19 ms.
Your answer
Answer & solution
Official answer: D
Step through it (7 steps)
Track remaining time at each arrival rather than comparing original burst times throughout. At t=0 only P1 is available. At t=1 P1 has 9 ms left, less than P2's 13, so P1 continues. At t=2 P1 has 8 ms left and P3 arrives needing 6; P3 preempts it and runs from 2 to 8.
At t=8 P3 completes and P4 arrives. Remaining times are P1:8, P2:13, P4:9, so choose P1 for 8…16. Next choose P4 for 16…25, followed by P2 for 25…38. The execution intervals are therefore P1 [0,2), P3 [2,8), P1 [8,16), P4 [16,25), P2 [25,38).
Turnaround equals completion minus arrival: P1=16−0=16, P2=38−1=37, P3=8−2=6, P4=25−8=17 ms. Their sum is 76 ms and the average is 76/4=19 ms. Waiting time would subtract each burst as well; that is not the requested metric. Answer: D.
A demand-paging system has three initially empty frames and reference string [1,2,3,4,5,4,1,6,4,5,1,3,2]. In frame order, the resident triples after each reference are: 1:(1,−,−); 2:(1,2,−); 3:(1,2,3); 4:(1,4,3); 5:(1,4,5); 6:(1,4,5); 7:(1,4,5); 8:(6,4,5); 9:(6,4,5); 10:(6,4,5); 11:(6,1,5); 12:(6,1,3); 13:(2,1,3). Which policies could produce this trace? A. LRU; B. LFU; C. MFU; D. optimal/farthest-next-use. Frequency-counter lifetime and tie-breaking are not stated.
Select all that apply
Answer & solution
Official answer: D
Our answer: D with lifetime counters; C;D with reset-on-load counters
Test policies at the first point where their required choice disagrees with the trace. LRU fails at reference 4: among pages 1,2,3, page 1 was used least recently, but the trace evicts page 2. LFU fails at reference 8: before loading page 6, resident reference counts are page 1:2, page 4:2, page 5:1. The trace evicts page 1 rather than the least frequent page 5. These counts agree under both lifetime and reset-on-load conventions at that point.
Optimal replacement is possible. At reference 4, pages 1,2,3 are next used at positions 7,13,12, so evict 2. At reference 5, residents 1,4,3 are next used at 7,6,12, so evict 3. At reference 8, residents 1,4,5 are next used at 11,9,10, so evict 1. At references 11,12,13, the displayed victim is never used again, so the trace can choose it among tied infinite-next-use victims. Thus D is valid.
MFU requires a convention. With lifetime counts, reference 11 loads page 1 with its cumulative count now 3. At reference 12, residents have counts 6:1,1:3,5:2, but the trace evicts 5, not 1. So lifetime MFU fails already there; the final eviction also contradicts it.
With counts reset on each page load, however, MFU can reproduce the whole trace: early victims 2 and 3 are tied at 1; at reference 8 choose page 1 tied with 4 at 2; at reference 11 evict 4 at 3; at reference 12 evict 5 at 2; at reference 13 all residents have count 1 and 6 may be evicted. Therefore C,D are possible under this interpretation. Preserve official answer D and discrepancy CS-2025-S2-Q47-MFU-COUNTERS. The ambiguity is about unspecified counters, not an error in the displayed trace.
There are processes P1,…,P4 and one instance each of resources R1,…,R4. Ri is assigned to Pi. Current waits are P1→R2, P2→R3, P3→R1, P2→R4, P4→R2. The question calls these wait edges “claim edges.” Which actions make the system deadlock-free? A. Abort P1 alone. B. Abort P3 alone. C. Abort P2 alone. D. Abort P1 and P4.
Select all that apply
Answer & solution
Official answer: C, D
Step through it (5 checks)
Convert each wait on a resource into a wait on its current owner. The wait-for graph has edges P1→P2, P2→P3, P3→P1, P2→P4, P4→P2. It contains the cycles P1→P2→P3→P1 and P2→P4→P2. With one instance of each resource and actual blocking waits, such cycles characterize deadlock.
Aborting P1 removes the first cycle but leaves P2↔P4, so A fails. Aborting P3 has the same problem, so B fails. Aborting P2 removes a vertex common to both cycles. Remaining waits can be satisfied as resources are released, with no cycle left; C works. Aborting P1 and P4 removes one vertex from each cycle, leaving only P2→P3 among the surviving wait edges, so D also works.
The question asks which listed sets suffice, not which set uses the minimum number of abortions. Hence D remains correct even though C resolves the problem with fewer abortions. Use the question's explicit interpretation of “claim” as a current wait; a future potential-claim edge in deadlock-avoidance terminology would not imply the same present deadlock. Select C,D.
A byte-addressable logical space has 2^32 bytes and uses two-level paging with 4096-byte pages. Each inner-page-table entry takes 8 bytes, and an inner table occupies one page. An address contains b outer-index bits, an inner-table entry index, and a data-page offset. Find b.
Answer & solution
Official answer: 11
A 4096-byte data page needs log2(4096)=12 offset bits. An inner page table stored in one 4096-byte page holds 4096/8=512=29 entries. Selecting one of those entries therefore needs 9 bits.
The complete logical address has 32 bits, so the remaining outer index has b=32−12−9=11 bits. As a coverage check, each inner table maps 512 data pages, or 512·4096=221 bytes. A 232-byte space therefore needs 232−21=211 such inner-table slots in its outer table.
Do not allocate 12 independent address bits to the inner entry index just because an inner-table page is 4096 bytes. Entries are 8 bytes each; their byte offsets are aligned, leaving only 9 independent selection bits. The question does not require the entire outer table to fit a single page. Answer: 11.
Separate per-thread state from shared process state
Processes, Threads & System Calls
Tap to enlarge
Which thread statements are true? A Threads can exist only in kernel space. B Every thread has its own open-file descriptor table. C All threads of a process share one execution stack. D Threads in one process are not protected from each other by default.
Select all that apply
Answer & solution
Official answer: D
Approach: A process supplies a shared resource environment; a thread supplies a separate flow of execution inside it. 1. Thread management can be implemented by a user-space library, by the kernel, or by a combination. Kernel space is not the only possibility, so A is false. 2. Threads of a process normally share the process's open-file descriptor table. One thread's file operations can therefore affect descriptors available to the others. B is false. 3. Each thread needs its own program counter, register state and execution stack so that its calls and local execution can progress independently. A common address space does not mean a common stack, so C is false. 4. The stacks and other memory still lie in the shared address space. Ordinary thread boundaries do not provide the protection boundaries that separate processes have; a thread can access or corrupt another thread's memory. Thus D is true. Answer: D only.
In the standard process-state model, which direct transitions are not possible? A Running→Ready; B Waiting→Running; C Ready→Waiting; D Running→Terminated.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Recall the distinction between being eligible to run, actually executing, and being blocked for an event. 1. Running→Ready is possible when the scheduler preempts a process, for example when its time slice expires. The process can still execute, but no longer holds the CPU. Thus A is not selected. 2. Waiting→Running is not a direct transition in this model. Completion of the awaited event makes the process Ready; only a later scheduling/dispatch action makes it Running. Select B. 3. Ready→Waiting is also not direct. A ready process is not executing and therefore cannot issue the blocking operation that makes it wait. It must first be dispatched to Running. Select C. 4. Running→Terminated is possible when a process exits, so D is not selected. Answer: B and C. The question is about edges of the abstract state diagram, not whether a waiting process can eventually run after passing through Ready.
Initially a=b=1. Thread T1 performs a=a+1 followed by b=b+1. Thread T2 performs b=2*b followed by a=2*a. Each assignment is atomic, but threads may interleave. Which set lists every possible final (a,b)? A {(4,4),(3,3),(4,3)}; B {(3,4),(4,3),(3,3)}; C {(4,4),(4,3),(3,4)}; D {(2,2),(2,3),(3,4)}.
Your answer
Answer & solution
Official answer: A
Approach: Preserve each thread's internal order while allowing every merge of the two two-statement sequences. 1. Label T1's statements A: increment a, B: increment b; label T2's statements C: double b, D: double a. Legal interleavings satisfy A before B and C before D. 2. There are six such orders: ABCD gives (4,4); ACBD gives (4,3); ACDB gives (4,3); CABD gives (4,3); CADB gives (4,3); CDAB gives (3,3). For example, ABCD increments each initial 1 to 2 before doubling it to 4. 3. Removing duplicates leaves {(4,4),(4,3),(3,3)}. 4. To see why (3,4) is impossible, a=3 would require D before A, while b=4 would require B before C. Together with the thread orders this demands C<D<A<B<C, an impossible cycle. Answer: A. Atomic assignments prevent lost updates inside an assignment, but do not force a whole thread to run as one unit.
The code is int x=3; while(x>0){fork(); printf("hello"); wait(NULL); x--;}. The printed question assumes successful system calls and asks how many times printf executes. The ordinary POSIX behavior of wait creates a qualification to that premise.
Answer & solution
Official answer: 14
Step through it (24 steps)
Approach: Count statement executions in the process tree, not the number of visible copies of buffered output or the number of processes at one instant. 1. At x=3, the original process forks into a parent and child. Both continue after fork and execute printf, giving 2 executions associated with that loop value. 2. Each process has its own copied x. Both eventually reach x=2, and each forks again, giving 4 printf executions at that level. At x=1, the four process lineages each fork, giving 8 more executions. 3. Total executions are 2+4+8=14. wait may delay a parent while descendants finish, so these levels need not occur simultaneously, but waiting does not erase the later iterations of the parent's loop. A newly created child initially has no child of its own. Its first wait(NULL) therefore returns −1 with ECHILD on POSIX, contradicting the blanket premise that all calls succeed. The code ignores the return value, so the intended count is still 14 when normal no-child wait failures are allowed. Buffered “hello” text can also be copied by fork; that concerns output rendering, not the number of printf executions asked here. Answer: 14 under the intended counting model. Existing discrepancy CS-2024-S1-Q57-WAIT-PREMISE remains preserved.
Translate a page number while preserving the offset
Virtual Memory & Paging
Tap to enlarge
Pages are 2 KB, with addresses starting at zero. Virtual pages 0,1,2,3 occupy physical frames 1,3,2,0 respectively. What decimal physical address corresponds to decimal virtual address 2500? Use 1 KB=1024 bytes.
Answer & solution
Official answer: 6596
Step through it (5 steps)
Approach: Split the virtual address into a page number and page offset. The page table replaces only the page number; the offset stays unchanged. 1. Page size is 2×1024=2048 bytes. Compute 2500=1×2048+452, so the virtual page is 1 and the offset within it is 452 bytes. 2. The mapping for virtual page 1 is physical frame 3. It is the second listed mapping because page numbering starts at 0. 3. Physical frame 3 begins at address 3×2048=6144. Add the same offset: 6144+452=6596. Answer: 6596. The result lies within frame 3's address range [6144,8191], and subtracting its start recovers offset 452. Using page 2 or frame 1 would confuse zero-based numbering with the order in which the mappings are listed.
Which are MMU responsibilities in a paging system? A allocate a new process’s page table; B translate virtual to physical addresses with the page table; C trap on a missing/invalid page-table mapping; D trap on a write to a read-only page.
Select all that apply
Answer & solution
Official answer: B, C, D
Approach: Separate fast hardware checks from policy and resource management performed by the operating system.
1. Derivation. The OS allocates a new process’s page-table structures, so A is not an MMU duty. The MMU uses the mappings to translate addresses, detects absent/invalid mappings and raises page-fault exceptions, and checks permissions such as write protection. Thus B, C, D. A TLB miss alone is not the same as a page being absent from the page table.
2. Explanation and checks. The MMU interprets the mapping and protection information supplied by the OS. For a valid writable mapping it can complete a write translation; for a nonpresent page or forbidden write it transfers control through an exception so the OS can decide what to do. Creating the table and allocating its memory belong to OS management. A TLB cache miss may be resolved by a page-table walk without any missing mapping or page-in operation.
Running process P encounters one of these events. Which always move P to a non-running state in the intended model? A an actually blocking disk-read system call; B a page fault for a page in swap; C a disk interrupt delivering another process’s data; D a timer interrupt.
Select all that apply
Answer & solution
Official answer: A, B
Approach: Ask whether P must wait for something unavailable, rather than merely whether control enters the kernel.
1. Derivation. A genuinely blocking disk read puts P into a waiting state while I/O completes. A fault on a page currently in swap also requires storage I/O, so P is blocked pending page-in. An interrupt for another process need not deschedule P, and a timer interrupt may return to P if no switch is needed. Thus A, B. A mere user-to-kernel mode switch is not necessarily a switch to a different process; blocking in A is taken as actual blocking, as stipulated.
2. Explanation and checks. For A, the CPU cannot complete P’s read until the requested I/O finishes; for B, execution cannot retry the memory access until the swapped page is brought into memory. Both create a reason to block P and run another process or idle. In C, handling an interrupt can make a different process ready without forcing immediate preemption. In D, the scheduler may choose P again. Kernel entry and saving a trap frame alone are not the requested process context switch.
Compare preemptive and nonpreemptive shortest-job schedules
CPU Scheduling
Tap to enlarge
Four processes have (arrival,burst): A(0,10), B(2,6), C(4,3), D(6,7). Find average waiting times for SRTF and nonpreemptive SJF. A 6,7; B 6,7.5; C 7,7.5; D 7,8.5.
Your answer
Answer & solution
Official answer: B
Step through it (2 schedules)
Approach: Draw a separate timeline for each policy, then use waiting=completion−arrival−burst.
1. Derivation. SRTF runs A0–2, B2–4, C4–7, B7–11, D11–18, A18–26. Completion times A26, B11, C7, D18 give waiting times 16, 3, 0, 5 after subtracting arrival and burst, average 24/4=6. Nonpreemptive SJF runs A0–10, C10–13, B13–19, D19–26, giving waiting times 0, 11, 6, 13 and average 30/4=7.5. Answer B. D’s arrival at 6 does not preempt C, whose remaining time is 1.
2. Explanation and checks. For SRTF, at time 2 A has 8 left and B needs 6, so B preempts A. At time 4 B has 4 left and C needs 3, so C preempts B. At time 6 C needs only 1 more, so D does not preempt it. In nonpreemptive SJF, A cannot be displaced after starting at time 0; when it finishes at 10 all others are ready and C is shortest. These decisions explain the difference in the two timelines.
Threads share s1=1,s2=0,x=0. T1: wait(s1); x++; print(x); wait(s2); signal(s1). T2: wait(s1); x++; print(x); signal(s2); signal(s1). Possible outcomes? A T1 prints 1 then T2 prints 2; B T2 prints 1 then T1 prints 2; C T1 prints 1 then deadlock without T2 printing; D T2 prints 1 then deadlock without T1 printing.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Branch on which thread acquires s1 first, since this excludes the other thread from its increment.
1. Derivation. The first successful wait(s1) excludes the other thread. If T1 acquires it first, T1 increments and prints 1, then blocks on initially zero s2 while still holding s1; T2 cannot reach its signal(s2), so this deadlocks, giving C. If T2 acquires first, it prints 1 and signals s2 and s1. T1 can then acquire s1, print2, consume s2, and finish, giving B. Thus B, C.
2. Explanation and checks. In the T1-first branch the wait-for chain is T1 waiting for s2, which only T2 signals; T2 waits for s1, which T1 will not signal until its s2 wait finishes. In the T2-first branch signal(s2) either stores a permit or satisfies a waiting thread, so T1’s later wait(s2) cannot deadlock. The mutual exclusion around x prevents a lost increment, but it does not prevent the circular wait caused by the semaphore ordering.
Minimize and maximize two-level page-table storage
Virtual Memory & Paging
Tap to enlarge
A 32-bit byte-addressed system uses 4 KiB pages and 4-byte PTEs. Each process receives one outer directory page. Inner table pages are allocated only when they hold a valid mapping. A process accesses 2000 distinct pages and none is swapped out. Let X and Y be minimum and maximum total page-table pages over both levels. Find X+Y; do not count data pages.
Answer & solution
Official answer: 1028
Approach: Compute how many data-page mappings each inner table can hold and how many inner tables the directory can address.
1. Derivation. A4KB table page holds 4096/4=1024 entries. The32-bit address divides into 10 outer-index bits, 10 inner-index bits and 12 offset bits, allowing 1024 inner table pages. Minimum table storage for 2000 mapped pages packs them into ceil(2000/1024)=2 inner pages plus the allocated outer page: X=3. Maximum spreads mappings across all 1024 distinct outer entries, possible with 2000 pages, giving Y=1024+1=1025. Thus X+Y=1028. Data pages themselves are not counted.
2. Explanation and checks. To achieve the minimum, map 1024 data pages through one outer entry and the remaining 976 through a second. To achieve the maximum, use at least one data page in each of the 1024 outer regions; the remaining 976 accesses can fall in regions already used. This construction shows the upper bound is attainable, not just theoretical. An outer entry does not itself map one data page: it selects an entire inner table, so counting 2000 table pages would be incorrect.
During a switch between two threads of the same process, which state needs saving? A page-table base register; B stack pointer; C program counter; D general-purpose registers. Select all applicable options.
Select all that apply
Answer & solution
Official answer: B, C, D
Threads in one process share the same virtual address space, so the page-table base normally need not change. Their stacks, instruction positions, and working register values differ, requiring preservation of stack pointer, program counter, and general-purpose registers. Thus B, C, D in the usual same-process thread model.
Teaching detail. A thread must later resume at its own instruction and restore the register values on which that computation depends. It also needs its own stack pointer because function frames and local storage belong to that thread's call chain. Threads in one process ordinarily share the page tables, so changing only the thread does not require switching the address-space root. Real implementations may save additional architecture-specific state, but that does not alter which of the four listed items are logically thread-specific in the stated model.
Which events necessarily enter kernel mode from user mode? A ordinary function call; B malloc call; C page fault; D system call. Select all.
Select all that apply
Answer & solution
Official answer: C, D
A page fault is an exception handled in kernel mode, and a system call deliberately enters kernel mode. An ordinary function call need not do so. malloc may satisfy a request from already acquired user-space allocator memory and therefore does not always invoke the kernel. Hence C, D.
Teaching detail. The word “guarantee” excludes events that merely sometimes need kernel assistance. A user-space function can manipulate registers and its stack entirely in user mode. A malloc implementation often serves a request from a previously acquired heap arena; only some calls need to request more memory from the operating system. A page fault is a processor exception and transfers control to the kernel fault handler. A system call is the designated controlled entry mechanism for requesting kernel services.
Which scheduling policies can cause starvation? A FIFO; B round robin; C priority scheduling; D shortest job first. Preserve all answer sets accepted in the official key.
Select all that apply
Answer & solution
Official answer: A, C, D or C, D
Our answer: C;D under finite-burst FIFO; A;C;D also officially accepted
Priority scheduling can indefinitely postpone a low-priority process when higher-priority work keeps arriving. SJF can similarly starve a long job under a continuing supply of shorter jobs. Round robin provides recurring turns under its usual finite-quantum assumptions. Ordinary FIFO with finite earlier jobs does not starve a waiting job, giving C, D. If an earlier nonpreemptive FIFO job never relinquishes the CPU, a later job can wait forever; the official key additionally accepts A, C, D. Preserve both accepted sets rather than silently selecting one.
Teaching detail. Starvation means indefinite postponement despite continuing operation, rather than a long but finite waiting time. Under conventional finite service times, FIFO eventually reaches each queued job, whereas higher priorities or shorter new jobs can repeatedly overtake an eligible job under the other policies. Round robin with finite quanta and the ordinary finite active-set assumptions revisits each ready process. The official acceptance of a second set including FIFO must not be erased by applying only the conventional model. The nonterminating FIFO-job scenario explains one possible model distinction, not an official stated rationale.
Shared X starts at 10. Five threads each do wait(s); X=X+1; signal(s), and three do wait(s); X=X−1; signal(s). The updates are non-atomic read/modify/write operations. Find minimum final values V1,V2 for a binary semaphore initially 1 and a counting semaphore initially 2. A 15,7; B 7,7; C 12,7; D 12,8.
Your answer
Answer & solution
Official answer: C
With binary semaphore1 the updates are mutually exclusive: V1=10+5−3=12. With counting semaphore2, two updates may overlap. For a witness to V2=7, let one decrement enter and read 10, then pause before its write. Through the second permit run all five increments to completion. Resume the held decrement to overwrite X with 9, then run the other two decrements serially, giving 8 then 7. No value below 7 can arise because a value’s chain of read/write dependencies starts at 10 and contains at most the three decrement operations; increments only increase it. Thus12, 7, option C, under the intended non-atomic read-modify-write interleaving model.
Teaching detail. A semaphore with capacity two limits concurrency but does not make each arithmetic assignment atomic. Two threads can read the same old value and later overwrite each other's results. The witness yielding 7 uses only two simultaneous entrants at any moment: one delayed decrement occupies one permit while all other selected operations use the second. The lower-bound argument follows the ancestry of the final written value, not the total number of writes. Each decrement in that ancestry contributes −1 once at most, and there are only three decrements available.
Row-major C array int D[128][128] is accessed by for i=0..127, for j=0..127, D[j][i]*=10. A page holds 512 array elements and 30 frames are available under LRU demand paging. Count faults in the intended page-aligned, initially nonresident array model; disclose these implicit assumptions.
Answer & solution
Official answer: 4096
Under the usual page-aligned, initially nonresident array model, one page holds four complete rows because 512/128=4. The inner loop scans down a column and touches 32 pages in order, with four consecutive accesses per page. Only the first access of each four-row group faults. A cyclic traversal of 32 distinct pages with only 30 LRU frames has a miss on each page at every column: the reuse distance is 31 other pages. Hence 128 columns times 32 faults per column gives 4096. The standard answer implicitly assumes the array starts at a page boundary and ignores unrelated memory references. A non-page-aligned placement or a different initial residency can change the count; these are not specified explicitly.
Teaching detail. For aligned storage, element D[j][i] has page number floor((128j+i)/512)=floor(j/4) for each fixed i∈[0,127]. The page stream per column is therefore 0 repeated four times, 1 repeated four times, through 31 repeated four times. Only the first access to each repeated group faults. Between two uses of any page in successive columns are 31 distinct other pages, exceeding the 30-frame capacity, so no page survives until its next reuse. Multiplying 32 by 128 gives the count; multiplying 128² would ignore within-page hits.
A 57-bit virtual address uses an L-level tree of page tables. Pages are 4 KiB; each page-table entry is 8 bytes at every level. Find L under the conventional one-page-per-table-node layout.
Answer & solution
Official answer: 5
Step through it (8 steps)
A 4 KiB page has a 12-bit offset. Under the conventional one-page-per-page-table-node layout, each node holds 4096/8=512 entries and contributes 9 index bits. The virtual page number has 57-12=45 bits, requiring L=45/9=5 levels. The page-sized table-node convention is implicit in this standard multilevel-paging calculation.
Teaching detail. The address must be partitioned into a page offset and a sequence of table indexes. Offset bits select one byte within 4096 bytes, so there are 12. Each page-sized table contains 512 entries, whose selection requires 9 bits. Five indexes account for 45 virtual-page bits and, together with the 12-bit offset, exactly cover 57 bits. In cases where this division is not exact, the top-level index can be shorter; here no partial level is needed. The result depends on page-sized table nodes, not merely on entry width alone.
Three infinite threads run on one CPU with binary semaphores. T1 repeats wait(S3); print C; signal(S2). T2 repeats wait(S1); print B; signal(S3). T3 repeats wait(S2); print A; signal(S1). Which initialization forces BCABC… despite arbitrary context switches? A (S1,S2,S3)=(1,1,1); B (1,1,0); C (1,0,0); D (0,1,1).
Your answer
Answer & solution
Official answer: C
T2 waits on S1 and prints B, then signals S3. T1 waits on S3 and prints C, then signals S2. T3 waits on S2 and prints A, then signals S1. Initialize only S1 to 1, with S2=S3=0, to force B→C→A repeatedly. That is C. This assumes ordinary successful semaphore operations and eventual scheduling of enabled threads.
Track the unique token: (1,0,0) enables only T2. Its wait consumes S1 and its signal creates the S3 token; then T1 creates S2; then T3 restores S1. Context switching can delay progress, but cannot permit a different letter while its semaphore is zero.
Select true deadlock statements: A circular wait is necessary; B with multiple instances per resource a wait-for cycle guarantees deadlock; C an unsafe allocation necessarily leads to deadlock; D if all resource-allocation edges are assignment edges, there is no deadlock.
Select all that apply
Answer & solution
Official answer: A,D
Circular wait is a necessary Coffman condition, so A is true. With multiple instances per resource, a cycle alone need not imply deadlock: an external holder can release an instance and let a waiting process proceed. An unsafe state means some future demands may deadlock, not that deadlock must occur, so C is false. If every resource-allocation edge is an assignment, there are no request edges and therefore no waiting cycle, making D true. Thus A, D under the usual resource-allocation interpretation of the question’s wait-for terminology.
An unsafe state lacks a guaranteed completion sequence for all declared maximum demands; it need not be currently deadlocked. Processes may request less than their maxima or release resources. Without request edges no process is represented as waiting, so assignment-only graphs cannot contain the alternating request/assignment cycle needed for deadlock.
Identify the intended FALSE virtual-memory statement: A a TLB searches all valid entries associatively in parallel by virtual page number; B a TLB hit followed by a cache miss guarantees the word is in main memory; C a given inverted page table has identical access time for all virtual addresses; D distinct virtual addresses hashing to the same value necessarily have different memory access times. Retain literal-model qualifications.
Your answer
Answer & solution
Official answer: C
Our answer: C in the intended textbook model; D is also overbroad literally
Inverted page-table lookup can scan or follow collision chains of different lengths, so access time is not always identical: C is false. The intended model treats A as a fully associative TLB search and B as a valid, coherent TLB translation implying resident data memory. D is intended to distinguish positions in a serial hash collision chain, but its literal universal claim is not valid: two distinct virtual byte addresses in the same virtual page share the same hashed page entry and may have identical access time. Other collision-resolution and caching implementations also defeat the asserted necessity. Preserve official C, while disclosing that the question needs distinct-page, serial-chain and textbook TLB assumptions to make it uniquely false.
An inverted table has one entry per physical frame and needs to locate a process/virtual-page pair; search or hash-chain length can vary by input. In a serial collision chain, different pages at different positions may take different time, explaining the intended D. But distinct byte addresses with the same page number use the same entry, providing a concrete counterexample to its unqualified wording.
P,Q,R,S arrive at time zero in that order. Round-robin quantum is 4. Observed switches include exactly one S→Q, one R→Q, two Q→R and no S→P, counting switches after termination too. Which burst tuple (P,Q,R,S) is impossible? A (4,10,6,2); B (2,9,5,1); C (4,12,5,4); D (3,7,7,3).
Your answer
Answer & solution
Official answer: D
With quantum 4, A, B, C each give execution segments P, Q, R, S, Q, R, Q: P and S finish in their first turn, R in its second, and Q in its third. This yields two Q→R switches, one R→Q and one S→Q. For D, burst times (3, 7, 7, 3) instead give P, Q, R, S, Q, R: Q finishes on its second turn, leaving no final R→Q switch. Thus D cannot produce the stated trace.
For option D the slices have lengths 3,4,4,3,3,3 respectively. The running order P,Q,R,S,Q,R has Q→R twice and S→Q once, but no R→Q. For A the slice lengths are 4,4,4,2,4,2,2, so P,Q,R,S,Q,R,Q satisfies all stated counts. B,C have that same order because Q needs three turns and R two.
A 100-block file exists in contiguous-allocation system A and linked-allocation system B. Insert one memory-resident block between original blocks 50 and 51. There is enough free space after the contiguous file; file-control blocks are in memory. If the respective disk-access counts are nA,nB, find nA+nB.
Answer & solution
Official answer: 153
For contiguous allocation, shift original blocks 51 through 100 one position to the right, working backward. Each of the 50 blocks is read and written, costing 100 disk accesses; writing the new memory-resident block costs one more, so nA=101. For linked allocation, follow the chain by reading blocks 1 through 50, costing 50 reads. Retain block 50 and its old next pointer in memory, write the new block pointing to original block 51, and rewrite block 50 to point to the new block: two writes, so nB=52. The sum is 153. This is the usual uncached data-block I/O model, with file-control blocks already in memory and no extra metadata-flush charges.
The backward shift in A is essential: forward shifting would overwrite block 52 before reading its original contents. In B, the data of blocks 51…100 stay in place; only the predecessor’s link and new block are written. Traversing 50 blocks rather than reading all 100 is sufficient to locate the insertion point.
Four initially empty demand-paging frames use LRU. References: 7,2,7,3,2,5,3,4,6,7,7,1,5,6,1. Find page faults/accesses rounded to one decimal.
Answer & solution
Official answer: 0.6
Step through it (17 steps)
Simulating four LRU frames gives faults at reference positions 1, 2, 4, 6, 8, 9, 10, 12, 13, for the values 7, 2, 3, 5, 4, 6, 7, 1, 5. The other six references hit. In particular, the second consecutive 7 hits, and the last 6 and 1 both remain resident. Hence the fault rate is 9/15=0.6.
Maintain recency oldest→newest after each access: [7]; [7,2]; [2,7]; [2,7,3]; [7,3,2]; [7,3,2,5]; [7,2,5,3]; [2,5,3,4]; [5,3,4,6]; [3,4,6,7]; [3,4,6,7]; [4,6,7,1]; [6,7,1,5]; [7,1,5,6]; [7,5,6,1]. On a full-frame miss remove the oldest before appending; on a hit move the referenced page to newest.
Select all correct paging statements. A paging addresses external fragmentation; B page size has no impact on internal fragmentation; C paging incurs memory overhead; D multilevel paging is necessary to support different page sizes.
Select all that apply
Answer & solution
Official answer: A; C
Fixed-size page frames avoid external fragmentation, while partially filled pages still incur internal fragmentation whose amount depends on page size. Page tables and related translation metadata require memory overhead. Multiple page sizes can be supported without requiring multilevel page tables, so that mechanism is not logically necessary. Thus A, C.
External fragmentation means sufficient free space exists but is scattered into unusable variable-size gaps. Equal-sized frames avoid that requirement for contiguous allocation. Internal fragmentation occurs inside the final allocated page, potentially wasting almost one page per allocation. Translation requires page-table entries and sometimes additional levels or supporting structures. The number of page-table levels and the set of supported page sizes are separate design choices.
Which standard C library functions always invoke a system call when executed by a single-threaded UNIX/Linux process? Select all: A exit; B malloc; C sleep; D strlen.
Select all that apply
Answer & solution
Official answer: A; C
Normal process termination through exit eventually asks the kernel to terminate the process. A blocking sleep asks the kernel to suspend execution and arrange resumption. malloc can satisfy a request from existing user-space heap storage, and strlen scans user-space memory, so neither always needs a system call. Thus A, C in the ordinary UNIX/Linux library execution model. This is a systems-interface question, not a claim about abnormal nonreturning exit handlers or arbitrary replacement libraries.
Library routines are not synonymous with system calls. strlen needs only reads of its argument up to the terminating zero byte. malloc commonly obtains a larger region once, then fulfills many allocations from its own free lists without entering the kernel. In contrast, normal process exit changes kernel process state, and a blocking sleep requires kernel scheduling/timer support. The exam's 'always' language is interpreted under these normal library semantics.
A directory foo is implemented as an unsorted linear list of nodes containing file names and metadata including data-block pointers. Which successful operations necessarily require a full scan? A create a new file; B delete an existing file; C rename an existing file; D open an existing file.
Select all that apply
Answer & solution
Official answer: A; C
Our answer: A; C under fresh-name uniqueness checking
Creating a new file requires checking that its proposed name is absent from the entire unsorted directory list. Renaming to a new unused name similarly needs an absence check. Deletion or opening can stop when the existing entry is found, so they do not necessarily scan the entire list. Thus A, C under the intended simple-directory model. A real rename operation that is permitted to replace an existing target, or an indexed name cache, changes the necessity claim; those are outside this linear-list/fresh-name interpretation.
A successful lookup can stop at the matched name, perhaps the first node, so opening/deleting do not necessarily scan all nodes. To establish that a proposed new name is absent, finding no match in only a prefix is insufficient: it could occur in the unvisited suffix. Creation and a rename to a fresh name must therefore inspect the whole directory. The distinction is existential lookup versus proof of absence, not simply whether the operation changes disk contents.
Three processes arrive at time zero with CPU bursts 16,20,10 milliseconds. With prior burst knowledge and non-preemptive scheduling, what is the minimum average waiting time, rounded to the nearest integer in milliseconds?
Answer & solution
Official answer: 12
Shortest-job-first minimizes total waiting time when all jobs arrive together and burst lengths are known. Execute bursts 10, 16, 20. Their waiting times are 0, 10, 26, whose average is 36/3=12 milliseconds.
For three jobs of lengths a,b,c in that order, total waiting is 0+a+(a+b)=2a+b. Placing shorter jobs earlier minimizes this weighted sum. More generally, swapping adjacent lengths x>y reduces the waiting total by x−y while leaving later completion times unchanged. This exchange argument proves shortest-job-first is optimal here. Completion/turnaround times would be 10,26,46 and are not the requested waiting times.
Shared counter=0 and counting semaphore S=5. Five threads concurrently execute parop(){wait(S); wait(S); counter++; signal(S); signal(S);} The increment is explicitly non-atomic. Select possible outcomes: A counter=5 after all complete; B counter=1 after all complete; C counter=0 after all complete; D all five threads deadlock.
Select all that apply
Answer & solution
Official answer: A; B; D
Serially completing all five operations gives counter=5, proving A. For B, let one thread acquire two permits and read counter=0, then pause before writing. The other four can each acquire two of the remaining three permits, increment and finish sequentially. Finally the paused thread writes its stale result 1 and finishes. C cannot occur after successful completion: every write is a nonnegative value read plus one, so the final write is at least 1. For D, let each of the five threads acquire its first permit before any acquires a second. All then block on the second wait with no permit left and none able to signal. These are pseudocode read-modify-write interleavings, as explicitly assumed.
The semaphore limits simultaneous holders of permits but does not provide mutual exclusion for counter++: two threads can each hold two permits out of five. For final value 1, the crucial schedule is a delayed stale write from the first thread after the other four have successively completed. For deadlock, no thread reaches its first signal because every thread is stuck on its second wait. Replacing the two waits by one atomic acquisition of two permits would remove that particular hold-and-wait pattern, but that is not the given code.
Select correct CPU scheduling statements: A turnaround includes waiting; B goal is only maximize CPU use and minimize throughput; C round robin works without advance CPU burst lengths; D preemption requires hardware support.
Select all that apply
Answer & solution
Official answer: A; C; D
Turnaround measures arrival-to-completion and includes waiting, so A. Throughput should ordinarily be increased, not minimized, refuting B. Round-robin only needs a time quantum, not advance knowledge of each burst, giving C. Preemption of an otherwise running process requires hardware interruption support, typically a timer interrupt, giving D in the standard OS model.
For an ordinary CPU-only job, turnaround=completion−arrival=waiting+CPU service; I/O time is also included if relevant. Round robin dispatches a ready job for at most a quantum, regardless of its remaining burst. A timer interrupt lets the OS regain control even if the process does not voluntarily yield.
Two separate processes each execute: global x=0 and global lock L1; main creates two threads running foo, joins both, prints x. foo has local y=0; acquire L1; x=x+1;y=y+1;release L1;print y. A both processes print x=2; B at least one prints x=4; C some thread prints y=2; D all four threads print y=1.
Select all that apply
Answer & solution
Official answer: A; D
Each process has its own address space, hence its own global x and lock. Within one process the lock serializes the two increments, giving x=2 after both threads finish. Each invocation has its own stack-local y, initialized to zero and incremented once, so every thread prints 1. The two processes do not share x merely because it is global. Thus A, D.
Threads share a process's global variables and synchronization objects, but ordinary separate processes do not share those objects without explicit shared-memory setup. Joining both threads ensures main prints after both increments. Each thread's y is an automatic local variable, so the lock is not needed to protect y, though it is needed for the shared x increment within each process.
One instance per resource type, exclusive ownership. OWNRESOURCE(R) acquires global lock L; if free, acquire R and release L; else if owned by another P, terminate P after freeing its resources, acquire R, restart P, release L. Select: A prevents deadlocks; B may livelock; C may starve; D violates mutual exclusion.
Select all that apply
Answer & solution
Official answer: A; B; C
Under the intended atomic termination/resource-release model, a requester never waits for another process to release its resource: it terminates that owner and takes the resource while holding L. Thus no circular resource wait develops, giving A. Two restarted processes can repeatedly take resources from and restart each other without completing, giving livelock B. An unfair execution can repeatedly kill the same process before it finishes, giving starvation C. The global lock and removal of the previous owner preserve exclusive ownership, so D is false. This assumes requests concern resources not already owned by the requester and that termination/restart do not themselves block on L; those implementation details are abstracted by the pseudocode.
For a livelock witness, let P hold A and Q hold B. P requests B, kills and restarts Q; later restarted Q requests a resource now held by P and kills/restarts P. Repeating such interference can prevent either from completing despite activity. A lock provides mutual exclusion, not fairness or progress. The answer depends on treating termination and resource release as atomic successful operations in the model.
39-bit virtual address splits as 9-bit level1,9-bit level2,9-bit level3,12-bit offset. Pages are 4KB and all PTEs 8 bytes. Process maps 2GB virtual to 2GB physical. Find minimum total page-table memory in KB, with binary KB/GB.
Answer & solution
Official answer: 4108
Each page-table page holds 4096/8=512 entries. The2GB mapping needs 231/212=219 leaf entries, hence 1024 level3 pages. Packing these contiguously minimizes higher levels: 1024/512=2 level2 pages and one level1 root page. Total=(1024+2+1)*4KB=4108KB. This is the minimum with allocated whole page-table pages and a densely placed virtual mapping.
Each level-2 page indexes up to 512 level-3 pages, which collectively map 512×512×4KB=1GB. Thus the 2GB region can occupy two such subtrees under one root. Sparse placement could require more page-table pages; the word minimum permits contiguous, suitably aligned placement. Physical page contents consume 2GB but are not part of page-table overhead.
Allocate one process into a memory hole, with no exact fit. Which comparison of newly remaining holes is always true? A first-fit remainder > next-fit remainder; B worst-fit remainder > first-fit remainder; C best-fit remainder ≤ first-fit remainder; D next-fit remainder ≤ best-fit remainder.
Your answer
Answer & solution
Official answer: C
Worked explanation
Let p be the process size and let H be the set of adequate hole sizes. Best fit chooses hB=min H. If first fit chooses hF∈H, then hB≤hF, and subtracting p gives hB−p≤hF−p. This is exactly C and allows equality. For counterexamples to strict claims A and B, take a single adequate hole: all policies choose it, so no remainder is strictly larger. D fails with adequate holes of sizes 10 and 20 for a process of size 6 when next fit chooses 20: its remainder 14 exceeds best fit’s 4. The cursor position matters for next fit, not for the minimum defining best fit.
Derivation and answer
Best fit chooses the smallest adequate hole. Subtracting the same process size from that hole and from the first-fit hole preserves the ≤ relation, so the best-fit remainder is never larger. Strict inequalities in the other options can fail when policies select the same hole. Thus C.
For preemptive scheduling, which direct state transitions are possible? I running→ready; II ready→running; III blocked→running; IV blocked→ready. Options: A I,II,III; B II,III; C I,II,IV; D all four.
Your answer
Answer & solution
Official answer: C
Worked explanation
Ready means eligible to run but not currently assigned a CPU; blocked means waiting for an event and therefore not eligible. A timer interrupt can preempt a running process into ready (I). Dispatch selects a ready process to run (II). I/O completion changes blocked to ready (IV); the scheduler may then dispatch it, but that is a second transition, not the direct blocked→running edge in III. The standard graph also has running→blocked when a process requests I/O. Distinguishing a possible two-edge path from one direct transition is the key to choosing C.
Derivation and answer
Preemption gives running→ready; dispatch gives ready→running; completion of the awaited event gives blocked→ready. In the standard state-transition model a blocked process becomes ready before dispatch, not directly running. Thus I, II, IV, C.
Each of n processes runs this once, with shared count=0, semaphores a=1,b=0, and P not using count: P; wait(a); count=count+1; if(count==n) signal(b); signal(a); wait(b); signal(b); Q; What is guaranteed? A no Q before all P finish; B at most two in Q; C P mutually exclusive; D at most n−1 in P.
Your answer
Answer & solution
Official answer: A
Worked explanation
Before any process can signal b, some process must observe count=n while holding a. Since increments are protected and occur after P, count is exactly the number of completed P sections that have passed the increment. Thus the first b signal proves every P has completed. The subsequent wait(b);signal(b) passes a token along the waiting processes; it gates entry but does not keep b held during Q. A process may enter Q and another may immediately enter too, so no mutual-exclusion or two-process bound follows. P is outside both waits, so every process can be in P simultaneously. This is a one-use barrier, not a reusable barrier because count is never reset.
Derivation and answer
Semaphore a serializes count increments after each process finishes P. Semaphore b starts 0 and is signaled for the first time only when count=n, so no process can pass wait(b) before all have finished P. Each passing process signals b to release the next waiter. The signal occurs before Q, so Q is not mutually excluded or limited to two entrants. Thus this is a barrier, A.
SSTF disk scheduling begins at cylinder 100 with requests P:155,Q:85,R:110,S:30,T:115. Which is false? A T before P; B Q after S but before T; C direction reverses between service of Q and P; D R before P.
Your answer
Answer & solution
Official answer: B
Worked explanation
Recompute the nearest remaining request after every move. From 100, distances to P,Q,R,S,T are 55,15,10,70,15, so R wins. From 110, T is 5 away; from 115, Q is 30 away versus P at 40 and S at 85, so Q wins. From 85, S is 55 away versus P at 70, so S wins, leaving P. The path is 100→110→115→85→30→155. T and R both precede P, and movement changes from decreasing to increasing at S between Q and P. B reverses the actual relation of Q to both S and T.
Derivation and answer
From100, nearest requests are R110 thenT115 thenQ85 thenS30 thenP155. The head distances for these choices are 10, 5, 30, 55, 125. Thus Q is before S and after T, making B false. The other assertions hold, including reversal at S between servicing Q andP.
All processes arrive at time 0. Burst times: P1=8,P2=7,P3=2,P4=4 ms. Compare SJF with RR, quantum 4 ms and initial order P1,P2,P3,P4. Find the absolute difference in average turnaround times, to two decimal places.
Answer & solution
Official answer: 5.25
Step through it (2 schedules)
Worked explanation
Turnaround time is completion minus arrival, not just waiting time. With all arrivals zero, completion times can be averaged directly. SJF Gantt timeline: 0—P3—2—P4—6—P2—13—P1—21. RR timeline: 0—P1—4—P2—8—P3—10—P4—14—P1—18—P2—21. After their first slices P1 has 4 ms remaining and P2 has 3; P3 and P4 finish in their first slices and leave the queue. In process order P1,P2,P3,P4, completions are (21,13,2,6) for SJF and (18,21,10,14) for RR. Sums 42 and 63 divided by 4 give the required difference 5.25 ms.
Derivation and answer
SJF executes P3, P4, P2, P1, completing them at 2, 6, 13, 21ms. Since arrivals are all zero, average turnaround is 42/4=10.5ms. RR with quantum 4 executes P1[0, 4], P2[4, 8], P3[8, 10], P4[10, 14], P1[14, 18], P2[18, 21]. Completion times are 18, 21, 10, 14ms, averaging 63/4=15.75ms. The absolute difference is 15.75−10.5=5.25ms, with zero context-switch overhead as conventionally assumed.
A one-level page table is in main memory. Main-memory access=100 ns, TLB lookup=20 ns, each disk page transfer=5000 ns. TLB hit ratio=95%, stated page-fault rate=10%, dirty victim on 20% of page faults, negligible TLB-update time. Find average access time to one decimal. The source does not explicitly state what conditions the fault rate.
Answer & solution
Official answer: 154.5 to 155.5
Our answer: 155.0 under conditional page-fault convention
Worked explanation
Under the intended conditional model, split all references into disjoint cases: TLB hit probability .95 and time 120; nonfaulting TLB miss probability .05×.9=.045 and time 220; clean-victim fault probability .05×.1×.8=.004 and time 5220; dirty-victim fault probability .05×.1×.2=.001 and time 10220. These probabilities sum to 1. Weighted contributions are 114,9.9,20.88,10.22 ns, totaling 155.0 ns. The 220 ns baseline counts lookup, page-table read and final data access; the faults add one or two disk transfers. This arithmetic follows the official convention, not a uniquely specified real-system fault handler. An unconditional 10% page-fault rate cannot coexist with 95% valid resident TLB hits in this simple model.
Derivation and answer
A TLB hit costs 20+100=120 ns; a nonfaulting miss costs 20+100+100=220 ns. Average disk work per page fault is 5000+0.20*5000=6000 ns. Interpreting the stated 10% page-fault rate as conditional on a TLB miss gives 0.95*120+0.05*(220+0.10*6000)=155.0 ns, within the official 154.5–155.5 range. The question does not explicitly say conditional: an unconditional 10% fault probability is inconsistent with a 95% valid resident TLB hit ratio in this standard model, since faults can occur only among the 5% misses. Official scoring therefore depends on the conditional interpretation and neglects extra fault-handler/restart overhead.
A Unix/Linux program runs for(i=0; i<10; i++), calling fork() whenever i%2==0, then returns. Assuming all forks succeed, find the total number of newly created child processes, excluding the original process.
Answer & solution
Official answer: 31
Step through it (33 steps)
Method: count the branching rounds; every process alive at a fork round executes that fork and then continues the same loop.
1. The loop values are 0 through 9. The even values 0,2,4,6,8 cause five fork rounds; odd iterations create no processes. 2. A successful fork creates one new child from each currently executing process. Both parent and child continue from immediately after the fork with their own copy of i, so both participate in later rounds. 3. Starting from one process, the total after successive rounds is 2,4,8,16,32. The numbers of new children produced at those rounds are respectively 1,2,4,8,16. 4. Adding the created children gives 1+2+4+8+16 = 31. Equivalently, subtract the original from the final total: 25−1 = 31.
Result: 31 child processes in total, including descendants created by children. Counting only the five calls made by the original parent would omit later generations. The result assumes no fork failure or external process termination.
Shared D starts at 100. Concurrent processes perform P1: D=D+20; P2: D=D−50; P3: D=D+10 on a time-shared uniprocessor. If X and Y are the minimum and maximum possible final values, find Y−X. Use the intended model in which each assignment's read and write can be interleaved with other processes.
Answer & solution
Official answer: 80
Method: split each assignment into a read, local arithmetic, and write; an interrupted process may later overwrite a newer shared value using its earlier read.
1. To attain the minimum, let P2 read 100 and compute 50 but delay its write. Let P1 and P3 complete their increments, then let P2 write its stored 50 last. The final result is 50, because the earlier increments are overwritten. 2. To attain the maximum, let P1 and P2 both read 100. P2 writes 50 first; P1 then writes its stored 120, overwriting the decrement. P3 reads 120 and writes 130. The final result is 130. 3. These are also bounds. Trace the final write back through the value read by its writer, and recursively through preceding writes. This dependency chain starts at 100 and can include each process's change at most once. Its smallest possible sum includes −50 but no positive changes, giving 50; its largest includes +20 and +10 but not −50, giving 130. 4. Both bounds are attainable by steps 1 and 2, so X=50 and Y=130. Their difference is 130−50=80.
Result: 80. If whole assignments were atomic, every order would instead end at 80; the intended model permits preemption within an assignment. Under that different atomic model X=Y=80 and Y−X would be zero. A uniprocessor prevents simultaneous instruction execution but does not by itself make a multi-instruction update atomic.
A word-addressable machine has 64-bit virtual addresses, 48-bit physical addresses, 8 kB pages, 4-byte words, and 128 valid TLB entries. Find the maximum distinct virtual word addresses translatable without a TLB miss: A 16×2^10, B 256×2^10, C 4×2^20, D 8×2^20.
Your answer
Answer & solution
Official answer: B
1. One TLB entry caches the translation for an entire virtual page, not just one word. Every offset within a cached page can use that same entry. 2. Using the intended binary memory units, a page contains 8×1024=8192 bytes. Since an address identifies a four-byte word, the number of addressable words per page is 8192/4=2048=211. 3. To maximize coverage, let the 128=27 valid entries represent different virtual pages. The number of distinct covered word addresses is 27×211=218=262144. 4. Rewriting 262144 as 256×210 identifies option B. The cached byte span would be 1 MiB, but reporting that number of addresses would ignore word addressability. 5. The 64-bit and 48-bit widths bound the larger virtual and physical spaces; they do not change the number of offsets covered by these 128 page translations.
All instances of resource R are allocated. Process i holds Xi and may request at most Yi additional instances. Exactly p and q have Yp=Yq=0. Which condition guarantees no other process completes? A Xp+Xq<min other Yk; B Xp+Xq<max other Yk; C min(Xp,Xq)≥min other Yk; D min(Xp,Xq)≤max other Yk.
Your answer
Answer & solution
Official answer: A
Our answer: A under actual-remaining-demand interpretation
1. First solve the intended resource-demand model, where Yi is the amount process i still needs in order to finish. Because no resource instances are currently free, only p and q have enough resources to finish immediately. 2. Once both finish and release what they hold, the total available pool is A=Xp+Xq. No other process has released anything yet. 3. If A<min{Yk:k≠p,q}, then A is smaller than every remaining demand. There is no possible next finishing process, so the system cannot enlarge its free pool by further completions. This yields option A under that model. 4. Comparing A with the maximum demand, as in B, blocks only at least one large-demand process; a smaller-demand process may finish and release resources. C and D similarly do not establish insufficiency for every remaining process. 5. The literal wording is weaker: each Yi is an upper bound on additional requests, not a necessary demand. A process with positive Yi could actually need zero more instances and finish. For example, with Xp=Xq=1 and another process's bound Yk=3, A holds, yet that process may finish without requesting anything. 6. Thus the keyed A needs the actual-remaining-demand interpretation. Under upper bounds alone, the claimed guarantee is not justified. Preserve this model caveat rather than presenting A as unconditional.
Four processes have (arrival, CPU burst) in ms: P1=(0,3), P2=(1,1), P3=(3,3), P4=(4,Z). Under preemptive shortest-remaining-time-first scheduling their average waiting time is 1 ms. Determine Z.
Answer & solution
Official answer: 2
1. SRTF always runs the available process with least unfinished CPU time. P1 runs from 0 to 1, leaving 2 ms. P2 arrives at 1 with burst 1, preempts P1, and finishes at 2. 2. P1 resumes at 2. When P3 arrives at 3, P1 has only 1 ms left versus P3's 3 ms, so P1 continues to completion at 4. P1 has waited 1 ms; P2 has waited 0; P3 has already waited 1. 3. At time 4, P4 arrives. If Z<3, P4 runs first for Z ms, then P3 runs for 3 ms. The total waiting time is W1+W2+W3+W4=1+0+(1+Z)+0=2+Z. 4. Average waiting 1 over four processes requires total waiting 4. Thus 2+Z=4, giving Z=2, which satisfies the branch assumption Z<3. 5. Check the other branch: if Z≥3, running P3 first adds a wait of 3 to P4, giving total 1+0+1+3=5. For Z=3 either tie order gives the same total, so this branch cannot give average 1. 6. With Z=2, completion times are P1=4, P2=2, P4=6, P3=9. Using waiting=completion−arrival−burst gives 1,0,0,3 respectively, totaling 4. Answer 2 ms.
An inode has 12 direct pointers, one single-indirect pointer, and one double-indirect pointer. Blocks are 4 kB and each disk-block address is 32 bits. Find the maximum file-data size in GB, rounded to one decimal place; retain the official key's alternative unit ranges.
Answer & solution
Official answer: 3.7 to 3.8 OR 4.0 to 4.1
Our answer: 4.0 under consistent binary units; alternate range retained
1. A block pointer occupies 32/8=4 bytes. Under the usual binary convention, one block is B=4096 bytes, so an indirect block stores 4096/4=1024 addresses. 2. Direct pointers address 12 data blocks. The single-indirect pointer addresses one metadata block containing 1024 data-block pointers, so it contributes 1024 data blocks. 3. The double-indirect pointer reaches a first-level metadata block containing 1024 pointers to second-level indirect blocks. Each second-level block addresses another 1024 data blocks. Its contribution is 1024²=1,048,576 data blocks. 4. Total file-data capacity is (12+1024+1,048,576)×4096=4,299,210,752 bytes. Metadata blocks are not part of the file's data size and must not be added to this total. 5. In binary GiB, divide by 230 to obtain 4.003952... GiB, rounding to 4.0. This is the conventional intended calculation even though the question prints GB. 6. Units matter. Taking kB as 1000 gives (12+1000+1000²)×4000=4,004,048,000 bytes: 4.0 decimal GB, or 3.7 GiB after rounding. Taking binary blocks but decimal GB instead gives 4.3, not an accepted supplied range. Preserve the official disjoint intervals 3.7–3.8 OR 4.0–4.1 rather than concealing this unit ambiguity.
A memory access costs M when resident and total D when it faults. Observed mean is X. Find fault rate: A (D−M)/(X−M); B (X−M)/(D−M); C (D−X)/(D−M); D (X−M)/(D−X).
Your answer
Answer & solution
Official answer: B
Method
Partition accesses into the two mutually exclusive outcomes. With fault probability f, their probabilities are f and 1−f, not two independent rates. The weighted mean X=M+f(D−M) interpolates between M at f=0 and D at f=1. These endpoints immediately distinguish the fault probability from C, which is the hit probability. For ordinary D>M, valid observations satisfy M≤X≤D.
Solution
If f is the fault rate, X=(1−f)M+fD=M+f(D−M). Therefore f=(X−M)/(D−M), B, assuming the stated fault access time D is the total fault-case time and D≠M.
Three processes share four identical resource instances. Each can need at most K, requesting and releasing one at a time. Find the largest K guaranteeing no deadlock.
Answer & solution
Official answer: 2
Method
If every unfinished process has fewer than its maximum requirement, each may hold at most K−1 while waiting for another instance. With K=2, three such waiting processes can hold at most three resources, leaving the fourth available to let one finish. Releasing its resources then enables the others. For K=3, a feasible allocation (2,1,1) consumes all resources while each process can still request one; no request can be granted. This supplies both safety and a tight counterexample.
Solution
For n=3 processes each requiring at most K identical resources, a sufficient and tight universal bound is R≥n(K−1)+1: for K=2, any allocation in which all three processes still need another instance leaves at least one of the four resources free; for K=3 the allocation (2,1,1) can instead exhaust all resources with all processes waiting. With R=4, K=2 satisfies 4≥4, while K=3 permits holdings2, 1, 1 and all waiting. Thus the largest guaranteed-safe K is 2, assuming completed processes release their resources.
Available (E,F,G)=(3,3,0). Allocation rows P0…P3 are (1,0,1),(1,1,2),(1,0,3),(2,0,0); Max rows are (4,3,1),(2,1,4),(1,3,3),(5,4,1). Choose A safe already; B unsafe but safe with one extra E; C likewise extra F; D likewise extra G.
Your answer
Answer & solution
Official answer: A
Step through it (6 steps)
Method
Banker’s safety test asks whether there exists an order in which each process can obtain all its remaining need and release its allocation. Need=Max−Allocation, computed component by component. After hypothetically finishing a process, Work increases by its original Allocation, not by its Max: any temporary extra resources lent from Work are returned, cancelling out. Initially P0 and P2 are both eligible. Exhibiting one complete order suffices; the algorithm need not show that every arbitrary request order is safe.
Solution
Subtract Allocation from Max to obtain remaining needs P0=(3, 3, 0), P1=(1, 0, 2), P2=(0, 3, 0), P3=(3, 4, 1). Starting Work=(3, 3, 0), complete P0 to get(4, 3, 1), then P2 to get(5, 3, 4), then P1 to get(6, 4, 6), then P3. This safe sequence proves A.
A size-N buffer uses empty=0, full=N, mutex=1. Here empty counts readable items and full writable slots. Producer executes wait(P),wait(mutex),add,signal(mutex),signal(Q); consumer wait(R),wait(mutex),remove,signal(mutex),signal(S). Choose A full/full/empty/empty; B empty/empty/full/full; C full/empty/empty/full; D empty/full/full/empty.
Your answer
Answer & solution
Official answer: C
Method
Follow the definitions rather than familiar variable names. Before adding an item, the producer must reserve one writable slot, so it waits on the semaphore initially N. After insertion it creates a readable item, so it signals the semaphore initially 0. The consumer performs the reverse transfer. Waiting for a resource before taking mutex also avoids holding the buffer lock while blocked for another process to make progress. Each successful pair of operations preserves the bounded-buffer accounting.
Solution
Use the definitions supplied, which reverse the usual semaphore names. full starts N and counts producer-writeable slots; empty starts 0 and counts readable items. The producer waits(full) and signals(empty); the consumer waits(empty) and signals(full), each using mutex for buffer access. Thus P=full, Q=empty, R=empty, S=full, C.
Disk has 4 platters, 200 cylinders and 256 sectors/track. Requests [sector,cylinder,platter]: [120,72,2],[180,134,1],[60,20,0],[212,86,3],[56,116,2],[118,16,1]. Head starts sector 100,cylinder 80 moving upward. SSTF movement costs are stated as 20 mW per 100 cylinders plus 15 mW per reversal; rotation/platter costs ignored. Find the intended total.
Answer & solution
Official answer: 85
Our answer: 85 under the stated additive-cost convention
Step through it (8 steps)
Method
SSTF chooses nearest pending cylinder, not the next request in the current direction. At 80 choose 86 (6 away), then 72 (14 away). From 72, 116 is 44 away versus 20 at 52; then 134 is nearest. The remaining requests are 20 and 16. Direction is up, down, up, up, down, down, so there are three reversals relative to the initially upward head. Sector and platter numbers do not affect the stipulated cost model.
Solution
SSTF chooses cylinders 80→86→72→116→134→20→16, with distances 6, 14, 44, 18, 114, 4 totaling 200. The head starts upward and reverses at 86, 72, 134, three times. Treating the supplied numbers as additive movement costs gives(200/100)*20+3*15=85, the official answer. Physical power in milliwatts cannot in general be added over sequential operations to obtain total consumption; energy or a time-based average would require durations and appropriate units. Thus85 is the intended numerical cost, not a dimensionally justified physical power calculation.
Threads of one process share: A globals but not heap; B heap but not globals; C neither globals nor heap; D both globals and heap.
Your answer
Answer & solution
Official answer: D
1. Threads are separate execution streams inside the same process address space. Globals live in that shared address space.
2. Heap allocations also belong to the process address space; one thread can pass an allocated object’s address to another. Sharing does not itself make unsynchronized updates safe.
3. Each thread instead has its own execution state, such as registers and program counter, and normally its own stack. Hence both heap and globals are shared, D.
Processes P1,P2,P3,P4 have (arrival,CPU burst) in ms: (0,7),(3,3),(5,5),(6,2). Use preemptive shortest-remaining-time-first scheduling and find average waiting time.
Answer & solution
Official answer: 3.0
Our answer: 3
Step through it (7 steps)
1. Run P1 at t=0. At t=3 it has 4 ms left, so newly arrived P2 with 3 ms preempts it. At t=5 P2 has only 1 ms left, less than P3’s 5, so P2 continues to completion at 6.
2. At t=6 choose P4’s 2 ms over P1’s 4 and P3’s 5. P4 completes at 8, P1 runs 8–12, then P3 runs 12–17.
3. Waiting=completion−arrival−burst. For P1,P2,P3,P4 these are 12−0−7=5,6−3−3=0,17−5−5=7,8−6−2=0. Average=(5+0+7+0)/4=3 ms.
A program has x threads and y non-reentrant locks. A thread cannot reacquire a lock it holds, and blocks if acquisition fails. Find minimum x,y allowing deadlock. A (1,2); B (2,1); C (2,2); D (1,1).
Your answer
Answer & solution
Official answer: D
1. Consider a single thread and one initially free non-reentrant lock L. The thread acquires L successfully.
2. Before releasing L, let the same thread request L again. The non-reentrancy rule blocks it because L is already held, even though the holder is itself.
3. Only this blocked thread could release L, so it cannot progress: self-deadlock. At least one thread and one lock are needed to discuss this failure, and this example achieves both minima. Answer D.
Belady’s anomaly means page faults may increase when allocated frames increase. S1 random replacement suffers from it; S2 LRU suffers from it. A both true; B S1 true,S2 false; C S1 false,S2 true; D both false.
Your answer
Answer & solution
Official answer: B
1. For LRU, order all pages by recency after each reference. The k-frame cache contains the k most recent distinct pages; those pages are included in the first k+1 pages of that same order.
2. This stack inclusion means a reference hitting with k frames cannot miss with k+1. Increasing LRU capacity therefore never increases faults for a fixed reference string, so S2 is false.
3. Random replacement has no such nested-set guarantee: its eviction choices can retain different useful pages, and an adverse larger-cache realization may fault more. S1 is interpreted as possibility, not inevitability or a claim about every run. Hence B.
Transactions receive unique Lamport timestamps. T1 holds resource R; T2 requests a conflicting lock. If TS(T2)<TS(T1), kill T1; otherwise T2 waits. Killed transactions restart with the same timestamp; any transaction not killed eventually terminates. A both deadlock-free and starvation-free; B deadlock-free only; C starvation-free only; D neither.
Your answer
Answer & solution
Official answer: A
1. Smaller timestamps denote older transactions. An older requester wounds a younger holder; a younger requester waits rather than aborting the older holder. This is wound-wait.
2. Every actual waiting edge points from a younger transaction to an older one, so timestamps strictly decrease along waits. A directed cycle would require returning to the original timestamp after strict decreases, impossible. Hence no deadlock.
3. A restarted transaction keeps its old timestamp, so it does not repeatedly become youngest. With the stated eventual-termination assumption and finitely many older predecessors, those predecessors finish and it ultimately becomes able to proceed. This is the intended starvation-free guarantee, A.
Which are shared by all threads of one process? I:program counter. II:stack. III:address space. IV:registers. A:I and II. B:III only. C:IV only. D:III and IV.
Your answer
Answer & solution
Official answer: B
1. Threads belong to one process and operate in its common virtual address space, including code, global data and heap. Thus III is shared.
2. Each thread may be executing a different instruction, so it needs its own program counter and saved register values. Sharing one program counter or register context would prevent independent execution.
3. Each thread also needs its own call stack for local variables, return addresses and nested calls. Although another thread may access that stack through an address in the shared memory, the execution stack is still distinct. Hence only III is correct, B.
Which file-allocation schemes avoid external fragmentation? I:contiguous. II:linked. III:indexed. A:I and III. B:II only. C:III only. D:II and III.
Your answer
Answer & solution
Official answer: D
1. External fragmentation means sufficient total free space may exist but be split into separate regions, so a request needing one contiguous run cannot fit. Contiguous file allocation has this problem.
2. Linked allocation connects a file's blocks by pointers, so successive blocks can occupy arbitrary free block positions. Indexed allocation instead keeps their addresses in an index structure and likewise allows scattered blocks.
3. Both II and III avoid requiring one contiguous extent, giving D. This does not assert that every allocated block is completely used: an incompletely filled last block can still cause internal fragmentation, which is a different phenomenon.
A system has 9 tape drives. Processes (current allocation,maximum requirement) are P1:(3,7), P2:(1,6), P3:(3,5). Classify the state. A:safe,deadlocked. B:safe,not deadlocked. C:not safe,deadlocked. D:not safe,not deadlocked.
Your answer
Answer & solution
Official answer: B
Step through it (5 steps)
1. Current allocations total 3+1+3=7, leaving 9-7=2 drives available. Remaining maximum needs are P1:7-3=4, P2:6-1=5, P3:5-3=2.
2. P3 can receive its remaining two drives and finish. It then returns all five drives, leaving five available to the other processes. Equivalently, in the safety simulation add its existing allocation 3 to the current available count 2.
3. Now P1 can finish and release its three previously allocated drives, raising available to 8; P2 can then finish. Thus P3,P1,P2 is a safe sequence (P3,P2,P1 also works). Existence of a safe sequence establishes safe and not deadlocked, B.
Processes have (arrival time,CPU burst,priority), all times in ms: P1:(0,11,2), P2:(5,28,0), P3:(12,2,3), P4:(2,10,1), P5:(9,16,4). Priority 0 is highest, there are no I/O bursts, and scheduling is preemptive priority with zero unspecified switching overhead. Find average waiting time.
Answer & solution
Official answer: 29.0
Our answer: 29
Step through it (10 steps)
1. P1 starts at 0. At 2, higher-priority P4 arrives and preempts it; P1 has 9 ms left. At 5, highest-priority P2 arrives and preempts P4, which has 7 ms left. P2 runs uninterrupted to 33; later arrivals P5 and P3 have lower priorities.
2. Among waiting processes, run P4 from 33–40, P1 from 40–49, P3 from 49–51, then P5 from 51–67. Completion times are C1=49,C2=33,C3=51,C4=40,C5=67.
3. With no I/O, waiting time equals completion minus arrival minus CPU burst. Thus W1=49-0-11=38; W2=33-5-28=0; W3=51-12-2=37; W4=40-2-10=28; W5=67-9-16=42. The total is 145, so the average is 145/5=29 ms. Do not confuse waiting time with turnaround, which also includes execution.
CPU-bound processes with unequal burst lengths all arrive simultaneously. Which scheduling policy minimizes average ready-queue waiting time? A: shortest remaining time first. B: round robin with quantum shorter than every burst. C: uniform random. D: highest priority first, with priority proportional to burst length.
Your answer
Answer & solution
Official answer: A
All processes are available initially and are CPU-bound, so shortest-remaining-time-first reduces to shortest-job-first. If a longer job immediately precedes a shorter one, swapping them reduces the sum of waiting times by the burst-length difference. Repeated exchanges yield increasing burst order, which is optimal. Thus A.
Suppose adjacent bursts have lengths a>b. Executing a before b contributes a to b's wait, whereas reversing them contributes b to a's wait; completion time of the pair and waits of later jobs stay unchanged. The swap decreases total wait by a−b. Eliminating all such inversions gives ascending burst order. Since all arrivals occur at time zero, no newly arriving short job triggers a distinct preemption issue; SRTF executes this same optimal order.
A system has 40-bit virtual addresses,16-kilobyte pages and a one-level page table per process. Each entry occupies 48 bits. Find the per-process page-table size in megabytes, using binary memory units.
Answer & solution
Official answer: 384.0 : 384.0
Our answer: 384
Step through it (6 steps)
A16 KiB page uses 14 offset bits, leaving 40−14=26 virtual-page bits. There are 226 page-table entries, each 48 bits=6 bytes, totaling 6*226 bytes=384 MiB. The official answer uses binary kilobyte/megabyte conventions and excludes unspecified table metadata.
Page-table storage depends on the number of virtual pages, not the physical RAM capacity, which is not given. Offset bits are log 2(16×1024)=14; the remaining 26 bits index 226 entries. Convert the 48-bit entry into 6 bytes before multiplying. The product 402653184 bytes divided by 220 bytes per MiB is 384. Confusing 48 bits with 48 bytes would inflate the answer by a factor 8.
A disk has cylinders 0–199 and pending requests 47,38,121,191,87,11,92,10. Its head starts at 63 moving upward. Using C-LOOK, find the total cylinder movement to service all requests, including the wrap movement.
Answer & solution
Official answer: 346.0 : 346.0
Our answer: 346
Step through it (10 steps)
C-LOOK services 87, 92,121,191 on the upward pass, wraps directly to 10, then services 11, 38, 47. Movement is(191−63)+(191−10)+(47−10)=128+181+37=346 cylinders. The wrap is physical head movement and counts; the head does not visit unrequested endpoints 0 or 199.
Sort upward requests as 87,92,121,191 and below-head requests as 10,11,38,47. C-LOOK wraps from the highest pending request directly to the lowest pending request and resumes upward service, unlike C-SCAN which visits physical endpoints. The individual moves are 24,5,29,70,181,1,27,9; their sum 346 matches the compact span calculation. The large jump services no intermediate request but is still physical head travel, so excluding it would undercount.
There are 10 initially empty physical page frames. The reference sequence is a1,a2,...,a 20,a1,a2,...,a 20, with 20 distinct pages. Find the difference between LIFO and optimal replacement in total page faults.
Answer & solution
Official answer: 1.0 : 1.0
Our answer: 1
Assume initially empty frames. Both policies fault on all 20 first-pass pages. LIFO retains a 1 through a 9 and the most recently inserted page a 20. The second pass hits on a 1..a 9 then faults on a 10..a 20, giving 31 faults total. OPT can retain a 1..a 9, a 20 after the first pass, then uses frames of already-consumed pages to service a 10..a 19 while retaining a 20, giving 30. At least 10 second-pass faults are unavoidable because only 10 of 20 distinct pages can initially be resident, so OPT is optimal. Difference 31−30=1.
Under LIFO, page hits do not change insertion order. Once frames fill with a1 through a 10, every first-pass fault replaces the newest page in the same slot; a1 through a9 remain throughout. In the second pass, these nine hit and the other eleven fault. OPT has ten resident pages at the start of the second pass and can fault on exactly the ten absent pages by discarding pages whose final reference has already occurred. The total faults are therefore 31 versus 30, not counts of distinct pages alone.
There are n processes Pi, and all t[i] initially equal 0. pmax returns an integer at least as large as each argument. Each Pi repeats: c[i]=1; t[i]=pmax(t[0],...,t[n−1])+1; c[i]=0; for every j!=i {while(c[j]); while(t[j]!=0 && t[j]<=t[i]);} Critical Section; t[i]=0; Remainder Section; Which claim is true? A:At most one process is in its critical section at any time. B:Bounded waiting holds. C:Progress holds. D:Deadlock cannot occur. Analyze the usual atomic-read/write, sequentially consistent, nonoverflowing-ticket model with initially clear choosing flags c.
Your answer
Answer & solution
Official answer: A
This is bakery-style ticket selection without a process-ID tie-breaker. The choosing flags ensure another process waits until ticket selection finishes. Under the usual atomic-read/write, sequentially consistent, nonoverflowing-ticket model, two active contenders cannot both pass each other: a smaller nonzero ticket blocks the larger, while equal tickets block both. Thus mutual exclusion holds. Two simultaneous selections can read the same old maximum and choose equal tickets; each then waits for the other forever, so progress, deadlock-freedom and eventual bounded waiting are not guaranteed. Only A. Choosing flags are understood initially clear.
For a concrete deadlock execution with two processes, both evaluate the old maximum 0 before either publishes its ticket, and both choose 1. After their choosing flags clear, each sees the other's nonzero equal ticket and waits because 1≤1. Neither reaches the code that resets its ticket to 0. A process-ID tie-breaker, as in the standard bakery algorithm, would order equal tickets; it is absent here. This shows why mutual exclusion can hold while progress and bounded waiting fail.
Which page-replacement policy can suffer a higher page-fault rate when more frames are allocated? A LRU; B OPT; C MRU; D FIFO.
Your answer
Answer & solution
Official answer: D
FIFO exhibits Belady’s anomaly. For reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5, FIFO produces 9 faults with 3 frames but 10 with 4. LRU and OPT obey inclusion/optimality monotonicity; MRU is also an inclusion policy under consistent recency/tie handling. Thus D.
With three FIFO frames the example’s fault positions are 1,2,3,4,5,6,7,10,11. With four they are 1,2,3,4,7,8,9,10,11,12. More capacity changes eviction order, not merely how many pages fit at one instant. The inclusion property prevents this anomaly when every smaller resident set is contained in the larger one.
Preemptive shortest-remaining-time-first schedules P1(arrival 0,burst 10), P2(3,6), P3(7,1), P4(8,3), all times ms. Find average turnaround time.
Answer & solution
Official answer: 8.2 : 8.3
Our answer: 8.25
Step through it (7 steps)
SRTF executes P1: 0–3, P2: 3–7, P3: 7–8, P2: 8–10, P4: 10–13, P1: 13–20. Turnaround times are 20−0=20, 10−3=7, 8−7=1, 13−8=5. Average33/4=8.25ms, within the official 8.2–8.3 interval.
At time 3, P1 has 7 ms left, so arriving P2 with 6 preempts it. At time 7, P2 has 2 left, so P3 with 1 preempts. At time 8, P2’s remaining 2 beats P4’s 3 and P1’s 7. Turnaround includes all waiting after arrival; average waiting would instead subtract each burst and yield 3.25 ms.
Two processes share turn=0. Process 0 entry waits while turn==1, then executes its critical section and sets turn=1 on exit. Process 1 waits while turn==0, executes its critical section and sets turn=0 on exit. A correct solution; B violates mutual exclusion; C violates progress; D violates bounded waiting.
Your answer
Answer & solution
Official answer: C
This is strict alternation. If process 0 finishes its critical section and remains in its remainder section, turn becomes 1. Process1 may enter and leave, setting turn back 0. A further request by process 1 is then blocked even though process 0 is not competing. This violates progress. Mutual exclusion holds because turn cannot be both 0 and 1; the intended answer is C under the standard synchronization-property definitions.
An even simpler progress witness occurs initially: only process 1 requests entry while process 0 stays forever in its remainder section. turn remains 0, so the empty critical section is inaccessible to the sole interested process. Strict alternation limits overtaking but lets an uninterested process prevent entry, which is why mutual exclusion alone is insufficient.
A nonnegative counting semaphore S uses P to decrement when permitted and V to increment. Twenty P and twelve V operations are issued in some order. Find the greatest initial S for which at least one P remains blocked after the V operations are processed.
Answer & solution
Official answer: 7.0 : 7.0
Our answer: 7
After all 12 V operations have taken effect, the total number of permits available to satisfy the 20 P operations is S0+12. At least one remains blocked exactly when S0+12<20, giving the largest integer S0=7. This concerns operations remaining blocked after all issued V operations are processed, not a temporary block earlier in some ordering.
At S0=7 there are only 19 permits over the entire execution, so twenty P operations cannot all finish. At S0=8 there are twenty permits, enough eventually to release every issued P once all twelve V operations occur. A transient empty semaphore does not prove an operation will remain blocked after future signals.
A disk-block cache has 1 ms hit latency and 10 ms disk-read latency; cache checking is negligible. Sizes are multiples of 10 MB. Graph points (size MB,miss %): (10,80),(20,60),(30,40),(40,35),(50,30),(60,25),(70,20),(80,15). Find the smallest size with average latency strictly below 6 ms.
Answer & solution
Official answer: 30.0 : 30.0
Our answer: 30
With negligible lookup-check cost, average latency is(1−m)*1+m*10=1+9m milliseconds, requiring m<5/9. The graph gives miss rates 80% at 10MB, 60% at 20MB and 40% at 30MB. Thus20MB gives 6.4ms and 30MB gives 4.6ms; the smallest allowed size is 30MB.
At 10,20,30 MB the weighted delays are 8.2,6.4,4.6 ms. The target threshold is miss probability below 0.555…, not hit probability below that number. Since cache sizes are discrete multiples of 10 MB, interpolation to a value between 20 and 30 is not an allowed answer. The stipulated negligible lookup cost avoids charging a cache read again on each miss.
Byte-addressable memory has 32-bit logical addresses, 4-kilobyte pages, and 4-byte page-table entries. Find the single-level page-table size in megabytes.
Answer & solution
Official answer: 4
Step through it (6 steps)
There are 232 addressable bytes and 212 bytes per page, so the virtual address space contains 220 pages. Each needs one entry even though physical memory size is not given. Multiply entries by bytes per entry: 220×4=222 bytes=4 MiB. The question labels binary MiB as MB; the answer is not the page size itself.
Solution: A4 KiB page uses 12 offset bits, leaving 20 page-number bits in a 32-bit address. A single-level table needs 220 entries of 4 bytes, totaling 222 bytes=4 MiB. Thus4 under the question’s binary MB convention.
Shared B starts at 2. Concurrent P1 executes C=B−1; B=2*C. Concurrent P2 executes D=2*B; B=D−1. How many distinct final values can B have? Treat each assignment as atomic.
Answer & solution
Official answer: 3
Name P1's statements a,b and P2's c,d. The six order-preserving interleavings abcd,acbd,acdb,cabd,cadb,cdab end with B values 3,3,2,3,2,4 respectively. C and D retain the values calculated when their own reads occurred; later writes to B do not recompute them. Thus the distinct set is {2,3,4}. This is the exam's interleaving model, not an assertion that unsynchronized shared-variable C code has defined behavior.
Solution: Respecting each process’s assignment order, the possible final values of B are 2, 3, 4. Running P1 then P2 gives 3; P2 then P1 gives 4; reading both old B values before either write and leaving P1’s write last gives 2. Enumerating the six order-preserving interleavings adds no others. Thus three distinct values, with atomic statements and sequential consistency.
A preemptive uniprocessor runs periodic T1,T2,T3 with periods 3,7,20 ms and execution times 1,2,4 ms. Shorter period means higher priority. All first jobs arrive at the beginning of millisecond 1. At the end of which millisecond does first T3 finish?
Answer & solution
Official answer: 12
Set time zero at that initial arrival. T1 releases at 0,3,6,9; T2 at 0,7. First T3 starts at 4 after T1,T2,T1 consume four units, gets two units until time 6, then waits while T1,T2,T1 run through time 10. It completes its remaining two units in [10,12). Thus the finish is the end of the twelfth millisecond, not the beginning of millisecond 12. No context-switch overhead is supplied.
Solution: With time 0 at the beginning of the first millisecond, rate-monotonic priorities are T1>T2>T3. Execute T1: 0–1, T2: 1–3, T1: 3–4, T3: 4–6, T1: 6–7, T2: 7–9, T1: 9–10, T3: 10–12. The first T3 job receives its required 4ms and finishes at time 12, the end of the twelfth millisecond. Context-switch overhead is unspecified and taken as zero.
Disk has 100 tracks. Pending sequence: 45,20,90,10,50,60,80,25,70. Initial head=50. Find extra travel by SSTF compared with SCAN, initially moving towards 100.
SSTF repeatedly chooses the nearest pending track, producing total 130. In an upward sweep followed by reversal at the highest request, travel is 50→90→10, or 120; this is LOOK and yields the published +10. SCAN conventionally visits the physical end before reversing. Ending the accounting at the last served request 10 gives 140 if the upper end is 100, or 138 if tracks are 0–99. Therefore literal SSTF−SCAN is −10 or−8 under those conventions. The source's positive answer remains recorded but must not be presented as an unqualified SCAN derivation.
Solution: SSTF services 50, 45, 60, 70, 80, 90, 25, 20, 10, with movements 0+5+15+10+10+10+65+5+10=130. Reversing at the last pending upper request 90 gives(90−50)+(90−10)=120, so SSTF exceeds that LOOK distance by 10, the published answer. True SCAN continues to the disk endpoint before reversing: using endpoint 100 gives(100−50)+(100−10)=140 and SSTF−SCAN=−10. If100 tracks means 0..99, SCAN gives 138 and the difference is−8. The stated SCAN name/endpoints do not support the published positive 10 without a LOOK-style convention.
Five initially empty page frames receive 3,8,2,3,9,1,6,3,8,9,3,6,2,1,3. Compare FIFO and LRU faults. A same; B FIFO has two more; C LRU has two more; D FIFO has one more.
Your answer
Answer & solution
Official answer: A
Step through it (2 policies)
After filling with 3,8,2,9,1, FIFO removes 3 for 6, then 8 for 3, then 2 for 8; the repeated hits do not change its queue. LRU updates recency at every hit, so it evicts 8 when 6 arrives, then 2 when 8 returns. Continuing through the full sequence gives nine faults for each, although different victims and fault positions occur. Equal totals in this example do not imply the policies behave identically or have equal performance on all strings.
Solution: Starting with empty frames, FIFO faults at reference positions 1, 2, 3, 5, 6, 7, 8, 9, 13; LRU faults at 1, 2, 3, 5, 6, 7, 9, 13, 14. Each has 9 faults, though at different references. Thus A. The simulation updates LRU recency on hits but does not change FIFO insertion order on hits.
A system has 6 identical resources, N processes, each claiming at most 2 resources. Which N could deadlock? A1, B2, C3, D4. Published answer D conflicts with literal total-claim premises.
Your answer
Answer & solution
Official answer: D
Our answer: None under maximum-total-claim reading; official D
With maximum claim 2, a blocked process can hold at most 1 resource. If all N≤4 processes are blocked, at most 4 of the 6 resources are held, leaving enough to satisfy at least one pending request. Hence deadlock is impossible for every listed N. Six processes each holding 1 and requesting 1 provide the first possible deadlock. Official D (N=4) conflicts with the stated 6 resources/max 2 total claim; do not silently change either premise.
If a process has obtained both resources it needs, it can finish and release them. A blocked unfinished process therefore holds at most one unit. With N≤4, even if every process holds one, at most 4 of 6 units are occupied, leaving spare units to let a process finish. In general, R≥N(maxclaim−1)+1 guarantees this progress for identical reusable units. For maxclaim 2, the first deadlock configuration is 6 processes each holding 1 and waiting for 1. None of the four offered counts realizes it; preserve the published D only as a conflicting score, not the mathematical conclusion.
Free partitions 200, 400, 600, 500, 300, 250 KB. Allocate processes 357, 210, 468, 491 KB in order using bestfit. Which original partitions stay unused? A200, 300; B200, 250; C250, 300; D300, 400.
Your answer
Answer & solution
Official answer: A
Best fit assigns 357 to 400, 210 to 250, 468 to 500, and 491 to 600. Original partitions 200 and 300 remain unused, A. Splitting residual space does not alter these choices.
At each request choose the smallest remaining partition large enough.357 fits 400, 500, 600; choose 400.210 fits 250, 300, 500, 600; choose 250.468 fits 500 or 600; choose 500.491 then uses 600. The unused original partitions are 200 and 300. If partitions are split, the resulting remnants 43, 40, 32 and 109 are all too small to change these subsequent choices, so the answer remains the same.
Physical addresses 32 bits, pages 8 KB. PTE has valid bit, dirty bit, 3 permission bits, and frame translation. Maximum page table 24 MB. Under packed entries, find virtual address width.
Answer & solution
Official answer: 36
An8 KiB page uses 13 offset bits. A physical frame number needs 32−13=19 bits, and the five status/permission bits make a 24-bit (3-byte) packed PTE. A24 MiB table then holds 223 entries, giving 23+13=36 virtual address bits. This assumes the entries are packed into 3 bytes rather than padded and the maximum table maps the full virtual page space.
An8KiB page needs 13 offset bits. From 32 physical bits, 19 remain for the physical frame number. Add 1 valid+1 dirty+3 permission bits to obtain 24 bits=3 bytes per packed entry. A24MiB table holds 24×220/3=8×220=223 entries, one per virtual page. Therefore the virtual address has 23 page-number bits plus 13 offset bits=36. Alignment that padded entries to 4 bytes would define a different organization, so packing is an explicit assumption.
For a computer system with n CPUs, what is the maximum number of processes that can be in the Ready state? Options: (A) n; (B) n²; (C) 2ⁿ; (D) independent of n.
Your answer
Answer & solution
Official answer: D
1. At most n processes can execute simultaneously on n single-threaded CPUs, but that bound applies to Running, not Ready. A ready queue may contain many more processes while the CPUs execute others.
2. Ready processes are waiting to be scheduled, not currently executing. Their possible count is not bounded by the CPU count n; it depends on system/process resources. Thus independent of n, D.
Processes X and Y use shared Boolean flags varP and varQ, both initially false. Their synchronization pseudocode is: X: while(true) { varP=true; while(varQ==true) { /* critical section X */ varP=false; } } Y: while(true) { varQ=true; while(varP==true) { /* critical section Y */ varQ=false; } } The critical sections are inside the inner while bodies, not after empty waiting loops. Which claim holds under the usual atomic-flag model? (A) prevents deadlock but fails mutual exclusion; (B) guarantees mutual exclusion but fails to prevent deadlock; (C) guarantees both; (D) guarantees neither.
Your answer
Answer & solution
Official answer: A
Our answer: A under atomic shared-flag model
1. If both flags become true before either loop test, both processes can enter their critical sections, so mutual exclusion fails.
2. The inner loops are not waiting loops: their bodies execute the critical section when the other flag is true. Under fair execution and terminating critical sections, a false test returns to the outer loop and reasserts the flag; there is no state where both wait permanently for an action the other cannot perform. Thus A. Literal unsynchronized C threads would instead require a memory-model analysis; the source is treated as synchronization pseudocode.
For mutually exclusive resources, which policies can prevent deadlock? I: A process acquires all resources at the start; if any is unavailable, it releases those acquired so far. II: Resources have unique numbers and requests occur only in increasing number order. III: Resources have unique numbers and requests occur only in decreasing number order. IV: Resources have unique numbers and a process may request only a resource numbered higher than all resources it currently holds. Options: (A) any one of I and III, but not II or IV; (B) any one of I,III,IV, but not II; (C) any one of II and III, but not I or IV; (D) any one of I,II,III,IV.
Your answer
Answer & solution
Official answer: D
1. I removes hold-and-wait by releasing partial acquisitions if all cannot be obtained.
2. II and III each impose a strict global resource order, excluding circular wait. IV likewise permits only requests larger than every held resource, so any wait cycle would require strictly increasing numbers around a loop, impossible. Each policy individually prevents deadlock, D; this does not promise starvation freedom.
Processes have (arrival time, processing time): A=(0,3), B=(1,6), C=(4,4), D=(6,2). Which scheduling scheme yields the lowest average turnaround time? Options: (A) first come first serve; (B) non-preemptive shortest job first; (C) shortest remaining time; (D) round robin with quantum 2. Turnaround time is completion minus arrival.
Your answer
Answer & solution
Official answer: C
Step through it (4 schedules)
1. Shortest remaining time runs A0–3, B3–4, C4–8, D8–10 and B10–15 (the C/D tie at 6 can be resolved either way without changing total turnaround).
2. Completion-minus-arrival times are 3, 14, 4, 4, mean 6.25. FCFS gives 3, 8, 9, 9, mean 7.25; nonpreemptive SJF gives 3, 8, 11, 5, mean 6.75. Round-robin quantum 2 gives a larger mean (8.25 under arrivals-before-requeue at equal times). Hence C.
A disk has cylinders 0 through 200. The arm is at 100, with pending requests 30,85,90,100,105,110,135,145. Under shortest-seek-time-first scheduling, how many requests are serviced before request 90?
Answer & solution
Official answer: 3
1. Method and setup. At each step recompute distances from the current head position; SSTF is not a one-time sort by distance from 100. The request already at the head is a request serviced before any movement. Once at 110, compare the distances to 90 and 135 rather than continuing upward automatically.
2. Work through the result and its assumptions. SSTF first services the zero-distance request 100, then 105, then 110. From110, 90 is 20 cylinders away, closer than 135 at 25. Thus90 is serviced after 3 requests.
Which threading statement is false? A: The kernel does not schedule user-level threads. B: If one user-level thread blocks, all other threads of its process block. C: User-level thread context switching is faster than kernel-level switching. D: Kernel-level threads cannot share the code segment. The usual intended model is many-to-one user threads with blocking system calls.
Your answer
Answer & solution
Official answer: D
Our answer: D under the many-to-one user-thread model
1. Method and setup. Separate a thread’s private execution state, such as registers and stack, from process-wide resources such as code and address space. Kernel scheduling does not imply a separate address space per thread. Statements about all user threads blocking depend on how user threads are mapped to kernel scheduling entities.
2. Work through the result and its assumptions. Kernel threads of one process share its address space, including code, so D is false. The remaining statements use the traditional many-to-one user-level-thread model and blocking kernel calls. A user-runtime wait that schedules another user thread need not block the whole process, and hybrid threading differs; the blanket wording of B needs that model.
Banker’s algorithm manages resources X,Y,Z for P0,P1,P2. Allocation rows are P0=(0,0,1), P1=(3,2,0), P2=(2,1,1); maximum-demand rows are P0=(8,4,3), P1=(6,2,0), P2=(3,3,3). Available=(3,2,2), and the current state is safe. Consider independent requests: REQ1 P0 asks (0,0,2); REQ2 P1 asks (2,0,0). Which may be granted safely? A: REQ1 only. B: REQ2 only. C: both. D: neither.
Your answer
Answer & solution
Official answer: B
Step through it (2 checks)
1. Method and setup. Compute Need=Max−Allocation. For each request separately, tentatively decrease Available and increase the requester’s Allocation, then try to find a complete safe sequence. Sufficient available resources for the immediate grant is necessary but not sufficient; the updated state must still permit every process to finish.
2. Work through the result and its assumptions. Initial needs are P0=(8, 4, 2), P1=(3, 0, 0), P2=(1, 2, 2). Grant REQ1: available=(3, 2, 0); only P1 can finish, releasing(3, 2, 0) to give(6, 4, 0). Neither remaining process can finish, so unsafe. Grant REQ2: available=(1, 2, 2), P1 need=(1, 0, 0); finish P1 to get(6, 4, 2), then P2 to get(8, 5, 3), then P0. Only REQ2 is safe, B.
Five processes have (arrival time, execution time), in ms: A=(0,6), B=(3,2), C=(5,4), D=(7,6), E=(10,3). Under preemptive shortest-remaining-time-first on one CPU, find the average turnaround time in ms.
Answer & solution
Official answer: 7.2
Step through it (9 steps)
1. Method and setup. Reevaluate the currently running process whenever a new process arrives. Compare remaining execution time, not the original burst length. Record completion time for each process, then subtract its own arrival time; averaging completion times directly would ignore that the processes enter at different times.
2. Work through the result and its assumptions. SRTF executes A0–3, B3–5, A5–8, C8–12, E12–15, D15–21. At10, C has 2 remaining versus E’s3, so it continues. Completion-minus-arrival times are 8, 2, 7, 14, 5. Their mean 36/5=7.2ms.
Three page frames are initially empty. For page references 1,2,3,4,2,1,5,3,2,4,6, how many page faults occur with optimal replacement?
Answer & solution
Official answer: 7
Step through it (13 steps)
1. Method and setup. On a fault with full memory, evict the resident page whose next reference is farthest in the future, treating never-used-again pages as infinitely far away. This uses future knowledge and is an optimal benchmark, not LRU. Mark hits explicitly so that each reference contributes at most one fault.
2. Work through the result and its assumptions. Load1, 2, 3 (three faults). At4 evict 3, whose next use is later than 1/2 (fourth fault). Hits2, 1 follow. At5 evict 1, never used again (fifth). At3 evict 5, never reused (sixth). Then2 and 4 hit; 6 causes the seventh fault. This is Belady’s farthest-future policy.
A FAT-based filesystem has 4-byte FAT entries. The disk size is 100×10^6 bytes and the data-block size is 10^3 bytes. Under the stated FAT-overhead model, find the largest file size in units of 10^6 bytes.
Answer & solution
Official answer: 99.55 to 99.65
Our answer: 99.6
1. Set up the reasoning. First count the nominal blocks on the disk, then reserve one four-byte FAT entry per block. The question's units are decimal, so retain powers of 10 rather than substituting powers of 2.
2. Derive the result. The simplified model gives 100×10⁶/10³=100000 disk blocks and one 4-byte FAT entry per block, totaling 400000 bytes. Subtracting FAT space leaves 99.6×10⁶bytes for one file, within the accepted range. This neglects boot sectors, directories, duplicate FAT copies and other metadata, as no such overhead is specified.
3. Check the interpretation. Subtract the specified overhead from disk capacity before converting to millions of bytes. This simplified maximum assumes one file can occupy all remaining data storage and ignores unmentioned directories, boot structures, and redundant FAT copies.
Producer-consumer pseudocode starts with semaphores n=0, s=1. Producer repeats produce(); wait(s); addToBuffer(); signal(s); signal(n). Consumer repeats wait(s); wait(n); removeFromBuffer(); signal(s); consume(). Which is true? A Producer can add but consumer can never consume. B Consumer removes at most one item. C Deadlock occurs if consumer acquires s when the buffer is empty. D n must start at 1 rather than 0 for deadlock-free operation.
Your answer
Answer & solution
Official answer: C
1. Set up the reasoning. Interpret s as the mutex and n as the number of available items. Trace the particular interleaving where the consumer runs first and locks the empty buffer.
2. Derive the result. If the consumer acquires s while n=0, it blocks on n while retaining s. The producer needs s before adding an item and signaling n, so neither can proceed. That is the deadlock in C. Correct ordering is to wait for n before acquiring the buffer mutex; inventing an initial item by setting n=1 is not a valid repair.
3. Check the interpretation. The consumer holds the very lock the producer requires to make n positive. The proper repair is to wait on n before locking s, not to pretend that an item exists by setting n=1.
Processes A,B,C each repeat 100 iterations of a CPU burst followed by independent-device I/O. CPU burst times are A 100 ms, B 350 ms, C 200 ms; all I/O operations take 500 ms. They arrive at 0,5,10 ms respectively. With round-robin scheduling, 50 ms quantum, no scheduling overhead, and sufficient independent I/O devices, when does C finish its first I/O, in ms from time 0?
Answer & solution
Official answer: 1000
Step through it (16 steps)
1. Set up the reasoning. Maintain the ready queue at quantum boundaries. Later arrivals join the queue but do not preempt A's already running time slice. Remove a process from the ready queue as soon as its CPU burst finishes and it blocks on I/O.
2. Derive the result. The50ms slices are A0–50, B50–100, C100–150, A150–200, B200–250, C250–300, B300–350, C350–400, B400–450, C450–500. A starts I/O at 200; C completes its 200ms CPU burst at 500 and its independent 500ms I/O at 1000.
3. Check the interpretation. C needs four 50-ms slices, not four consecutive slices. Its I/O can overlap A's and other CPU activity because separate devices are available; add 500 ms to C's CPU completion time rather than to its arrival.
Twenty physical frames initially contain pages 101 through 120. A program references pages 1,2,…,100 in order and repeats that access sequence THRICE. Which replacement policy has the same fault count as optimal replacement? A LRU; B FIFO; C LIFO; D MRU. Retain the source's occupied-frame condition and its wording about repetitions.
Your answer
Answer & solution
Official answer: D
Our answer: Official D needs initially reclaimable frames; literal initial occupancy makes no listed policy optimal
1. Set up the reasoning. Analyze the initially occupied frames before using the familiar result that MRU works well on repeated scans. After MRU loads page 1, that new page becomes the most recently used frame and is the next victim.
2. Derive the result. MRU is often optimal for cyclic scans larger than memory when frames initially fill with the scan’s pages. Here all 20 frames already contain irrelevant 101–120. Literal MRU evicts one old page for 1, then evicts the newly referenced 1 for 2, and so on, retaining 19 irrelevant pages forever. Every requested page therefore faults. LIFO likewise keeps 19 irrelevant pages; LRU/FIFO also fault on every pass because the cycle exceeds 20 frames. OPT discards the never-used initial pages and retains useful pages for later passes: for three total passes an explicit farthest-future simulation gives 260 faults instead of 300. Even simply preserving 19 useful pages across passes beats all-fault behavior. Official D requires treating the initial frames as free/reclaimable before MRU, a missing convention.
3. Check the interpretation. The official D cannot simply be explained by an initially empty-cache simulation. Literal occupied-frame MRU leaves nineteen irrelevant pages resident, unlike OPT. The inherited discrepancy remains open; the phrase about repetitions also needs a clearly stated pass-count convention when numerical simulations are quoted.
Three initially empty page frames use LRU replacement. Count faults for page references 4,7,6,1,7,6,1,2,7,2.
Answer & solution
Official answer: 6
Step through it (12 steps)
Step 1: Maintain recency on hits as well as on insertions. Write resident pages from least to most recently used. The first three references fault and produce [4], [4,7], [4,7,6]. Step 2: Reference 1 faults and evicts 4, giving [7,6,1]. The following hits on 7,6,1 change the order to [6,1,7], [1,7,6], [7,6,1]. Step 3: Reference 2 faults, evicting 7 and giving [6,1,2]. Next 7 faults, evicting 6 and giving [1,2,7]. Final 2 hits and gives [1,7,2]. Faults occur at positions 1,2,3,4,8,9: total 6.
Similar questions7 more → · asked again: GATE 1997, Q6.7
Deadlocks
Tap to enlarge
Three programs each require three tape units to operate. What is the minimum number of tape units that guarantees no resource deadlock?
Answer & solution
Official answer: 7
Step 1: Exhibit a deadlock with six units: each program holds two and waits for a third, leaving no free unit and no program able to finish. Thus six is insufficient. Step 2: With seven units, if no program yet holds its full requirement, each holds at most two and together they hold at most six. At least one unit remains available to let some program reach three and finish. Step 3: Its release permits the others to progress. Hence the minimum is 3(3−1)+1=7 under the usual reusable-resource model, maximum demand of three, and eventual completion/release once the demand is met.
Preemptive shortest-remaining-time-first scheduling is applied to processes (arrival,CPU burst), in ms: P1=(0,12), P2=(2,4), P3=(3,6), P4=(8,5). Find their average waiting time.
Answer & solution
Official answer: 5.5
Step through it (8 steps)
Step 1: P1 runs 0–2, leaving 10. P2 arrives with burst 4 and preempts it. At time 3, P2 has 3 remaining, shorter than P3's 6, so P2 finishes at 6. Step 2: P3 then runs 6–12. When P4 arrives at 8, P3 has 4 remaining, less than P4's 5, so no preemption occurs. P4 runs 12–17, then P1 runs 17–27. Step 3: Waiting time equals completion−arrival−burst: P1=27−0−12=15; P2=6−2−4=0; P3=12−3−6=3; P4=17−8−5=4. The average is (15+0+3+4)/4=5.5 ms, assuming negligible switching cost.
A paging system has a TLB; all pages and the entire page table reside in physical memory. TLB search takes 10 milliseconds, physical-memory access 80 milliseconds, and the TLB hit ratio is 0.6. Find effective access time in milliseconds.
Answer & solution
Official answer: 122
Step 1: On a TLB hit, address translation takes 10 ms and the requested memory access takes 80 ms, totaling 90 ms. Step 2: On a TLB miss, after the same 10 ms lookup, one memory access reads the page-table entry and another reads the requested data: 10+80+80=170 ms. There is no disk page-fault penalty because all pages are resident. Step 3: Average over the two cases: 0.6×90+0.4×170=122 ms. The source's milliseconds are intentionally retained; the model assumes serial lookup and a single-level page-table access.
All processes arrive at time 0, have no I/O, and start with zero priority. Priority is proportional to accumulated waiting time. Every T time units priorities are reevaluated and the next process is selected. Which policy is equivalent? A FCFS; B round-robin; C shortest-job-first; D shortest-remaining-time-first.
Your answer
Answer & solution
Official answer: B
Our answer: B under the usual cyclic tie convention
With all jobs arriving together and no blocking, running a process stops its waiting time from growing while the others continue to accumulate waiting time. At each T-unit reassessment, the previously waiting processes take priority over the one just served. With a fixed fair cyclic resolution of ties this is round-robin with quantum T, B. The statement does not independently specify how equal priorities are ordered, so an exact fixed cyclic order requires that usual tie convention.
For processes that remain ready, elapsed time equals CPU service received plus accumulated waiting time. At a fixed reassessment time, maximizing waiting time is therefore the same as favoring the process that has received the least service. Starting together, the unserved processes outrank the one just given a T-unit slice. With consistent cyclic tie-breaking, each gets a slice before that process gets another, reproducing round-robin. Neither job lengths nor remaining times are consulted, excluding SJF/SRTF. FCFS would let the first job keep running rather than preempt it at each reassessment.
Binary semaphores a, b, c, d start at 1. X acquires a, b, c; Y acquires b, c, d; Z acquires c, d, a, then each releases its three locks after work. Which acquisition ordering is deadlock-free? A X:abc, Y:bcd, Z:cda; B X:bac, Y:bcd, Z:acd; C X:bac, Y:cbd, Z:acd; D X:abc, Y:cbd, Z:cda.
Your answer
Answer & solution
Official answer: B
Option B respects a single global order b<a<c<d in every process: X takes b, a, c; Y takes b, c, d; Z takes a, c, d. A circular wait would require strictly increasing lock ranks around a cycle, which is impossible. The other choices admit contradictory acquisition orders and circular-wait executions. Thus B.
Assign ranks b=1, a=2, c=3, d=4. In B every process acquires strictly increasing ranks, so a process holding one lock can wait only for a higher-ranked lock. A circular chain would require rank to increase all the way back to its starting value, which is impossible. For contrast, A permits X holding a while Z holds c, d and waits for a, with X eventually waiting for c. C permits X holding b and Y holding c, each waiting for the other. D permits X holding a, b and Z holding c, d, with X waiting for c and Z for a. These are concrete circular waits, not merely inconvenient orderings.
Shared x starts 0. W and X each read x, add1 locally, then store; Y and Z each read x, subtract 2 locally, then store. Each process waits on a counting semaphore initially 2 before reading and signals after storing. Each executes once. Maximum final x: A−2, B−1, C1, D2.
Your answer
Answer & solution
Official answer: D
Each increment operation adds 1 to a previously read value, while each decrement subtracts 2. A causal chain of reads and writes contains at most the two increment operations, so no value can exceed 2 starting from 0. This is attainable with semaphore capacity 2: W reads 0 and pauses; Y reads 0 and writes−2; Z reads−2 and writes−4; W then writes 1; X reads 1 and writes 2. The capacity restriction is respected throughout. Thus the largest final value is 2, D.
A write stores a locally computed value based on an earlier read, so updates need not add algebraically to−2. With capacity 2, W can occupy one slot while reading 0; the other slot is reused by Y then Z, producing−2 then−4. W’s delayed write overwrites these with 1. After W leaves, X can read 1 and write 2. For the upper bound, trace a written value backward through the reads it depends on. Each increment process can appear at most once in such a causal chain, so no chain adds more than 2; decrements only decrease it. This proves both attainability and optimality.
Producer X computes a[i]=f(i), then ExitX; consumer Y calls EntryY, then computes b[i]=g(a[i]), for i=0,…, n−1. Binary semaphores R, S initially 0. Which implementation synchronizes them? A Exit=P(R), V(S);Entry=P(S), V(R). B Exit=V(R), V(S);Entry=P(R), P(S). C Exit=P(S), V(R);Entry=V(S), P(R). D Exit=V(R), P(S);Entry=V(S), P(R).
Your answer
Answer & solution
Official answer: C
In C, the consumer first signals S to indicate readiness, then waits on R; the producer waits on S before signaling R after its item has been computed. The consumer reads the item only after that R handshake. Since the next S is not issued until the preceding consumer iteration finishes, signals cannot outrun the corresponding item and collapse in a binary semaphore. A deadlocks immediately because both sides initially wait on zero semaphores. B lacks a readiness handshake, so multiple signals can collapse. In D, the producer can signal R for the next item before the consumer consumes the preceding R, again collapsing signals. Thus C provides the required synchronization.
A binary semaphore stores only whether a signal is pending, not an unbounded count. The consumer’s V(S) in C grants permission for one producer notification, then its P(R) waits for the corresponding completed a[i]. The producer cannot notify the next item without another S grant, which the consumer issues only in its next iteration. This prevents two notifications collapsing into one. In D, after the first readiness signal the producer can release R twice before the consumer takes R even once, losing a notification and potentially blocking a later consumer iteration.
A46-bit virtual/32-bit physical address machine uses 3-level paging. T1 fits exactly one page; T1 entries point to page-sized T2 blocks; T2 entries point to page-sized T3 blocks of 32-bit PTEs. Under32-bit table entries throughout, page size: A2, B4, C8, D16 KB. Shared data:1MB16-way virtually indexed physically tagged cache, 64-byte block.
Your answer
Answer & solution
Official answer: C
Let each page contain 2p bytes. Under the standard fixed-width organization, a 32-bit PTE or physical-address entry occupies four bytes, so each page-sized table contains 2p−2 entries and each of the three levels uses p−2 index bits. The page offset uses p bits. Covering the 46-bit virtual address therefore gives 3(p−2)+p=46, hence 4p=52 and p=13. The page size is 213 bytes=8 KiB, labeled 8 KB in the options, so C. This uses 32-bit entries at the upper levels as well as the stated 32-bit leaf PTE, page-sized table blocks, full address-space coverage, and the usual binary KB convention.
A page of 2^pbytes contains 2p/4=2p−2table entries when each occupies 4 bytes. Hence each level contributes p−2 index bits and the final byte offset contributes pbits. With three levels, the address budget is(p−2)+(p−2)+(p−2)+p=46. Solving gives p=13and8192 bytes. The result is conditional on the usual fixed-width pointer entries at upper levels; the problem explicitly gives the leaf PTE size and implies that conventional organization.
A process executes the code fork(); fork(); fork(); The total number of child processes created is (A) 3 (B) 4 (C) 7 (D) 8
Your answer
Answer & solution
Official answer: C
Step through it (9 steps)
Assuming each fork succeeds, the first invocation creates one child, the second is executed by two processes and creates two more, and the third by four processes creates four more. There are 1+2+4=7 children, or eight total processes including the original. Hence C.
Check: Track the live population after each call as 1→2→4→8. Every new process is a child of an existing process, but the original process is not its own child, so subtracting it from the final population avoids distractor D.
Consider the 3 processes, P1, P2 and P3 shown in the table.
Process Arrival Time Units time Required P1 0 5 P2 1 7 P3 3 4
The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are (A) FCFS: P1, P2, P3 RR2: P1, P2, P3 (B) FCFS: P1, P3, P2 RR2: P1, P3, P2 (C) FCFS: P1, P2, P3 RR2: P1, P3, P2 (D) FCFS: P1, P3, P2 RR2: P1, P2, P3
Your answer
Answer & solution
Official answer: C
Step through it (2 schedules)
FCFS executes P1 from 0–5, P2 from 5–12 and P3 from 12–16, so completion order is P1, P2, P3. For quantum 2, round robin runs P1 0–2, P2 2–4, P1 4–6, P3 6–8, P2 8–10, P1 10–11, P3 11–13, P2 13–15 and 15–16. Completion times are respectively 11, 16, 13, giving P1, P3, P2. Hence C.
Check: The arrivals occur between quantum boundaries: P2 joins during P1’s first slice, and P3 joins during P2’s first slice. A preempted unfinished process returns to the tail, whereas a completed process is removed. This explains why the shorter P3 finishes before P2 under RR.
Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
AcquireLock(L){ while (Fetch_And_Add(L,1)) L = 1; }
ReleaseLock(L){ L = 0; }
This implementation (A) fails as L can overflow (B) fails as L can take on a non-zero value when the lock is actually available (C) works correctly but may starve some processes (D) works correctly without starvation
Your answer
Answer & solution
Official answer: B
Suppose one process holds the lock with L=1. A waiter executes Fetch_And_Add, obtains old value 1 and changes L to 2, so it must execute the loop body. Before that body executes, the owner releases the lock by storing L=0. The waiter then executes its pending L=1 assignment, restoring a nonzero value even though nobody holds the lock. Subsequent tests keep failing and there need be no owner left to release it. Thus B identifies a failure even without arithmetic overflow.
Check: Atomicity protects the fetch-and-add operation itself, not the following plain assignment. The interleaving is: waiter atomically changes 1→2; owner changes 2→0; waiter changes 0→1. The last store overwrites the release and leaves no holder responsible for another release.
A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the size of each disk block address is 8 Bytes. The maximum possible file size in this file system is (A) 3 KBytes (B) 35 KBytes (C) 280 KBytes (D) dependent on the size of the disk
Your answer
Answer & solution
Official answer: B
Each indirect block holds 128/8=16 addresses. The descriptor therefore reaches 8+16+16²=280 data blocks. Their payload is 280×128=35, 840 bytes=35 KiB (the option calls these KBytes). Indirection blocks are metadata and do not count as file payload. The 300 GByte disk is more than large enough. Hence B.
Check: The eight direct pointers cover 1024 bytes, the single-indirect pointer covers 16×128=2048 bytes, and double indirection covers 256×128=32768 bytes. Their sum is 35840 bytes. Multiplying 280 by KiB instead of by 128 bytes produces the 280-KByte distractor.
Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 on a demand paged virtual memory system running on a computer system that has main memory size of 3 page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the corresponding page replacement policy. Then (A) OPTIMAL < LRU < FIFO (B) OPTIMAL < FIFO < LRU (C) OPTIMAL = LRU (D) OPTIMAL = FIFO
Your answer
Answer & solution
Official answer: B
Step through it (3 policies)
Number the ten references from 1. FIFO faults at positions 1, 2, 3, 5, 6, 8: six faults. LRU faults at 1, 2, 3, 5, 6, 7, 8, 9, 10: nine faults. Optimal replacement faults at 1, 2, 3, 5, 8: five faults; at reference 5 evict page 2, whose next use is later than those of 1 and 3, and at reference 8 evict page 3, which is never used again. Thus OPTIMAL=5 < FIFO=6 < LRU=9, B.
Check: A hit updates recency in LRU but does not move a page in FIFO’s arrival order. This distinction first matters after reference 4, a hit on page 2: LRU remembers page 2 as recent, while FIFO still regards page 1 as the oldest arrival.
Let t1 be the time to switch between user and kernel execution modes, and t2 the time to switch between two processes. Which comparison is intended to hold?
(A) t1 > t2 (B) t1 = t2 (C) t1 < t2 (D) Nothing can be said about their relation
Your answer
Answer & solution
Official answer: C
Our answer: C in the conventional OS model
A user/kernel mode switch changes privilege and performs the associated entry/exit bookkeeping without necessarily changing the current process. A process context switch additionally saves/restores execution context and changes scheduling/address-space state. In the conventional comparison this costs more, giving t1<t2, C. It is an architectural cost-model comparison, not a hardware-independent numerical law for arbitrary implementations.
A system call can enter the kernel, do work for the same process, and return without scheduling another process. In a full context switch, the OS must preserve enough state to resume one process later and load another process's state; address-space switching may also entail translation/cache overhead. Thus a mode switch is conceptually a smaller operation. The question supplies no timings from which a numerical ratio could be calculated, only this conventional ordering.
Threads are called lightweight processes because the OS maintains smaller structures for a thread than a process. Which statement is TRUE?
(A) Per thread, the OS maintains only CPU register state (B) The OS does not maintain a separate stack for each thread (C) Per thread, the OS does not maintain virtual-memory state (D) Per thread, the OS maintains only scheduling and accounting information
Your answer
Answer & solution
Official answer: C
Threads of one process share its virtual address space, so virtual-memory mappings are maintained at process level rather than separately for each thread. Each thread still needs its own register context, stack and scheduling information. Therefore C.
Independent execution requires each thread to remember its own instruction pointer and registers, and its own stack holds function calls and local execution state. The scheduler also tracks the thread's run/block status. Those facts refute A, B and D: none of the single listed items is the whole thread context, and stacks are not omitted. Virtual-memory mappings, however, describe the shared process address space, which is why C identifies the saving.
Memory access takes 20 ns on average, a page fault takes 10 ms to service, and one page fault occurs per 10^6 memory accesses. Find the effective access time.
(A) 21 ns (B) 30 ns (C) 23 ns (D) 35 ns
Your answer
Answer & solution
Official answer: B
The fault probability is 10−6 and 10ms=107 ns. Average fault overhead contributes 10 ns per access, in addition to the 20 ns memory time, giving approximately 30 ns, B. If fault service is taken as a replacement rather than added time, the weighted result 29.99998 ns has the same rounded answer.
Convert all units before averaging: 1 ms=106 ns, so the fault penalty is ten million nanoseconds. Although the event is rare, multiplying that large penalty by 1/1000000 adds 10 ns to the average. This is half the normal access time, so ignoring faults because they are rare would be a large relative error. Conversely, adding the full 10 ms to every access would wrongly assume every reference faults.
Processes P0,P1,P2 have (arrival,burst) times in ms of (0,9),(1,4),(2,9). Use preemptive shortest-job-first scheduling, reconsidering at arrivals or completions. What is their average waiting time?
(A) 5.0 ms (B) 4.33 ms (C) 6.33 ms (D) 7.33 ms
Your answer
Answer & solution
Official answer: A
Step through it (6 steps)
P0 runs 0–1, then P1 with its shorter remaining time runs 1–5 despite P2 arriving at 2. P0 finishes its remaining 8 units during 5–13; P2 then runs 13–22. Waiting times are 13−0−9=4, 5−1−4=0 and 22−2−9=11. Average(4+0+11)/3=5ms, A.
At time 1, P0 has 8 units remaining and P1 needs 4, so preemption is required. At time 2, P1 has only 3 remaining, less than P0's 8 and newly arrived P2's 9, so no further preemption occurs. Waiting time is turnaround minus burst, not completion time alone. P0 waits from 1 to 5, P1 never waits, and P2 waits from 2 to 13. These intervals independently reproduce the total 15 ms waiting time.
An application loads 100 libraries at startup. Each takes one disk access to a random location. Average seek time is 10 ms and rotational speed is 6000 rpm. Neglect data-transfer time once positioned at the block. What is the expected total load time?
(A) 0.50 s (B) 1.50 s (C) 1.25 s (D) 1.00 s
Your answer
Answer & solution
Official answer: B
At 6000 rpm the disk makes 100 revolutions per second, so one revolution lasts 10 ms. Random angular position gives an average rotational latency of 5 ms. Each library requires one access with 10 ms seek time plus 5 ms average rotational latency; transfer time is neglected. The total expected loading time is 100×15 ms=1500 ms=1.50 s, option B. The random-location wording calls for average rotational latency, not a full revolution per access.
Convert rpm to revolutions per second before computing time: 6000/60=100. Uniform random angular placement means the desired sector can be anywhere from just under the head to nearly a full revolution away, averaging half a turn. Seek and rotational wait occur for each of the 100 distinct accesses, so both contributions must be counted 100 times. The expected seek total is 1 second and expected rotation total is 0.5 second; ignoring either would select an incorrect smaller answer.
Processes P1 and P2 use shared Boolean variables S1,S2 whose initial values are assigned randomly. Whenever they need their critical sections they execute: P1: while (S1==S2); critical section; S1=S2; P2: while (S1!=S2); critical section; S2=not(S1); Which properties are achieved? Options: (A) Mutual exclusion but not progress; (B) Progress but not mutual exclusion; (C) Neither mutual exclusion nor progress; (D) Both mutual exclusion and progress.
Your answer
Answer & solution
Answer: A (no official key was published)
P1 passes its guard only when S1≠S2; P2 passes only when S1=S2. Neither changes the shared state until leaving its critical section, so while one is inside the other’s guard stays blocking: mutual exclusion holds. Progress fails: if S1=S2 and only P1 wants to enter, P1 spins forever unless P2 participates and changes S2. The symmetric case also occurs. This is strict alternation, so A, assuming atomic sequentially consistent accesses as the pseudocode model does.
After P1 exits it sets S1=S2, making P2 eligible and itself ineligible; after P2 exits it makes S2 the opposite of S1, restoring P1’s turn. Consequently the processes alternate even if one no longer wants the critical section. Mutual exclusion is a safety property; progress additionally requires that an uninterested process not prevent an interested one from entering.
A FIFO page-replacement system has four frames, initially empty. It accesses 100 distinct pages in some order, then accesses those same 100 pages in the reverse order. How many page faults occur? Options: (A) 196; (B) 192; (C) 197; (D) 195.
Your answer
Answer & solution
Answer: A (no official key was published)
The first 100 distinct references all fault. The four resident pages are then the last four in forward order, and the reverse scan hits these four first. Every one of the other 96 reverse references is to a page not yet resident; those faults evict only pages already visited in the reverse scan. Therefore faults total 100+96=196, option A. Hits do not refresh FIFO order.
Name the forward sequence p₁,…,p₁₀₀. The reverse sequence starts p₁₀₀,p₉₉,p₉₈,p₉₇, all already resident. Then p₉₆,…,p₁ must each fault because none remains from the forward scan. There are 200 total references and exactly four hits, giving 200−4=196 independently of the original ordering.
Which statements about CPU scheduling are true? I: shortest-remaining-time-first may cause starvation. II: preemptive scheduling may cause starvation. III: round robin is better than FCFS in response time. Options: (A) I only; (B) I and III only; (C) II and III only; (D) I,II and III.
Your answer
Answer & solution
Answer: D (no official key was published)
SRTF may indefinitely postpone a long job when shorter jobs keep arriving, so I is true. SRTF is itself preemptive, establishing that preemptive scheduling may cause starvation, so II is true. Round robin’s time slices let waiting jobs receive CPU service without waiting for a long earlier job to finish, which is the conventional interactive response-time advantage asserted by III. The intended answer is all three, D. III is a qualitative textbook comparison, not a strict improvement for every workload and quantum; for a quantum exceeding all bursts, RR reduces to FCFS.
Starvation means unbounded waiting, not merely a long finite delay. Under SRTF, a long job can be repeatedly preempted by a stream of shorter jobs. Round robin uses a bounded quantum to distribute service opportunities among ready jobs, which improves typical interactive first-response behavior, while potentially increasing context-switch cost. The word “may” in I and II is essential.
Three concurrent processes use binary semaphores initially S0=1,S1=0,S2=0: P0: while(true) { wait(S0); print '0'; release(S1); release(S2); } P1: wait(S1); release(S0); P2: wait(S2); release(S0); How many times will P0 print '0'? Options: (A) At least twice; (B) Exactly twice; (C) Exactly thrice; (D) Exactly once.
Your answer
Answer & solution
Answer: A (no official key was published)
P0 consumes the initial S0 permit and prints once, then enables P1 and P2. Each of those processes releases S0 exactly once. If both releases occur before P0 next waits on S0, binary saturation coalesces them into one permit, allowing only one further print: total 2. If P0 consumes the first released permit before the other process releases S0, it receives two separate permits and prints three times total. Thus 2 or 3 prints are possible, so the only correct choice is A, at least twice. This assumes ordinary progress/eventual scheduling; an adversarial scheduler that permanently starves runnable processes defeats any eventual-print guarantee. A counting semaphore would instead give exactly three.
The distinction between binary and counting semaphores changes the answer. A binary semaphore stores at most one available permit; release on an already available semaphore does not accumulate a second permit. P1 and P2 have no loops, so they cannot supply unbounded future permits even though P0 keeps releasing S1 and S2. That bounds the total prints above by three.
There are n single-instance resources R₀,…,Rₙ₋₁ and k processes P₀,…,Pₖ₋₁. Each process Pᵢ requests resources using: if(i%2==0) { if(i<n) request Rᵢ; if(i+2<n) request Rᵢ₊₂; } else { if(i<n) request Rₙ₋ᵢ; if(i−2<n) request Rₙ₋ᵢ₋₂; } For which offered n,k is deadlock possible? The odd-branch subscripts are faint in the scan; the explicit reading above preserves the inherited interpretation. The second odd-branch guard is printed i−2<n, not silently repaired. Options: (A) n=40,k=26; (B) n=21,k=12; (C) n=20,k=10; (D) n=41,k=19.
Your answer
Answer & solution
Answer: B (no official key was published)
Read the code as even i requesting Ri followed by R(i+2), and odd i requesting R(n−i) followed by R(n−i−2), subject to the printed guards. For n=21,k=12, P10 requests R10 then R12, while P9 requests R12 then R10. If each obtains its first resource, they wait on each other: deadlock is possible, B. For even n (A and C), even processes use only even-indexed resources in increasing order, while odd processes use only odd-indexed resources in decreasing order. Each parity class has a consistent order, so neither can cycle. For D, n=41,k=19: even processes use resources 0 through 20, whereas odd processes use even resources 22 through 40, so these opposite-order sets do not overlap and cannot form a cycle. This uses single-instance, non-preemptive resources held until completion, the standard deadlock model. The low-quality scan has faint minus signs/subscripts in the odd branch; the relevant R(n−i),R(n−i−2) reading is recorded explicitly.
The deadlocking B execution can be written explicitly: P10 acquires R10; P9 acquires R12; P10 blocks requesting R12; P9 blocks requesting R10. The resource-allocation graph now has a cycle with single-instance resources. Consistent increasing or decreasing order prevents cycles within one resource set, but opposing orders on overlapping resources can create the exhibited cycle.
For which listed page replacement policy may Belady’s anomaly occur? A FIFO; B optimal; C LRU; D MRU.
Your answer
Answer & solution
Answer: A (no official key was published)
FIFO can incur more faults with more frames: the standard reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 has 9 faults with 3 frames and 10 with 4. LRU and optimal replacement have the stack-inclusion property; ordinary MRU also preserves inclusion for nested initially empty caches. Thus FIFO is the supplied policy exhibiting the anomaly, A.
FIFO can evict a page because it arrived long ago even if it will be reused immediately; adding frames changes that queue order and can increase faults. The classic reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 produces 9 FIFO faults with three frames and 10 with four. LRU and optimal have the inclusion/stack property that prevents this anomaly. The intended listed answer is FIFO; the baseline qualification concerning the exact MRU model remains important.
What is essential in each conventional page-table entry? A virtual page number; B physical page-frame number; C both numbers; D access-right information.
Your answer
Answer & solution
Answer: B (no official key was published)
A conventional page table is indexed by the virtual page number, so that number need not be stored again in each entry. Its essential mapping result is the physical page-frame number, B. Permission and status bits may also be included; inverted/hashed organizations have different entry layouts and are not the conventional indexed table assumed here.
A conventional page table is indexed by virtual page number, so that number is implicit in the entry’s position rather than necessarily stored again. The essential translation payload identifies the physical frame. Protection, valid and dirty information may also be stored, but access rights alone cannot perform address translation. Thus B is the expected minimum translation information; hashed or inverted page-table organizations can require additional explicit tags.
Resources R1, R2, R3, R4 have totals 3, 2, 3, 2. Requests are nonpreemptive and all-or-nothing. Independent progress timelines: P1 t0 requests 2R2, t1 requests 1R3, t3 requests 2R1, t5 releases 1R2+1R1, t7 releases 1R3, t8 requests 2R4, t10 finishes. P2 t0 requests 2R3, t2 requests 1R4, t4 requests 1R1, t6 releases 1R3, t8 finishes. P3 t0 requests 1R4, t2 requests 2R1, t5 releases 2R1, t7 requests 1R2, t8 requests 1R3, t9 finishes. Starting together, choose A all finish; B only P1/P2 deadlock; C only P1/P3 deadlock; D all deadlock.
Your answer
Answer & solution
Answer: A under blocked-process local time (no official key was published)
Initially P1 holds both R2 units, P2 two R3 units, and P3 one R4. P1 obtains its R3 at 1; P2 obtains its R4 and P3 two R1 at 2. P1 then waits for two R1 at 3 because only one is free. P2 can take that last R1 at 4. At 5 P3 releases its two R1, allowing P1 to resume. Its local-time 5 releases now occur at wall time 7, providing the R2 requested by P3. P2 releases R3 at 6 and finishes at 8, so P3 can obtain R3 at 8 and finish at 9. P1’s later two-R4 request can be satisfied after those completions, and it finishes. No circular wait persists; A. The timeline treats each listed time as progress time in an independently running process, with blocked execution delayed.
A temporary wait is not sufficient evidence of deadlock: check whether another process can still progress and release the needed resource. At time 3, P1 lacks its two R1 units, but P3 will release two at time 5 without needing anything from P1 first. That release allows P1 to resume. P1’s later release of R2 lets P3 progress; P2 independently releases R3 and finishes. The dependency chain therefore has an escape. Using progress times delayed during blocking gives the timeline above and all processes eventually finish, A. Treating delayed operations as occurring retroactively at their original wall times would be inconsistent.
A disk has 100 cylinders, head initially 50, all requests pending in listed order 4, 34, 10, 7, 19, 73, 2, 15, 6, 20. SSTF costs 1 ms per cylinder moved. Total seek time? A 95; B 119; C 233; D 276 ms.
Your answer
Answer & solution
Answer: B (no official key was published)
Step through it (12 steps)
With all listed requests pending, SSTF visits 50→34→20→19→15→10→7→6→4→2→73. The decreasing leg costs 48 cylinders and the final increasing leg 71, totaling 119. At 1 ms per adjacent cylinder the seek time is 119 ms, B, excluding unspecified transfer/rotation costs.
At 50, the nearest pending request is 34 (distance 16), not 73 (distance 23). From 34 choose 20, then 19, 15, 10, 7, 6, 4, 2, always the nearest remaining cylinder. This monotone descent costs 50−2=48 in total. Only 73 then remains, costing 73−2=71. Total movement 119 times 1 ms gives 119 ms. Initial request order is irrelevant after all are pending under SSTF; FCFS would follow that order and produce a different answer.
Process transitions: A Start→Ready; B Ready→Running; C Running→Ready; D Running→Terminated; E Blocked→Ready; F Running→Blocked. A uniprocessor always has some ready processes. Assess I D immediately causes another A; II E may occur while another process runs; III preemptive scheduling; IV nonpreemptive scheduling. A I/II; B I/III; C II/III; D II/IV.
Your answer
Answer & solution
Answer: C under conventional preemption labeling (no official key was published)
D terminates a running process; another ready process is dispatched through B, not newly admitted through A, so I is false. A blocked process can become ready by E while another runs, so II is true. The running-to-ready edge C represents preemption in the conventional diagram, making III true and IV false. Thus II and III, C. If C were instead explicitly defined as voluntary yield, the drawing alone would not establish preemption; the usual state-diagram convention is used.
Termination frees the CPU, so the scheduler dispatches an already ready process along B. It need not create or admit a process along A, making I false. An I/O completion can move a different process from blocked to ready while the CPU is busy, making II true. Under the conventional interpretation, C is preemption and distinguishes the diagram from a purely nonpreemptive scheduler. Thus III is selected with II; if C instead explicitly meant voluntary yield, that additional meaning would need a separate analysis.
Shared lock X starts 0. enter_CS spins while atomic test-and-set(X) returns true; leave_CS writes X=0. Assess I deadlock-free; II starvation-free; III FIFO entry; IV multiple simultaneous entrants. A I only; B I/II; C II/III; D IV only.
Your answer
Answer & solution
Answer: A (no official key was published)
Atomic test-and-set allows exactly one contender to observe 0 and enter, preserving mutual exclusion. When the current holder eventually leaves and resets X, some contender can acquire it, so the lock is deadlock-free under ordinary progress assumptions. There is no FIFO order or bounded-wait guarantee: the same process can repeatedly win and starve another. Only I holds, A. X denotes shared lock storage in this pseudocode, not an ordinary pass-by-value C local.
The atomic operation returns the old flag and sets it to 1 as one indivisible action. Only one contender can see old 0, so IV is false. Once the holder releases, some waiting process can succeed, assuming the holder and scheduler make ordinary progress; this supplies deadlock freedom. But no queue orders contenders. A newly arriving or repeatedly scheduled process can keep winning before another waiter, defeating both FIFO and starvation freedom. Therefore only I is justified.
Why prefer multilevel over single-level page tables? A shorter memory access time; B reduced page-table storage for a process virtual address space; C required by a TLB; D fewer replacement page faults.
Your answer
Answer & solution
Answer: B (no official key was published)
A sparse virtual address space need not allocate lower-level page tables for unused regions. This can reduce the resident page-table storage compared with a full flat table, B. Extra levels do not inherently shorten a page walk, eliminate page faults or become mandatory merely because a TLB exists.
A flat table allocates an entry for every possible virtual page even when most virtual regions are unused. A multilevel table can omit entire lower-level tables for absent regions, saving storage. This is the purpose captured by B. The price may be additional memory references on a TLB miss, not a guaranteed speedup. Neither a TLB nor the page-replacement policy logically requires a multilevel representation.
Disk has 63 sectors/track, 10 platters with 2 surfaces each, 1000 cylinders. Zero-based address(c, h, s) orders sectors then surfaces then cylinders. Convert(400, 16, 29) to linear sector index: A 505035; B 505036; C 505037; D 505038.
Your answer
Answer & solution
Answer: C (no official key was published)
There are 10×2=20 recording surfaces, hence 20 tracks per cylinder. With 63 sectors per track and all indices starting at zero, linear sector index = ((c×20)+h)×63+s. For (400, 16, 29) this is (8000+16)×63+29=505008+29=505037, option C. No one-based correction applies because the shared statement explicitly labels the first sector (0, 0, 0) as sector 0.
There are 20 tracks per cylinder because each recording surface supplies one track at that radius. Convert cylinder and surface to track index 400·20+16=8016. Convert to sector index 8016·63+29=505037. Every multiplication moves one level down the address hierarchy. The explicit zero-based convention means no extra 1 is added at the end.
For the same disk with 20 surfaces/cylinder and 63 sectors/track, convert zero-based linear sector 1039 to(c, h, s): A(0, 15, 31); B(0, 16, 30); C(0, 16, 31); D(0, 17, 31).
Your answer
Answer & solution
Answer: C (no official key was published)
Each cylinder contains 20×63=1260 sectors. Divide 1039 by 1260: cylinder c=0 with remainder 1039. Then 1039=16×63+31, giving surface h=16 and sector s=31. Thus the address is (0, 16, 31), option C. This uses the zero-based indexing explicitly defined in the common data on physical page 11.
Invert the mixed-radix calculation. One cylinder spans 1260 sectors, so 1039 lies in cylinder 0. Divide the remainder by 63: quotient 16 is the surface and remainder 31 is the sector. Check by recomposition:((0·20)+16)·63+31=1039. This is C; options differing by one reveal the common mistake of silently switching to one-based counting.
How are blocks of a very large file allocated in the Unix file system?
(A) Contiguous allocation (B) Linked allocation (C) Indexed allocation (D) An extension of indexed allocation
Your answer
Answer & solution
Answer: D (no official key was published)
1. Unix inodes store direct data-block addresses for small files. 2. For larger files, indirect blocks contain further addresses; double and triple indirection extend this hierarchy. 3. This is multilevel indexed allocation, the extension described in D. It neither requires contiguous blocks nor follows a next-block pointer stored in each data block.
Counting-semaphore operations are P(s): decrement s and wait if s<0; V(s): increment s and wake one waiter if s≤0. Given binary-semaphore wait/signal Pb,Vb, consider: P(s): Pb(xb); s=s−1; if(s<0){Vb(xb); Pb(yb);} else Vb(xb); V(s): Pb(xb); s=s+1; if(s≤0) Vb(yb); Vb(xb); What initial values should xb,yb have respectively?
(A) 0,0 (B) 0,1 (C) 1,0 (D) 1,1
Your answer
Answer & solution
Answer: C (no official key was published)
1. The semaphore xb protects the shared count and must start unlocked at 1. The semaphore yb represents the waiting gate and must start at 0, so a P operation with negative count blocks. 2. Thus the required initial values are (1,0), option C. This answers the initialization question, not a proof of the whole implementation. 3. Under ordinary saturating binary-semaphore semantics the shown implementation can lose a wakeup: two P callers decrement to -2 and pause before Pb(yb); two V callers then both signal yb before either waiter consumes it, leaving only one stored signal. A robust implementation needs additional synchronization or a specified wakeup protocol.
Which statement about synchronous/asynchronous I/O is NOT true in the interrupt-driven model?
(A) An ISR is invoked on synchronous completion but not asynchronous completion (B) Both synchronous and asynchronous I/O invoke an ISR after completion (C) Synchronous callers wait for completion; asynchronous callers do not (D) For synchronous I/O, the completion ISR wakes the waiting process
Your answer
Answer & solution
Answer: A (no official key was published)
1. In the intended interrupt-driven I/O model, both synchronous and asynchronous operations can invoke an ISR on completion. Synchronous versus asynchronous describes whether the requesting process waits, not whether completion interrupts exist. 2. Hence A is the false statement; B, C and D describe the model. More generally I/O can be polled, so interrupt use is an assumed implementation detail rather than a universal consequence of synchronous/asynchronous semantics.
Which is NOT true of deadlock prevention and avoidance?
(A) Prevention always grants a request if the resulting state is safe (B) Avoidance always grants a request if the resulting state is safe (C) Avoidance is less restrictive than prevention (D) Avoidance needs resource requirements known in advance
Your answer
Answer & solution
Answer: A (no official key was published)
1. Prevention breaks a necessary condition for deadlock, for example by requiring a fixed acquisition order or all-at-once requests. It may deny a request even though granting it would leave a safe state. 2. Avoidance explicitly tests safety using declared maximum needs and grants an otherwise valid request if safety is preserved. 3. Thus A incorrectly attributes avoidance’s rule to prevention. The conventional comparison makes B,C,D true: avoidance is less structurally restrictive but needs advance resource information.
A process executes for(i=0;i<n;i++) fork();. How many child processes are created in total, assuming all forks succeed?
(A) n (B) 2^n−1 (C) 2^n (D) 2^(n+1)−1
Your answer
Answer & solution
Answer: B (no official key was published)
Step through it (3 cases)
1. Both parent and new child continue the loop after each successful fork. Hence each iteration doubles the number of processes still executing. 2. From one process, n iterations yield 2n total processes. Equivalently the iterations create 1+2+⋯+2n−1 children. 3. Subtract the one original process: 2n−1, B. Counting only n forks by the original parent misses descendants’ forks.
A processor has 36-bit physical and 32-bit virtual addresses, 4-KiB page frames, and 4-byte page-table entries. Its three-level translation indexes level 1 with VA bits 30–31, level 2 with bits 21–29, level 3 with bits 12–20; bits 0–11 are page offset. How many address bits in entries at levels 1,2,3 identify the next table or final frame, respectively?
1. Each second- and third-level table has 29 entries of 4 bytes, so it occupies 211 bytes. With compact 2-KiB-aligned tables in a 36-bit physical address space, a pointer to either table needs 36−11=25 bits. 2. A data page frame occupies 212 bytes and its frame number needs 36−12=24 bits. The result is (25,25,24), option D. 3. This uses the intended natural table-size alignment; forcing every table to a separate 4-KiB frame would instead produce 24-bit table-frame pointers.
1. Approach. Gang scheduling groups collaborating threads; rate monotonic assigns priorities from task periods; fair share divides capacity between users or groups rather than only individual runnable processes.
2. Derivation and interpretation. Gang scheduling coordinates related threads, P→3. Rate-monotonic priorities schedule periodic real-time tasks, Q→2. Fair-share scheduling aims to guarantee users/groups an allocated CPU share, R→1. Thus A.
Which statement about user-level and kernel-level threads is false? Options: (A) Context switches take longer for kernel-level than user-level threads (B) User-level threads need no hardware support (C) Related kernel threads may run on different processors (D) Blocking one kernel thread blocks all related threads
Your answer
Answer & solution
Answer: D (no official key was published)
1. Approach. The kernel knows about each kernel thread and can choose another runnable thread when one blocks. Contrast this with a many-to-one user-thread implementation whose sole kernel thread blocks.
2. Derivation and interpretation. Kernel threads are independently schedulable, including on different processors. Blocking one does not inherently block every sibling thread, making D false. User-level thread switching can avoid kernel entry and dedicated threading hardware under the conventional comparison; kernel scheduling manages each kernel thread separately.
Shortest remaining time scheduling and waiting time
CPU Scheduling
Tap to enlarge
Shortest Remaining Time first schedules four processes: P1 arrives at 0 and requires 20 units; P2 at 15 requires 25; P3 at 30 requires 10; P4 at 45 requires 15. What is P2’s total waiting time? Options: (A) 5 (B) 15 (C) 40 (D) 55
Your answer
Answer & solution
Answer: B (no official key was published)
Step through it (8 steps)
1. Approach. At each arrival compare remaining service, not original burst lengths. Draw the execution intervals and count only the intervals after P2 arrives during which it is ready but not running.
2. Derivation and interpretation. P1 runs from 0 to 20: at P2's arrival at 15, P1 has only 5 units left versus P2's 25. P2 runs 20–30, leaving 15; P3 then arrives with 10 and runs 30–40. P2 resumes at 40. When P4 arrives at 45, P2 has 10 left versus P4's 15, so P2 continues until 55. Its waiting intervals are 15–20 and 30–40, totaling 5+10=15 (B). Equivalently completion−arrival−execution=55−15−25=15.
A virtual-memory system uses FIFO replacement with a fixed allocation of frames. P: increasing a process’s frame allocation sometimes increases its page-fault rate. Q: some programs do not exhibit locality of reference. Which statement is true? Options: (A) Both true and Q explains P (B) Both true but Q does not explain P (C) P false,Q true (D) Both false
Your answer
Answer & solution
Answer: B (no official key was published)
1. Approach. Separate truth from causation. Belady’s anomaly is possible because FIFO does not retain a nested set of resident pages as frame count grows; locality is not the defining cause.
2. Derivation and interpretation. P is true: FIFO can exhibit Belady's anomaly. For example, reference string 1,2,3,4,1,2,5,1,2,3,4,5 incurs 9 faults with three initially empty frames but 10 with four. Q is also true: programs can make accesses without useful locality, for example broadly scattered independent random accesses. Q does not explain the anomaly; the issue is FIFO's failure of the stack-inclusion property, not simply the presence or absence of locality. Stack algorithms such as LRU do not exhibit this anomaly even on reference strings without locality. Thus B.
Three processes share resource types X,Y,Z, with 5 units of each. Allocated and additionally requested vectors (X,Y,Z) are: P0 alloc=(1,2,1), request=(1,0,3); P1 alloc=(2,0,1), request=(0,1,2); P2 alloc=(2,2,1), request=(1,2,0). Each request is needed to finish, after which resources are released. Which process finishes last? Options: (A) P0 (B) P1 (C) P2 (D) None; the system is deadlocked
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (5 steps)
1. Approach. Subtract all allocations from the total vector to obtain current availability. Repeatedly choose a process whose remaining request fits componentwise, then add its old allocation back to availability.
2. Derivation and interpretation. Allocated totals are (1,2,1)+(2,0,1)+(2,2,1)=(5,4,3), so the initial available vector is (0,1,2). Only P1's remaining request (0,1,2) can be met. After P1 completes and returns all its resources, availability becomes (0,1,2)+(2,0,1)=(2,1,3). P0's request (1,0,3) can now be met, while P2 still needs two Y units but only one is available. P0 finishes next, leaving availability (2,1,3)+(1,2,1)=(3,3,4), which permits P2's request (1,2,0). The forced safe order is P1,P0,P2, so P2 finishes last (C), assuming each request is the additional resource vector needed for completion as stated.
Two intent flags give mutual exclusion but may deadlock
Synchronization & Concurrency
Tap to enlarge
Shared flags wants1,wants2 are initially false. P1 executes: while(true) { wants1=true; while(wants2==true); /* critical section */ wants1=false; } P2 executes: while(true) { wants2=true; while(wants1==true); /* critical section */ wants2=false; } The source places each remainder-section comment after its loop. Under atomic sequentially consistent flag operations, which statement is intended? Options: (A) Mutual exclusion is not ensured (B) Bounded waiting is not ensured (C) Critical sections must alternate strictly (D) Deadlock is not prevented, but mutual exclusion is ensured
Your answer
Answer & solution
Answer: D (no official key was published)
1. Approach. Test safety and progress separately. Two critical sections cannot overlap because each entrant advertises its intent. But if both advertise before either tests, neither can reach the instruction clearing its flag.
2. Derivation and interpretation. Under the standard sequentially consistent, atomic-read/write pseudocode model, each process sets its own wants flag before testing the other's flag and keeps it true throughout its critical section. Thus both cannot pass their tests and overlap in the critical section: whichever passes first prevents the other entering until it clears its flag. However, if both set their flags before either tests the other, each spins forever, giving deadlock. Thus D describes the decisive combination: mutual exclusion holds but deadlock prevention fails. Strict alternation is not required; one process can repeatedly enter while the other does not request entry. Option B needs care: under a broad interpretation that bounded waiting guarantees eventual entry, deadlock also violates it. In the usual bounded-overtaking formulation, distinguish this progress failure from another process overtaking a waiter indefinitely; the latter cannot occur here. D is the intended most specific answer, while the phrasing of B can be read more broadly.
A process has three initially empty page frames and reference string 1,2,1,3,7,4,5,6,3,1. How many page faults occur with optimal replacement? Options: (A) 7 (B) 8 (C) 9 (D) 10
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (12 steps)
1. Approach. At a miss with full frames, evict the page whose next reference lies farthest in the future, treating never-used-again pages as farthest. Keeping pages 1 and 3 is valuable because both are referenced at the end.
2. Derivation and interpretation. For references 1,2,1,3,7,4,5,6,3,1 with three initially empty frames, first load 1,2,3 (the second reference to 1 hits). When 7 arrives, discard 2 because it is never needed again. Retain 1 and 3 while replacing the third frame successively by 7,4,5,6; each of these pages has no future use. The final 3 and 1 then hit. Faults are on 1,2,3,7,4,5,6, totaling 7, option A. Seven distinct pages also give a matching lower bound.
A process has three initially empty page frames and reference string 1,2,1,3,7,4,5,6,3,1. How many more faults does LRU incur than optimal replacement? Options: (A) 0 (B) 1 (C) 2 (D) 3
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (2 policies)
1. Approach. LRU uses past recency rather than future references. Maintain a least-recent-to-most-recent list and move a page to the end even on a hit; then compare the full LRU count with the optimal count.
2. Derivation and interpretation. LRU faults on references 1,2,3,7,4,5,6,3,1; only the early repeated 1 hits. After loading 3, the least-recent order is 2,1,3; successive new pages evict 2, then 1, then 3, then 7. Therefore final references 3 and 1 also fault. LRU has 9 faults versus the optimal 7, an excess of 2, option C.
Three CPU-bound processes arrive at times 0,2,6 and need 10,20,30 time units respectively. With shortest-remaining-time-first scheduling, how many context switches occur, excluding initial dispatch at time 0 and final termination? Options: (A) 1 (B) 2 (C) 3 (D) 4
Your answer
Answer & solution
Answer: B (no official key was published)
1. At time 2 the first process has 8 units remaining, less than the new 20. At time 6 it has 4 remaining, less than 30.
2. It therefore runs 0–10, followed by the 20-unit process 10–30 and the 30-unit process 30–60. Excluding initial dispatch and final exit leaves two process switches, B.
3. Teaching check: Draw the CPU timeline 0–10:P1, 10–30:P2, 30–60:P3. An arrival is not automatically a preemption: compare its burst with the current remaining time. Only the changes P1→P2 and P2→P3 count under the exclusions in the question.
Atomic fetch-and-set(x,y) sets shared location x to 1 and returns its old value in y, without an intervening access. Binary semaphore code is: P(S): do { fetch-and-set(S.value,y); } while(y); V(S): S.value=0; Which statement is true? Options: (A) P may fail to work if context switching is disabled inside it (B) A normal load/store pair can replace atomic fetch-and-set (C) V is incorrectly implemented (D) The code does not implement a binary semaphore
Your answer
Answer & solution
Answer: A (no official key was published)
1. P repeatedly atomically exchanges S.value with 1 and succeeds only when the previous value was 0. V releases it by storing 0.
2. On a uniprocessor, a process spinning in P with context switching disabled can prevent the lock owner from running V, so progress can fail. Separate load/store instructions are not atomic and allow two contenders to enter.
3. Thus A is true. This is a busy-wait semaphore using 0 for available and 1 for held; assume the intended atomic shared-memory model.
4. Teaching check: Atomicity prevents two contenders from both observing an available semaphore and entering. It does not guarantee progress if the spinning contender prevents the holder from being scheduled. Thus mutual-exclusion correctness and scheduling/liveness assumptions must be considered separately.
A system has both 32-bit virtual and 32-bit physical addresses. Its designers remove virtual memory because the address-space sizes are equal. Which claimed consequence is true? Options: (A) Efficient multiuser support becomes impossible (B) The cache organization can be made more efficient (C) Hardware memory-management support is no longer needed (D) CPU scheduling can be made more efficient
Your answer
Answer & solution
Answer: B (no official key was published)
1. Equal virtual and physical address widths do not make virtual memory redundant: address-space isolation, relocation, and protection still matter. Nevertheless removing address translation can simplify cache lookup, avoid translation-related latency and virtual alias issues, and thus permit a more efficient cache organization (B says can, not must).
2. Multi-user operation remains possible with other protection mechanisms; memory-management hardware can still be needed, and CPU scheduling does not automatically improve.
3. Teaching check: Equal address widths do not imply an identity mapping or a single shared address space. Different processes can map the same virtual address to different physical pages. The question’s true claim is only that cache organization can become simpler without translation, not that deleting virtual memory is generally desirable.
Processes with IDs 0,1,2 all arrive at time zero and need 2,4,8 compute units respectively. Use longest-remaining-time-first, reevaluated each time unit, with ties favoring the lower ID. What is average turnaround time? Options: (A) 13 (B) 14 (C) 15 (D) 16
Your answer
Answer & solution
Answer: A (no official key was published)
1. Using one-unit scheduling steps and breaking ties by the lower process ID, the running process IDs for times 0 through 13 are 2,2,2,2,1,2,1,2,0,1,2,0,1,2. Completion times are 12,13,14 for IDs 0,1,2.
2. Since arrivals are all zero, mean turnaround=(12+13+14)/3=13 units, A. This uses the intended discrete time-unit model; ideal continuous reevaluation at every instant would require a separate tie-sharing convention.
3. Teaching check: Turnaround equals completion time because every arrival is zero. LRTF initially favors the eight-unit process, but its remaining time eventually ties the four-unit process and the tie rule changes the schedule. Computing each completion time is safer than averaging burst lengths or waiting times alone.
Three processes arrive at time zero with total activity durations 10,20,30. Each spends its first 20% in I/O, next 70% computing, and last 10% in I/O. I/O overlaps as much as possible. The CPU chooses the shortest remaining compute burst when its current process blocks or completes its burst. What percentage of the entire elapsed interval is CPU-idle? Options: (A) 0% (B) 10.6% (C) 30.0% (D) 89.4%
Your answer
Answer & solution
Answer: B (no official key was published)
1. The three initial I/O bursts last 2,4,6; compute bursts last 7,14,21; final I/O bursts last 1,2,3. CPU is idle 0–2, executes process 1 during 2–9, process 2 during 9–23, and process 3 during 23–44.
2. Their final I/O finishes at 10,25,47. Over the complete 47-unit elapsed interval, CPU idle time is 2+3=5, hence 100×5/47≈10.6%, B.
3. The question continues on physical page 10.
4. Teaching check: The initial I/O phases overlap, so their elapsed cost is not 2+4+6 in series. While the first process computes, the other initial I/Os finish. The final three-unit I/O of the last process extends the completion horizon beyond the final CPU burst, producing additional CPU-idle time.
There are n processes; process i holds xᵢ instances of a resource and requests yᵢ additional instances. All resource instances are allocated. Exactly two processes p,q have yₚ=y_q=0. Which can be a necessary condition for avoiding impending deadlock? Max/min below range over k≠p,q. GFG prints max in B; GateForum prints min, a materially different condition. Options: (A) min(xₚ,x_q)<max yₖ (B) xₚ+x_q≥max yₖ [GFG]; xₚ+x_q≥min yₖ [GateForum] (C) max(xₚ,x_q)>1 (D) min(xₚ,x_q)>1
Your answer
Answer & solution
Answer: As printed, no listed condition is universally necessary (no official key was published)
1. Only p and q can initially finish without another allocation. After both finish, available resources equal W=xp+xq.
2. To make any further progress, at least one remaining process must have yk≤W; therefore W≥mink≠p,qyk is necessary (not sufficient for eventual completion of all processes).
3. The paper instead prints max in B: W≥max yk is sufficient, assuming these are remaining completion needs, but is not necessary. Counterexample: allocations (1,1,2,1), additional requests (0,0,1,3) have a safe sequence p,q,r,s: W grows 2→4→5, yet initial W=2<3.
4. No other the paper option is universally necessary: with all four allocations 1 and remaining requests (0,0,1,1), a safe sequence exists while A (1<1), C (1>1), and D (1>1) are false.
5. Teaching check: A necessary condition need not guarantee full completion. Once p and q release their holdings, at least one remaining process must be able to obtain its requested resources. Requiring enough for the largest request is stronger than necessary; a smaller request may finish first and release more resources.
Three processes repeatedly synchronize at a barrier. Shared process_arrived and process_left start at 0. S is a binary semaphore, initially available; P acquires and V releases it. Each process calls: void barrier(void) { 1: P(S); 2: process_arrived++; 3: V(S); 4: while (process_arrived != 3); 5: P(S); 6: process_left++; 7: if (process_left == 3) { 8: process_arrived=0; 9: process_left=0; 10: } 11: V(S); } Use the intended shared-memory pseudocode model, not a claim of data-race-safe modern C. Why is the implementation incorrect? Options: (A) The use of binary semaphore S makes it wrong (B) Two consecutive barrier invocations can deadlock (C) Lines 6–10 do not need a critical section (D) It is correct with two processes instead of three
Your answer
Answer & solution
Answer: B (no official key was published)
1. Once all three arrive, process_arrived=3. Let P leave the first barrier, increment process_left to 1, and immediately enter its next barrier before Q and R have finished the first.
2. It increments process_arrived to 4. If Q and R have not passed the first barrier’s while test, they now wait for process_arrived==3, and P also waits in its second invocation.
3. No one can perform the final reset: deadlock. Binary semaphores correctly protect the updates and are not the cause; the missing separation between barrier generations is.
4. The same issue can occur with two processes. Hence B.
5. Teaching check: The first invocation opens when arrival count reaches three, but the code does not close entry to the next generation. An early returning process can raise the count to four while another still tests for equality with three. A protected increment alone does not prevent mixing generations.
Three processes repeatedly synchronize at a barrier. Shared process_arrived and process_left start at 0. S is a binary semaphore, initially available; P acquires and V releases it. Each process calls: void barrier(void) { 1: P(S); 2: process_arrived++; 3: V(S); 4: while (process_arrived != 3); 5: P(S); 6: process_left++; 7: if (process_left == 3) { 8: process_arrived=0; 9: process_left=0; 10: } 11: V(S); } Use the intended shared-memory pseudocode model, not a claim of data-race-safe modern C. Which proposed repair addresses its reuse problem? The phrase “first process” in B is only a conceptual generation gate and needs a concrete synchronization implementation. Options: (A) Replace lines 6–10 by process_arrived-- (B) At barrier entry, the first process waits for process_arrived to become zero before executing P(S) (C) Disable context switching throughout the barrier (D) Make process_left private instead of shared
Your answer
Answer & solution
Answer: B, with generation-entry qualification (no official key was published)
1. The intended repair is to prevent a process from incrementing the next generation’s arrival count until the previous generation has reset process_arrived to zero, corresponding to B. It must wait before acquiring S, leaving S available to the final departing process that performs the reset.
2. A lets an early departure lower process_arrived while others still need to observe 3; C prevents necessary scheduling on a uniprocessor; D prevents the shared departure count reaching 3. However the phrase first process to enter is a conceptual generation gate, not complete executable synchronization.
3. Merely adding an unconditional while(process_arrived!=0) to every invocation blocks the second arrival of the same generation; waiting only one vaguely designated process while allowing another new-generation entrant through is also insufficient. A concrete reusable barrier needs a correctly synchronized generation flag or two-turnstile design.
4. Teaching check: Waiting while holding S would prevent the final departing process from acquiring S to reset the counters. Waiting must therefore occur outside that critical section, and it must distinguish generations correctly. A two-turnstile or generation-counter barrier is a concrete way to enforce this separation.
With memory-mapped I/O and no separate privileged I/O opcodes, what enforces device-access protection? A OS routines alone; B hardware trap; C system configuration alone; D protection impossible.
Your answer
Answer & solution
Answer: B (no official key was published)
Map device registers into protected address ranges/pages and have the processor’s memory-protection hardware trap unauthorized user-mode loads or stores. Thus the immediate enforcement is a hardware trap, B, although the operating system configures the permissions and handles the exception. Ordinary unprivileged load/store opcodes do not bypass address protection.
Memory-mapped device registers occupy addresses just like memory. The OS configures access permissions, but hardware checks each user access and raises a protection exception if forbidden. This immediate trap prevents bypassing the OS merely by issuing a load/store instruction. A software routine alone cannot intercept an unchecked direct memory access, so B names enforcement, while configuration establishes policy.
What is disk swap space for? A temporary HTML; B process data; C filesystem superblock; D device drivers.
Your answer
Answer & solution
Answer: B (no official key was published)
Swap space stores process memory contents that have been evicted from RAM and may later be paged back in. Thus saving process data, B, rather than caching HTML pages or storing filesystem superblocks.
A process may have memory pages that cannot all remain in physical RAM. Swap space provides backing storage for evicted process contents, allowing them to be brought back when needed. Thus B. It is distinct from a browser cache, filesystem metadata and the ordinary files holding drivers, even though all may reside on the same physical disk.
Why does increasing RAM typically help? A more virtual memory; B larger chips are intrinsically faster; C fewer page faults; D fewer segmentation faults.
Your answer
Answer & solution
Answer: C (no official key was published)
More physical memory can retain a larger working set, reducing expensive page faults and disk paging, C. Capacity does not inherently make memory chips faster, nor does it repair illegal accesses that cause segmentation faults. Improvement depends on the workload being memory-constrained.
When working sets exceed physical memory, pages are repeatedly fetched from much slower secondary storage. Additional RAM can hold more of those pages and reduce paging, hence C. It does not automatically enlarge the architecture’s virtual address width, accelerate each DRAM access, or make an illegal address valid. The performance benefit is workload-dependent rather than guaranteed for every program.
n processes share m identical reusable units, acquired/released one at a time. Process i has positive maximum need s_i. Which is sufficient to avoid resource deadlock? A every s_i<m; B every s_i<n; C Σs_i<m+n; D Σs_i<m·n.
Your answer
Answer & solution
Answer: C (no official key was published)
If no process can finish, every process can hold at most si−1 units while still needing another unit. Thus at most sum(si−1)=sum(si)−n units can be held in an all-unfinished configuration. If sum(si)<m+n, this total is less than m, so at least one resource is free; allocating available units eventually lets a process reach its maximum and finish. Release its resources and repeat. Equivalently m>sum(si−1) guarantees progress for the single resource type. This is option C.
Suppose every unfinished process is blocked below its maximum claim. It can hold at most si−1 units, so together they can hold at mostΣ(si−1). If m exceeds that bound, some units remain available and can be allocated until at least one process finishes; its release only improves the position. Rearranging m>Σsi−n gives option C. Individual small claims alone do not prevent circular waiting among multiple processes.
Code: if(fork()==0){a=a+5;printf("%d,%d\n", a,&a);}else{a=a−5;printf("%d,%d\n", a,&a);}. Parent prints u, v and child x, y. A u=x+10, v=y; B u=x+10, v≠y; C u+10=x, v=y; D u+10=x, v≠y. Address formatting is reproduced literally and requires a portability qualification.
Your answer
Answer & solution
Answer: C, under intended address-printing semantics (no official key was published)
Let a initially equal a 0. The child executes the zero-return branch and obtains x=a 0+5; the parent obtains u=a 0−5. Therefore u+10=x. fork preserves the virtual address of a, so its address has the same numeric value in each process even though the memory is logically separate: v=y. Hence C under the intended OS model. Strictly, the printed printf uses %d for &a; that variadic type mismatch is undefined behavior in ISO C, so literal portable-C output is not guaranteed. Using %p with (void *)&a expresses the intended comparison.
fork duplicates the address-space state. The child and parent modify separate copies starting from the same initial a 0: child a 0+5, parent a 0−5, hence a difference 10. Their virtual addresses retain equal numerical locations despite distinct physical memory. This supports C as the intended OS result. The actual %d address argument is type-incorrect; use %p and a void* cast to state the intended comparison in portable C.
Regarding user-level and kernel-supported threads, select the true statements: (1) Context switching is faster with kernel-supported threads. (2) A system call by a user-level thread can block the whole process. (3) Kernel-supported threads can be scheduled independently. (4) User-level threads are transparent to the kernel. Options: (A) 2,3,4 only (B) 2,3 only (C) 1,3 only (D) 1,2 only
Your answer
Answer & solution
Answer: A (no official key was published)
1. In the conventional many-to-one user-thread model, a blocking system call can block the process, the kernel does not see individual user threads, and kernel-supported threads can be scheduled independently. Thus2,3,4 are true, A.
2. User-thread context switches normally avoid kernel transitions and are not slower by definition; statement 1 is false. Modern hybrid threading arrangements need not share the many-to-one blocking limitation.
3. Teaching check: Separate visibility from speed: the kernel schedules only what it knows about. A library can switch its user threads without a kernel transition, but a blocking call can stop their common kernel scheduling entity. Kernel-supported threads trade that limitation for kernel-managed scheduling.
An OS can load and execute one sequential user process at a time. FCFS disk scheduling is replaced by SSTF, advertised as giving 50% better benchmark performance. What improvement in user-program I/O performance is expected? The usual one-outstanding-request assumption is not explicitly stated. Options: (A) 50% (B) 40% (C) 25% (D) 0%
Your answer
Answer & solution
Answer: D under synchronous single-request I/O (no official key was published)
1. If the single sequential process blocks for each disk request, there is never a choice among queued requests. FCFS and SSTF therefore execute the same sequence, giving 0% improvement, D; a benchmark with concurrency does not transfer to this case.
2. The premise of one sequential process alone does not prohibit asynchronous I/O, readahead or background requests. Without the one-outstanding-request assumption, the improvement is not determined by the stated facts.
3. Teaching check: A seek scheduler can improve ordering only when it can choose between multiple pending requests. With exactly one pending request, both rules choose it. “50% better” on another workload is not evidence for this workload; asynchronous requests would require further information.
What determines the minimum number of page frames that must be allocated to a running process in a virtual-memory environment? Options: (A) Instruction set architecture (B) Page size (C) Physical memory size (D) Number of processes in memory
Your answer
Answer & solution
Answer: A under a fixed paging configuration (no official key was published)
1. The instruction set determines which instruction bytes and operands may have to be resident together to complete/restart one instruction without endless page faults. Thus A is the standard determinant of the minimum required frame count, rather than a count based simply on concurrent processes or total RAM.
2. Exact numerical requirements also depend on the fixed page size, operand placement, and restart implementation; the answer identifies the architectural constraint, not independence from all those details.
3. Teaching check: The minimum is about making forward progress on an instruction, not fitting the whole working set. For example, an instruction may simultaneously need its code page and multiple operand pages. The ISA constrains these requirements; page geometry and restart details matter when calculating an actual number.
Processes (arrival time,CPU burst), in ms, are P1=(0,5), P2=(1,3), P3=(2,3), P4=(4,1). What is the average turnaround time under preemptive shortest remaining processing time first (SRPT)? Options: (A) 5.50 ms (B) 5.75 ms (C) 6.00 ms (D) 6.25 ms
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (7 steps)
1. A valid SRPT schedule is P1:[0,1), P2:[1,4), P4:[4,5), P3:[5,8), P1:[8,12). P2 still has the smallest remaining time when P3 arrives.
2. Completion times for P1,P2,P3,P4 are 12,4,8,5; subtracting arrivals 0,1,2,4 gives turnaround times 12,3,6,1. Their mean is 22/4=5.50ms.
3. Teaching check: Turnaround is completion minus arrival, not total waiting time. The four turnaround values are 12,3,6,1; their sum is 22. Context-switch overhead is not supplied and is therefore excluded. Arrival of P3 at time 2 does not preempt P2, whose remaining burst is only 2.
A two-level paging system has regular memory access time 150 ns and page-fault service time 8 ms. An average instruction uses 100 ns CPU time and two memory accesses. TLB hit ratio is 90%; page faults occur once per 10,000 instructions. What is effective average instruction time? TLB lookup time and caching of page-table levels are unspecified. Options: (A) 645 ns (B) 1050 ns (C) 1215 ns (D) 1230 ns
Your answer
Answer & solution
Answer: 1260 ns under literal two-level page-table model; no listed option (no official key was published)
1. Assuming negligible TLB lookup time and a true two-level page table, a TLB hit costs 150ns and a miss costs three memory accesses: two page-table reads plus the requested data access,450ns. Two accesses per instruction therefore cost 2(0.9×150+0.1×450)=360ns.
2. Add100ns CPU time and 8,000,000/10,000=800ns amortized fault service:1260ns. None of 645,1050,1215,1230 matches.
3. Option D=1230ns results from counting only TWO total memory accesses per TLB miss:100+2(0.9×150+0.1×300)+800. That requires a single-level translation model or an unstated cached first-level entry.
4. Treat the result as model-dependent rather than silently forcing D. Minor whether-fault-service-includes-retry conventions do not account for the 30ns discrepancy.
5. Teaching check: A true two-level TLB miss reads level 1, level 2 and data: three memory accesses. The page-fault rate is per instruction, so add the 800-ns average penalty once, not twice. The closest-looking listed value must not erase the extra translation read.
Shared X,Y are protected by binary semaphores Sx,Sy, initially 1. P waits/decrements and V signals/increments. Fill L1,L2,L3,L4 to avoid deadlock: P1: while true { L1; L2; X=X+1; Y=Y-1; V(Sx); V(Sy); } P2: while true { L3; L4; Y=Y+1; X=X-1; V(Sy); V(Sx); } GateForum prints X=Y−1 in P2; that arithmetic variant does not change the locking question. Options: (A) P(Sy),P(Sx),P(Sx),P(Sy) (B) P(Sx),P(Sy),P(Sy),P(Sx) (C) P(Sx),P(Sx),P(Sy),P(Sy) (D) P(Sx),P(Sy),P(Sx),P(Sy)
Your answer
Answer & solution
Answer: D (no official key was published)
1. Both processes must acquire both Sx and Sy, exactly once, in the same global order. Option D supplies P(Sx),P(Sy) to both processes.
2. A process that has acquired Sx prevents its competitor from holding Sy while it waits for Sx, so the circular-wait condition is impossible. Options A/B use opposite acquisition orders and admit deadlock; C acquires the same binary semaphore twice and can block itself.
3. Different release orders do not invalidate the common acquisition order.
4. Teaching check: Construct an opposite-order deadlock: P1 holds Sx and waits for Sy while P2 holds Sy and waits for Sx. Requiring the same acquisition order eliminates this cycle. A release-order difference is harmless here because neither process waits while executing V.
A Unix-style inode has 10 direct pointers and one each single-, double- and triple-indirect pointer. Blocks are 1 Kbyte, block addresses are 32 bits, and integers are 48 bits. What is the maximum file size? Use 1 Kbyte=1024 bytes; alternatives are powers of two, not exact inode totals. Options: (A) 2^24 bytes (B) 2^32 bytes (C) 2^34 bytes (D) 2^48 bytes
Your answer
Answer & solution
Answer: 17,247,250,432 bytes; C only as a power-of-two approximation (no official key was published)
1. A1KiB indirect block holds 1024/4=256 addresses. The inode can reference 10+256+256²+256³=16,843,018 data blocks, totaling 17,247,250,432 bytes.
2. The32-bit block-address space and 48-bit integer bound are both larger and do not constrain this total. The dominant triple-indirect contribution alone is 256³×1024=234 bytes, option C, but the exact maximum includes direct, single-indirect and double-indirect blocks and exceeds 234 by 67,381,248 bytes.
3. Thus no offered power-of-two option is exactly the stated maximum; C is the usual scale approximation, not an exact equality.
4. Teaching check: Indirect blocks contain addresses, so divide 1024 bytes by four bytes per address before exponentiating. The triple-indirect branch contributes 256³ data blocks; it does not replace the smaller branches. Distinguish exact capacity from the dominant-power approximation offered by the choices.
In the conventional comparison for a fixed-block-size file system, increasing block size leads to: A. Better disk throughput but poorer space utilization; B. Better throughput and better utilization; C. Poorer throughput but better utilization; D. Poorer throughput and poorer utilization.
Your answer
Answer & solution
Answer: A (no official key was published)
1. Reading a larger contiguous block transfers more useful bytes per seek or setup cost for a sequential workload. But the last block of a file is allocated in full even when only partly used; increasing the allocation unit can increase this internal slack. These effects explain the conventional throughput/utilization tradeoff.
2. Larger blocks amortize per-I/O overhead across more bytes, often improving sequential disk throughput, but waste more unused space in partially occupied final blocks. Thus better throughput with poorer space utilization, A, under the conventional workload comparison. It is not a universal guarantee for every random-access workload.
With 32-bit virtual addresses and 1 KB pages, why is a one-level page table impractical? A. Large internal fragmentation; B. Large external fragmentation; C. Large memory overhead for page tables; D. Large computation overhead in translation.
Your answer
Answer & solution
Answer: C (no official key was published)
1. A 1 KB page means 2¹⁰ byte offsets, so a virtual address splits into 22 page-number bits and 10 offset bits. Even a sparsely used process address space requires all 2²² slots in a flat table. Four-byte entries are an illustration, not an additional given: they would occupy 16 MiB per table.
2. A 1 KiB page uses 10 offset bits, leaving 22 virtual-page bits in a 32-bit address. A flat table therefore needs 222 entries per address space; at 4 bytes each this is 16 MiB. The large memory overhead, C, motivates multilevel or other sparse organizations.
Which is NOT an advantage of shared, dynamically linked libraries over statically linked libraries? A. Smaller executable files B. Lower overall page-fault rate in the system C. Faster program startup D. Existing programs need not be relinked to benefit from newer library versions
Your answer
Answer & solution
Answer: C (no official key was published)
1. Static linking copies required library code into each executable. Dynamic linking can leave that code in a separately loaded library, reducing executable size, so A is a conventional benefit. 2. Multiple processes can map the same read-only physical library pages. This reduces duplicated resident code and can reduce total memory pressure/page faults, the intended benefit in B. 3. A compatible replacement library may be used on the next load without rebuilding each application, explaining D; compatibility remains necessary. 4. Dynamic loading and symbol relocation/resolution add work at startup or first use. Faster startup is not a general advantage, so C is the requested exception. Actual cache and page-fault behavior still depends on workload.
Solution: Dynamic linking can keep library code out of the executable, share physical library pages among processes, and permit compatible library updates without relinking each application. It also introduces runtime loading, relocation, or symbol-resolution work. Faster program startup is therefore not the characteristic advantage over static linking, option C. The other listed benefits are the conventional shared-library benefits; actual page-fault and startup measurements can depend on caching and workload.
A uniprocessor runs only two processes, created nearly simultaneously. Each alternates a 10 ms CPU burst with a 90 ms I/O burst; their I/O can proceed in parallel. Which policy gives the least long-run CPU utilization? A. First come, first served B. Shortest remaining time first C. Static priority with different priorities D. Round robin with a 5 ms quantum
Your answer
Answer & solution
Answer: D (no official key was published)
1. Ignore switching overhead as the statement supplies none. Under FCFS one process runs 0–10 and the other 10–20. Their I/O ends at 100 and 110, and each finishes its next CPU burst just as the other becomes ready. Thus the CPU supplies 20 ms work per 100 ms: 20% utilization. SRTF and distinct priorities have the same sustained burst staggering here. 2. Under 5 ms round robin, the initial slices are P:0–5, Q:5–10, P:10–15, Q:15–20. Their I/O begins at 15 and 20, only 5 ms apart, and ends at 105 and 110. 3. With the usual ordering when I/O completion coincides with quantum expiry, Q gets the CPU at 110, so the next completed CPU bursts are at 120 and 125. This repeats the paired pattern after 105 ms. 4. Utilization is 20/105≈19.05%, less than 20%, making D the conventional answer. The smaller separation causes more simultaneous I/O and hence more CPU idle time.
Solution: Ignoring context-switch cost, FCFS, shortest-remaining-time, and distinct static priorities run the two initial CPU bursts consecutively for 10 ms each. Their I/O completions stay offset by 10 ms, giving 20 ms of CPU work in a 100 ms steady-state period. With round robin at a 5 ms quantum, the initial bursts finish at 15 and 20 ms, so the processes enter I/O only 5 ms apart. Under the usual ready-queue ordering at simultaneous quantum expiry and I/O completion, this pattern repeats every 105 ms, giving utilization 20/105≈19.05%, below 20%. Thus D is the conventional answer: fine time slicing makes their long I/O intervals overlap more.
A byte-addressable processor has 32-bit virtual and physical addresses and two-level page tables stored in main memory. Address bits are split 10 bits for first-level index, 10 for second-level index, and 12 for page offset. All page-table entries are 4 bytes. TLB hit rate is 96%, physical-cache hit rate 90%; TLB and cache access each take 1 ns, and main memory takes 10 ns. A process maps only two contiguous code pages starting at 0x00000000, two contiguous data pages starting at 0x00400000, and one stack page starting at 0xFFFFF000. How much storage is needed for its page tables? A. 8 KB B. 12 KB C. 16 KB D. 20 KB
Your answer
Answer & solution
Answer: C (no official key was published)
1. A 10-bit index selects 1024 entries. At four bytes per entry each full table occupies 4096 bytes, one 4 KiB page. 2. One second-level table covers 1024 virtual pages, or 1024×4096=4 MiB. The code pages fall in the first 4 MiB region, top-level index 0. The data begins exactly at 4 MiB, index 1. The stack address has index 1023. 3. The two contiguous code pages share one second-level table, as do the two data pages. The stack needs a third second-level table. Add one top-level table: four tables total. 4. Storage=4×4096=16384 bytes=16 KiB, option C. Mapped content pages are not additional page-table storage.
Solution: Each page-table level has 210 entries of four bytes, so each allocated table uses 4096 bytes. The two code pages occupy top-level index 0; the two data pages starting at 0x00400000 occupy index 1; the stack page at 0xFFFFF000 occupies index 1023. Three second-level tables are therefore required, plus the first-level table. Total page-table storage is 4×4096=16384 bytes=16 KiB, option C. The five mapped code/data/stack pages are not themselves included in page-table storage.
Two concurrent processes use binary semaphores S,T. Process P loops forever: W: [synchronization]; print '0'; print '0'; X: [synchronization]. Process Q loops forever: Y: [synchronization]; print '1'; print '1'; Z: [synchronization]. Synchronization can be placed only at W,X,Y,Z. P(S) means wait/decrement and V(S) means signal. Which always gives an output starting 001100110011...? A. W=P(S), X=V(S), Y=P(T), Z=V(T); S=T=1 initially B. W=P(S), X=V(T), Y=P(T), Z=V(S); S=1,T=0 initially C. W=P(S), X=V(T), Y=P(T), Z=V(S); S=T=1 initially D. W=P(S), X=V(S), Y=P(T), Z=V(T); S=1,T=0 initially
Your answer
Answer & solution
Answer: B (no official key was published)
1. The required output demands both pairwise exclusion and alternation starting with P's zeros. Initially only P should have permission: S=1 and T=0. 2. P passes wait(S), prints both zeros, then signals T. Q cannot print any one until this signal; once released it consumes T, prints both ones and signals S. 3. P's next wait(S) cannot pass before Q completes its pair. Inductively the execution consists of 00,11,00,11,..., so B works. 4. In A independent locks allow arbitrary interleaving. C initially lets both processes enter, so even the first pair need not be 00. In D Q waits forever on T because no other process signals T.
Solution: Initially give P permission to run by setting S=1 and block Q with T=0. P waits on S at W, prints both zeroes, and signals T at X. Q waits on T at Y, prints both ones, and signals S at Z. Each process therefore hands permission to the other only after completing its pair, forcing 00,11,00,11,… starting with 00. This is B. Separate locks do not coordinate the processes, and initializing both cross-signalling semaphores to one would permit initial interleaving.
Two concurrent processes use binary semaphores S,T. Process P loops forever: W: [synchronization]; print '0'; print '0'; X: [synchronization]. Process Q loops forever: Y: [synchronization]; print '1'; print '1'; Z: [synchronization]. Synchronization can be placed only at W,X,Y,Z. P(S) means wait/decrement and V(S) means signal. Which ensures the output never contains 0 1^n 0 or 1 0^n 1 with n odd? A. W=P(S), X=V(S), Y=P(T), Z=V(T); S=T=1 B. W=P(S), X=V(T), Y=P(T), Z=V(S); S=T=1 C. W=P(S), X=V(S), Y=P(S), Z=V(S); S=1 D. W=V(S), X=V(T), Y=P(S), Z=P(T); S=T=1
Your answer
Answer & solution
Answer: C (no official key was published)
1. The forbidden patterns mean a run of ones between zeros, or zeros between ones, must have even length. It is sufficient for each process to print its identical pair atomically. 2. C uses the same initially available semaphore at both W and Y. Only one process can enter its two-print critical section, and it releases the mutex only after the pair. 3. Output is thus a concatenation of whole 00 and 11 blocks. Adjacent blocks of the same digit may merge, but their lengths remain multiples of two, proving the desired property. 4. A and B initially allow both processes inside, permitting P's first 0, Q's first 1, P's second 0: a forbidden 010. D does not make P acquire a common mutex and likewise does not ensure whole-pair exclusion. Therefore C.
Solution: Use one common binary semaphore S, initially one, as a mutex around both print statements of either process: wait(S) at W and Y, signal(S) at X and Z. Each critical section then emits either 00 or 11 without interleaving, so any run between opposite digits is a concatenation of equal pairs and has even length. That is C. For example, when independent locks or two initially available cross-signalling permissions let P emit its first zero, Q one one, and P its second zero, the forbidden substring 010 occurs. Mutual exclusion of entire pairs is the needed property, not merely exclusion within each individual process.
Similar questions1 more → · asked again: GATE 2026 Set 2, Q23
Nonpreemptive scheduling policy
CPU Scheduling
Tap to enlarge
Which scheduling method is nonpreemptive? (A) Round robin; (B) First-in first-out; (C) Multilevel queue scheduling; (D) Multilevel queue scheduling with feedback.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Identify the event that removes the running process.
Step 2: Under FIFO, arrival of another ready process does not by itself interrupt the current one. The current process relinquishes the CPU by blocking or finishing. Round robin deliberately introduces timer preemption. A multilevel policy needs additional rules before one can decide whether it preempts, so its name is not an unconditional alternative to FIFO.
Conclusion: FIFO/FCFS lets the running job continue until it blocks or completes, so B. Round robin preempts at a time quantum. Multilevel scheduling families depend on their specified interqueue and intraqueue policies and are not, by name alone, the fixed nonpreemptive policy sought.
Which page does optimal page replacement evict? (A) The one unused for the longest past interval. (B) The one whose next use is farthest in the future. (C) The one used the fewest times. (D) The one used the most times.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Compare future reuse times.
Step 2: If resident pages will next be requested after 2,5 and 10 accesses, evict the page needed after 10. Evicting the page needed after 2 causes a miss sooner while retaining a page that is not yet useful. This exchange argument can be repeated to match an optimal schedule. The method is a theoretical benchmark because the future reference string is generally unavailable online.
Conclusion: Choose the resident page whose next use lies farthest in the future, treating no further use as infinity. Exchanging any earlier-needed victim for this one cannot increase future faults, yielding Belady’s optimal policy, B. Past recency describes LRU instead.
Why can dynamic linking raise security concerns? (A) Security is dynamic. (B) The search path for dynamic libraries is not known until runtime. (C) Linking is insecure. (D) Cryptographic procedures are unavailable for dynamic linking.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Describe the actual attack surface.
Step 2: A loader may search directories in an order influenced by environment variables, configuration or application location. If an attacker can place a library earlier in that search, the program may execute unintended code under its privileges. Restricting search paths and validating loaded libraries addresses this risk. The problem is runtime resolution policy, not an intrinsic absence of cryptographic techniques.
Conclusion: Dynamic linking may resolve library paths at runtime. If untrusted directories or mutable search-path settings influence resolution, an unintended library can be loaded. This is the security concern described by B, not a claim that every dynamic-linking configuration is insecure or that cryptography is unavailable.
Which combination suffices to characterize a multiprogrammed operating system? Features: (i) Multiple programs may be loaded into main memory simultaneously for execution; (ii) when a program waits for an event such as I/O, another is immediately scheduled; (iii) when a program terminates, another is immediately scheduled. (A) (i); (B) (i) and (ii); (C) (i) and (iii); (D) (i), (ii), and (iii).
Your answer
Answer & solution
Answer: B as the minimal defining combination (no official key was published)
Step 1: Test the weaker feature combinations.
Step 2: Multiple resident programs alone do not ensure the CPU switches away from a waiting one. Starting another program only after termination also describes a serial batch system that wastes time during I/O. Combining residency with switching on a wait supplies the distinguishing behavior. Adding termination scheduling does not logically destroy sufficiency, which is why the minimal-feature reading must be stated rather than pretending D is an impossible system.
Conclusion: Keeping multiple programs resident, (a), and switching to another ready program when one waits, (b), permit useful CPU work while I/O proceeds: the characteristic multiprogramming behavior. Thus the minimal defining combination is B. Scheduling another job after termination, (c), occurs in ordinary serial batch processing too. Literally D contains this sufficient combination as well; the usual question asks which features distinguish the model, not all logical supersets. An available ready job is implicit in the scheduling statements.
In indexed file-block allocation, on what does the maximum possible file size depend? (A) Block size and block-address size. (B) Number of index blocks and block size. (C) Block size, number of index blocks, and block-address size. (D) None of these.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Track the dimensions of the capacity calculation.
Step 2: Each index block contains floor(B/p) addresses. I such blocks contain I·floor(B/p) addresses in a flat organization, and each address identifies a B-byte data block. Multiplying gives I·floor(B/p)·B bytes. Omitting address size ignores how many pointers fit, while omitting index-block count ignores how many such pointer containers are available.
Conclusion: If I index blocks of B bytes store addresses of p bytes each, a simple flat index addresses I·floor(B/p) data blocks, giving roughly IB²/p file bytes. Thus block size, index-block count and address size all affect capacity, C. Multilevel structures alter the detailed formula, not the need to account for these quantities.
Original18(a): Draw and label the process-state transitions for an OS with states created,ready,running,blocked(sleep/wait),terminated and only non-preemptive scheduling.
Answer & solution
Answer: Created→Ready (admit); Ready→Running (dispatch); Running→Blocked (wait); Blocked→Ready (event completes); Running→Terminated (exit). (no official key was published)
Use these five labelled transitions: Created --admit--> Ready --dispatch--> Running --exit--> Terminated Running --I/O request or event wait--> Blocked Blocked --I/O or awaited event completes--> Ready The scheduler selects a ready process when the CPU becomes available. There is no timer/preemption edge from Running to Ready in the conventional non-preemptive diagram. Waking a blocked process makes it ready; it does not immediately displace the running process. A system explicitly supporting voluntary yield could add a Running→Ready edge labelled yield, but no such extra mechanism is required by the question.
Atomic TEST_AND_SET(int*x) performs A1:y=*x; A2:*x=1; A3:return y. Shared mutex initially 0. Entry/exit templates: void enter_cs(){while(blank);} void leave_cs(){blank;} Original18(b)(i): Fill the while condition in enter_cs(){while(blank);} and the statement in leave_cs(){blank;} using this instruction.
Answer & solution
Answer: enter_cs: while (TEST_AND_SET(&mutex)) { } ; leave_cs: mutex=0; (no official key was published)
Use the shared lock variable mutex, initially zero: void enter_cs(void) { while (TEST_AND_SET(&mutex)) { } } void leave_cs(void) { mutex = 0; } TEST_AND_SET atomically returns the old value and writes one. Exactly one contender observing the unlocked zero receives zero and leaves the loop; later contenders receive one and keep spinning. Releasing the lock restores zero for a future acquisition. This is pseudocode for the given atomic primitive and a shared lock, not a claim that an ordinary non-atomic C integer and a handwritten function implement modern concurrent-C synchronization. The source's hyphenated function names are rendered with underscores to make the names valid C identifiers.
Atomic TEST_AND_SET(int*x) performs A1:y=*x; A2:*x=1; A3:return y. Shared mutex initially 0. Entry/exit templates: void enter_cs(){while(blank);} void leave_cs(){blank;} Original18(b)(ii): For the resulting spinlock entry/exit solution, determine whether it is deadlock-free and starvation-free.
Answer & solution
Answer: Deadlock-free under the usual progress assumptions; not starvation-free. (no official key was published)
With atomic TEST_AND_SET, one contender acquires any free lock, and a holder that finishes its finite critical section releases the lock. Under the usual assumptions that a holder continues to receive execution time and eventually exits, the lock is deadlock-free: processes do not remain mutually blocked with no one able to proceed. It is not starvation-free, since a waiting process is not assigned a turn. Each time the lock is released another contender can acquire it first, so one process can lose indefinitely even while other processes keep making progress. As with any spinlock, a scheduler that prevents the holder from running can itself defeat progress; deadlock-freedom is not an unconditional scheduling guarantee.
Atomic TEST_AND_SET(int*x) performs A1:y=*x; A2:*x=1; A3:return y. Shared mutex initially 0. Entry/exit templates: void enter_cs(){while(blank);} void leave_cs(){blank;} Original18(b)(iii): If the three TEST_AND_SET steps were not atomic, give an interleaving violating mutual exclusion.
Answer & solution
Answer: Both processes can read mutex=0 before either sets it, so both enter. (no official key was published)
Initially mutex=0. Split TEST_AND_SET into the source steps A1: y=*x; A2: *x=1; A3: return y. Interleave two processes as follows: 1. P executes A1 and stores local yP=0. 2. Q executes A1 and stores local yQ=0. 3. P executes A2, writing mutex=1. 4. Q executes A2, also writing mutex=1. 5. P executes A3 and returns its saved zero; its while condition is false and it enters the critical section. 6. Q executes A3 and returns its saved zero; it also enters before P leaves. The final shared value one does not distinguish the two prior reads. Atomicity must cover the read and write as one indivisible operation.
Two-level address translation with equal index widths
Virtual Memory & Paging
Tap to enlarge
Virtual and physical addresses are 32 bits, byte addressed, page size 4 KB, two-level page tables with equal index widths, each entry 4 bytes. Original19(a): Draw how a virtual address translates to a physical address.
Answer & solution
Answer: Virtual address: 10-bit outer index | 10-bit inner index | 12-bit offset; physical address: 20-bit frame number | 12-bit offset. (no official key was published)
A 4 KiB page has 212 bytes, so the low 12 address bits are the unchanged page offset. The remaining 32−12=20 virtual-page bits split equally into two 10-bit indices. The translation is: VA[31:22] --index--> first-level table --second-level table base VA[21:12] --index into that table--> second-level entry --20-bit physical frame number PA = (physical frame number << 12) | VA[11:0]. More explicitly, the first entry is at first_table_base + 4·VA[31:22]; it identifies the second-level table. The second entry is at second_table_base + 4·VA[21:12]; it identifies the data page frame. Validity and protection flags are checked along the way; absent or disallowed mappings fault. The diagram describes a successful translation and does not require a TLB assumption.
Virtual and physical addresses are 32 bits, byte addressed, page size 4 KB, two-level page tables with equal index widths, each entry 4 bytes. Original19(b): How many page-table entries fit in one page?
Answer & solution
Answer: 1024 entries. (no official key was published)
Step through it (7 steps)
Each page contains 4 KiB=4096 bytes and each page-table entry occupies 4 bytes. Thus one page holds 4096/4=1024=210 entries, matching either 10-bit index. A first-level table and each populated second-level table can each occupy one page.
Virtual and physical addresses are 32 bits, byte addressed, page size 4 KB, two-level page tables with equal index widths, each entry 4 bytes. Original19(c): How many bits in each entry remain for protection/other information?
Answer & solution
Answer: 12 bits per page-table entry. (no official key was published)
Step through it (8 steps)
There are 232 addressable physical bytes and frames of 212 bytes, so a physical frame number needs 32−12=20 bits. Each page-table entry is 4 bytes=32 bits, leaving 32−20=12 bits for valid, protection, reference, dirty, or other information. The page offset is supplied by the virtual address and is not separately stored in each entry. First-level entries likewise point to page-aligned second-level tables.
Circular buffer size 100, indices first=last=0, semaphores b_full=0,b_empty=100. Producer repeats produce item; p1 blank; put into buf[first]; first=(first+1)%100; p2 blank. Consumer repeats c1 blank; take from buf[last]; last=(last+1)%100; c2 blank; consume item. Original20(a): Fill p1,p2,c1,c2 for one producer and one consumer.
Answer & solution
Answer: p1: wait(b_empty); p2: signal(b_full); c1: wait(b_full); c2: signal(b_empty). (no official key was published)
Complete the source placeholders with: p1: wait(b_empty); p2: signal(b_full); c1: wait(b_full); c2: signal(b_empty); The producer reserves an empty slot before writing buf[first] and advancing first, then announces a full slot. The consumer reserves a full slot before reading buf[last] and advancing last, then announces an empty slot. With b_empty initially BUFSIZE=100 and b_full initially zero, counting semaphores prevent overrun and underrun. Only one producer updates first and only one consumer updates last, so no additional mutex is needed for this single-producer/single-consumer algorithm under the usual atomic semaphore and memory-visibility assumptions. A semaphore count can exclude a reserved slot temporarily while its operation is in progress; b_empty+b_full need not equal BUFSIZE at every instruction boundary.
Mutex additions for multiple producers and consumers
Synchronization & Concurrency
Tap to enlarge
Circular buffer size 100, indices first=last=0, semaphores b_full=0,b_empty=100. Producer repeats produce item; p1 blank; put into buf[first]; first=(first+1)%100; p2 blank. Consumer repeats c1 blank; take from buf[last]; last=(last+1)%100; c2 blank; consume item. Original20(b): Introduce one additional semaphore and one statement at each location: immediately after p1, before p2, after c1, before c2 so the program supports multiple producers/consumers.
Answer & solution
Answer: Initialize semaphore mutex=1; after p1 and c1 insert wait(mutex); before p2 and c2 insert signal(mutex). (no official key was published)
Add a binary semaphore mutex initialized to one. Insert wait(mutex) immediately after p1 and immediately after c1, and signal(mutex) immediately before p2 and immediately before c2. The resulting operation order is: Producer: wait(b_empty); wait(mutex); write buf[first]; advance first; signal(mutex); signal(b_full). Consumer: wait(b_full); wait(mutex); read buf[last]; advance last; signal(mutex); signal(b_empty). This serializes updates to the shared buffer and indices across all producers and consumers. Slot availability is awaited before taking the mutex. Reversing that order can deadlock, for example a consumer holding the mutex while waiting for an item prevents a producer from inserting one. Producing and consuming the actual item stay outside the mutex-protected buffer operations.
Which virtual-memory claim is false? It translates program addresses to physical addresses; allows a program larger than primary memory; increases possible multiprogramming; or reduces context-switch overhead.
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Virtual memory translates virtual addresses, permits only part of a program to be resident, and can accommodate more simultaneously active processes than whole-program residency allows. These explain the usual claims A–C.
Step 2: A context switch still saves/restores CPU state and may change page-table context or invalidate/repopulate translation caches. Virtual memory does not inherently remove that work and can add translation-related overhead.
Thus D is the false general claim. The benefit in multiprogramming is a capability, not a guarantee against thrashing under every workload.
What is the principal system purpose of a software interrupt: testing interrupts, implementing coroutines, requesting system services needing privileged instructions, or returning from a subroutine?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: User-mode code cannot directly execute protected operations such as arbitrary device control. It must transfer control through an authorized entry point into the operating system.
Step 2: A software interrupt/trap provides that controlled transfer and lets the kernel execute the privileged instructions, so C. A normal subroutine return is not this transition, and coroutines can switch cooperatively without requiring a privileged trap. Testing interrupts is possible but is not their essential system-service purpose.
Given n tasks with known runtimes r1,…,rn on one processor, which policy maximizes throughput: round robin, shortest-job-first, highest-response-ratio-next, or FCFS? Explain the throughput interpretation needed.
Your answer
Answer & solution
Answer: B under the finite-horizon completion interpretation (no official key was published)
Step 1: If all jobs are ready and their runtimes are known, the k shortest jobs have the minimum possible total runtime among all k-job subsets. Executing them first therefore completes as many jobs as possible by each time horizon, under zero overhead and no blocking. This favors SJF, B.
Step 2: However, if throughput means the entire fixed batch’s n completions divided by its total processing time, every work-conserving order gives n/(r1+…+rn). Under that definition no unique scheduler maximizes it.
The answer therefore needs the finite-horizon or average-completion interpretation; it must not claim SJF reduces the sum of all CPU bursts.
Where does conventional swap space reside: RAM, disk, ROM, or on-chip cache?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Swapping moves memory contents out of RAM so that physical frames become available for other uses. The displaced contents must survive while those RAM frames are reused.
Step 2: Conventional swap space is reserved secondary-storage space, typically a disk partition or file, so B. ROM is not a normal writable swap target; CPU cache and RAM do not provide the intended backing store. This historical answer includes modern disk-like secondary storage such as SSDs.
With FIFO page replacement, what can increasing the number of frames do for an arbitrary reference string: always decrease faults, always increase faults, sometimes increase faults, or never change faults?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: FIFO evicts the page loaded earliest, without maintaining the stack-inclusion property of LRU. Adding frames can change future FIFO victim order.
Step 2: For reference string 1,2,3,4,1,2,5,1,2,3,4,5 from empty memory, FIFO incurs 9 faults with 3 frames but 10 with 4. This is Belady’s anomaly. Other strings can benefit or show no change.
Therefore additional frames can sometimes increase faults, C; neither a universal decrease nor universal increase is valid.
Which component normally requires a device driver: a CPU register, cache, main memory, or disk?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: A device driver translates OS requests into device-controller operations, handles completion/error reporting, and coordinates the peripheral’s interface. A disk has such an interface and requires a storage driver.
Step 2: CPU registers and ordinary cache are accessed or managed by processor mechanisms, while normal main-memory access is part of the memory architecture rather than a disk-style peripheral protocol.
Thus D is the intended distinction. Memory management software exists, but that does not make it the device driver meant in this question.
Which is not itself an interrupt source for a running process: a device, a timer, the scheduler process, or a detectable power failure?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Devices and timers can raise hardware interrupts; some systems also signal impending power failure through an interrupt or exception mechanism. These events transfer control away from a running process.
Step 2: A scheduler is software invoked after the kernel receives control, for example following a timer interrupt, blocking operation, or termination. It chooses the next runnable process but is not itself the independent hardware interrupt source.
Thus C in the conventional uniprocessor model. A complete abrupt loss of power may stop execution without a graceful interrupt, so the power-failure option presumes a detectable failure signal.
A machine has 64 MiB physical memory, 32-bit virtual addresses, and 4 KiB pages. Estimate a flat page-table size from choices 16,8,2,24 MiB, and state the necessary page-entry-size assumption.
Your answer
Answer & solution
Answer: C under a two-byte-entry assumption (no official key was published)
Step 1: A 4 KiB page has 12 offset bits. A 32-bit virtual address therefore has 20 virtual-page bits, requiring 220 entries in a full single-level page table.
Step 2: Physical memory 64 MiB=226 bytes contains 214 frames, so a physical frame number needs 14 bits. Rounding that field to two bytes gives 220·2=2 MiB, option C, with only limited room for additional status bits.
Qualification: The entry size and organization are not specified. Four-byte entries would require 4 MiB, not listed; multilevel allocation can use a different amount. Therefore 2 MiB is a conventional estimate, not uniquely determined by the stated capacities alone.
In Peterson’s entry code for process i: set flag[i]=true; turn=j; while(P) wait; enter critical section; then clear flag[i]. Choose P: flag[j] AND turn=i; flag[j] AND turn=j; flag[i] AND turn=j; flag[i] AND turn=i. Distinguish progress from safety alone.
Your answer
Answer & solution
Answer: B for Peterson mutual exclusion with progress (no official key was published)
Step 1: Process i announces intent with flag[i]=true and sets turn=j, yielding priority to j. It should wait only while j also wants entry and j has priority: flag[j] AND turn=j, option B.
Step 2: If both flags are true, the last write to turn selects one waiting process and lets the other enter. If j leaves, it clears flag[j], immediately releasing i’s wait regardless of turn. Atomic reads/writes and sequentially consistent ordering are assumed.
Qualification: The literal question mentions only mutual exclusion. Option C, testing its own flag with turn=j, can preserve exclusion while blocking a lone entrant forever. It is not Peterson’s correct solution because progress fails. B is the predicate satisfying the intended full critical-section requirements.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Answer & solution
Answer: Yes: with one-shot execution and atomic reads and writes, the opposite acquisition order prevents overlapping use (no official key was published)
Program, assume each individual flag read or write is atomic, but test-and-set is not, and each process executes its printed sequence once. Mutual exclusion of the actual use intervals S5 and Q5 is nevertheless guaranteed. Suppose the intervals overlapped. Neither process could yet have released a resource. P2 must therefore have passed its R1 test Q3 before P1 sets R1 at S2, giving Q3<S2. Similarly P1 must pass its R2 test S3 before P2 sets R2 at Q2, giving S3<Q2. Program order imposes S2<S3 and Q2<Q3. Combining yields the impossible strict cycle S2<S3<Q2<Q3<S2. Hence an overlapping execution is impossible. Separate tests and sets alone are not enough to prove a race in this particular opposite-order program.
The only possible intervening freeing operation is P1’s S6, which follows completion of S5. Therefore P2 cannot reach Q5 before P1 finishes its use. This is poor progress behavior, not an overlapping-use counterexample. These conclusions concern the printed one-shot programs; an unspecified outer repetition loop or non-atomic/memory-reordered implementation is a different model.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Answer & solution
Answer: Yes: S1, S2, Q1, Q2, then P1 waits at S3 and P2 waits at Q3 (no official key was published)
Initially both flags are free. Let P1 pass S1 and execute S2, so R1 becomes busy. Let P2 pass Q1 and execute Q2, so R2 becomes busy. P1 now spins in S3 waiting for R2; P2 spins in Q3 waiting for R1. Neither can reach its use or release operations. The wait-for graph is P1→P2→P1: each holds its first resource while waiting for the other.
P2 then spins at Q3 on R1, the flag it set itself. P1 spins at S1 on R1. No process can reach a release. This is a self-wait plus a blocked competitor, rather than the intended two-resource circular wait.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation. Exchange Q1 with Q3 and Q2 with Q4.
Answer & solution
Answer: Mutual exclusion fails after reordering, but there is no resource deadlock (no official key was published)
After swapping the the paper operations, both processes check/set R1 and then check/set R2. Name the new P2 order Q1′=test R1, Q2′=set R1, Q3′=test R2, Q4′=set R2, followed by use and the original releases. A violating interleaving is S1,Q1′,S2,Q2′,S3,Q3′,S4,Q4′, followed by overlapping S5 and Q5. Both tests of each free flag precede either write to that flag, so both reach their use intervals. This shows why a real atomic lock operation is required.
There is no resource deadlock in the reordered the paper protocol: a process waiting on R2 has already passed the R1 test. Any competing process that made R2 busy has also passed both tests and can finish and release; it cannot be waiting to acquire R1 afterward. This excludes a circular resource wait, assuming a runnable process eventually runs. It does not promise fairness or fix mutual exclusion.
Its one-shot nonoverlap and self-wait deadlock from parts (a),(b) remain.
Disk has tracks 0–99, rotates at 3000 rpm, has 100 sectors per track and takes 0.2 ms to move one track. Requests are tracks 32,7,45,5,10; head starts at 25 moving upward.
Answer & solution
Answer: SCAN: 33.6 ms; LOOK interpretation: 12 ms. (no official key was published)
Under strict SCAN, continue toward the physical end 99 before reversing. Requests are served in order 32,45,10,7,5, with traversal 25→32→45→99→10→7→5. Distance is (99−25)+(99−5)=74+94=168 tracks. Multiply by 0.2 ms/track to get 33.6 ms. Stop measuring once the final request at 5 is served; there is no need to continue to 0.
Some textbooks use “elevator” for LOOK, which reverses at the last pending request, 45, rather than at track 99. That traversal covers (45−25)+(45−5)=20+40=60 tracks, giving 12 ms. The source does not explicitly distinguish these conventions, so both are reported with their policies. Rotation rate and sector count do not enter a seek-time-only answer.
Disk has tracks 0–99, rotates at 3000 rpm, has 100 sectors per track and takes 0.2 ms to move one track. Initially 100 arbitrary requests, no new arrivals, head starts at track 0; determine worst-case completion time under elevator scheduling.
Answer & solution
Answer: Seek-only maximum 19.8 ms. Under a conventional one-sector/request bound, total ≤2039.8 ms (see assumptions). (no official key was published)
Starting at the lowest track, all requests can be served in one upward sweep. The maximum head travel is 99 tracks, so seek time is at most 99×0.2=19.8 ms, attained if a request is at track 99. A revolution takes 60/3000 seconds=20 ms, and a single sector transfer takes 20/100=0.2 ms.
If each request reads one sector and one charges a separate worst-case rotational wait of up to one full revolution to every request, an additive bound is 19.8+100×(20+0.2)=2039.8 ms. A uniform-random-phase average latency would be 10 ms, yielding a different, average-model value 1039.8 ms; it is not a worst-case answer. If a convention counts a complete revolution as covering both wait and the requested sector transfer, the bound is instead 19.8+100×20=2019.8 ms.
The printed request description does not specify bytes/sectors per request, sector ordering at one track, or a rotational-latency convention. Therefore it does not determine a unique exact total completion time. The 19.8 ms seek bound is unambiguous; any fuller time must state its service assumptions. Independent per-request latency maxima are a conservative additive bound, not a proof that a single finite queue attains every maximum simultaneously.
Which need not necessarily be saved: general-purpose registers, the TLB, the program counter, or all of these?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: The process’s program counter and live architectural registers determine where and how it resumes; their values must be preserved by the switching mechanism.
Step 2: A TLB is a cache of translations also represented in page tables. It may be invalidated and refilled, or entries may remain with address-space identifiers, without saving its entire contents in the process context.
Therefore B. Losing cached translations can hurt performance but does not inherently lose the process’s architectural execution state.
Processes P[0]…P[4] use mutexes m[0]…m[4]. Each waits on m[i], then m[(i+1) mod4], before releasing them. Can this cause thrashing, deadlock, starvation without deadlock, or none?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Schedule P0,P1,P2,P3 so each acquires its first mutex before any attempts the second. They now hold m0,m1,m2,m3 respectively.
Step 2: P0 waits for m1, P1 for m2, P2 for m3, and P3 for m0. Each resource is held by the next blocked process, creating a circular wait.
Thus deadlock is possible, B. The printed modulus is 4 even though five processes/mutexes are named; the four-process cycle already proves the result without silently changing it to 5. P4 does not remove this cycle.
Memory access takes 1 μs, average page-fault service 10 ms, and hit ratio is 99.99%. Choose effective time from 1.9999 ms,1 ms,9.999 μs,1.9999 μs.
Your answer
Answer & solution
Answer: D under the inclusive fault-service convention (no official key was published)
Step 1: Convert 10 ms to 10,000 μs and use fault probability 1−0.9999=0.0001.
Step 2: If the fault-case time is the stated total service, expected time is 0.9999·1+0.0001·10,000=0.9999+1=1.9999 μs, D.
If “service” excludes the final retried access, add another 0.0001 μs to obtain 2 μs. This tiny convention difference is explicit; neither interpretation gives a millisecond-scale average.
Which is not a valid general prevention policy: release all before requesting a new resource; request only in increasing resource-number order; never request after releasing any resource; acquire all required resources before execution?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Releasing all held resources before a new request removes hold-and-wait. A global increasing order removes circular wait. Atomic acquisition of the full required set before running also avoids partial hold-and-wait.
Step 2: Merely forbidding requests after the first release does not prevent deadlock during the initial acquisition phase. Process P can hold A and request B while Q holds B and requests A; neither has released anything, so both obey that rule.
Thus C is insufficient. The prevention interpretation presumes the usual nonreentrant-resource model and an all-or-nothing initial acquisition policy in the last option.
R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. Fill boxes 1,2,3.
Answer & solution
Answer: (1) signal(mutex); (2) signal(mutex); (3) R>0 || W!=0. (no official key was published)
The complete intended protocol is:
Reader() {
L1: wait(mutex);
if (W == 0) {
R = R + 1;
signal(mutex); // box 1
} else {
signal(mutex); // box 2
goto L1;
}
/* read shared data */
wait(mutex);
R = R - 1;
signal(mutex);
}
Writer() {
L2: wait(mutex);
if (R > 0 || W != 0) { // box 3
signal(mutex);
goto L2;
}
W = 1;
signal(mutex);
/* write shared data */
wait(mutex);
W = 0;
signal(mutex);
}
wait/signal must implement a genuine atomic binary semaphore with appropriate memory visibility. Merely reading and writing an ordinary flag is not a substitute. All tests and updates of R,W occur under mutex, so checking admission and registering the admitted reader/writer are atomic relative to competitors. A writer enters only when no reader and no writer is active, and W=1 prevents later admissions until it finishes. Multiple readers are allowed while W=0. Both reader branches must release mutex; retaining it would block exits or retries and can deadlock. The mutex protects admission bookkeeping, not the whole read/write operation; R and W reserve access while mutex is released. Safety holds, but fairness is not guaranteed.
R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. With correct boxes, can writers starve?
Answer & solution
Answer: Yes. Waiting writers do not prevent new readers from entering. (no official key was published)
Consider two streams of readers whose reading intervals overlap. Before the last current reader exits, a new reader acquires mutex, observes W=0, increments R and begins reading. Arrange this repeatedly so R never becomes 0. A waiting writer may acquire mutex infinitely often, but each time it finds R>0, releases mutex and retries. It therefore never reaches W=1, even though every individual read finishes. A pending writer is not recorded anywhere: W means an active writer, not a waiting writer. Consequently new readers remain admissible throughout this schedule. This is starvation, not deadlock, since readers keep making progress. Even fairness in acquiring the bookkeeping semaphore would not repair this example because the writer gets turns and still cannot enter. Avoiding it requires a different admission policy, for example recording waiting writers and refusing new readers while a writer waits, together with suitable queue fairness; that change is outside the requested three boxes.
Match thread, virtual address space, file system and signal to CPU, memory, disk and interrupt respectively; option C gives 3,2,4,1.
Your answer
Answer & solution
Answer: C (no official key was published)
A thread is an execution context scheduled on a CPU. A virtual address space is the process-facing abstraction of memory. A file system organizes persistent disk storage into named files and directories. A signal is a software notification analogous to an interrupt in its asynchronous transfer of control. Thus the mapping is thread→3, virtual address space→2, file system→4, signal→1, giving C. This matches abstractions rather than asserting that signals and hardware interrupts are identical.
Which is likely to provide best throughput: farthest cylinder next, nearest cylinder next, FCFS, or elevator?
Your answer
Answer & solution
Answer: B under the usual seek-dominated comparison (no official key was published)
Nearest-cylinder-next, or SSTF, chooses the pending request needing the least immediate head movement. Shorter seeks usually reduce service time and allow more requests per unit time, motivating B. FCFS ignores position; farthest-next deliberately increases movement. Elevator scheduling trades some local seek economy for orderly service and better fairness. The question says likely, not universally optimal: arrivals, rotational latency and starvation can change observed performance, so this is a conventional workload judgment rather than a theorem for every request sequence.
Which hardware feature is essential in the standard native protected-OS model: address translation,DMA,two privilege modes,demand paging?
Select all that apply
Answer & solution
Answer: C under the protected native-execution model (no official key was published)
User code must be prevented from directly changing privileged OS state, while kernel code must be allowed to do so. Distinct privileged and unprivileged execution modes provide this boundary, motivating C. DMA is an optimization over programmed transfers; demand paging is optional; and full address translation is not the only conceivable protection mechanism. The literal word cannot is broader than the textbook model: trusted programs or an interpreter can implement multiuser services without native privilege modes. Thus the result concerns untrusted applications executing natively with hardware-enforced protection.
Select advantages: A faster average accesses,B protected address spaces,C linker addresses independent of physical loading,D programs larger than RAM.
Select all that apply
Answer & solution
Answer: B,C,D (no official key was published)
Translation associates each process’s virtual addresses with controlled physical mappings, enabling separate protected spaces: B. Link-time virtual addresses need not equal final physical frame addresses, enabling C. Keeping only a working set resident while backing other pages on storage permits an address space larger than RAM: D. Translation and page faults add overhead rather than intrinsically speeding memory access, so A is not a general advantage. Protection permissions and backing-store support are the conventional virtual-memory system assumptions.
Which is typically NOT performed when switching A to B: save/restore registers,change translation tables,swap A’s entire memory image to disk,invalidate TLB?
Select all that apply
Answer & solution
Answer: C (no official key was published)
A context switch preserves A’s architectural state and restores B’s registers. It also selects B’s address-translation context. In a conventional untagged TLB, old translations must be invalidated to avoid interpreting B’s addresses through A’s mappings. None of this requires writing all of A’s memory to disk: both processes can remain resident. Therefore C is the operation not normally required. Tagged TLBs may avoid full invalidation, but that architectural optimization is distinct from whole-process swapping and does not turn every switch into a disk transfer.
A byte-addressed segmented-paging system has 2^16 bytes in each of its virtual and physical address spaces, divided into 8 equal virtual segments. The hardware segment table points to each segment’s page table in main memory. Each page-table entry is 2 bytes. GateForum visibly prints 2^16; GFG loses exponent formatting and appears as 216. Find the smallest power-of-two page size for which one segment’s page table occupies at most one page.
Answer & solution
Answer: 128 bytes (no official key was published)
The eight segments need 3 segment-number bits, leaving 13 bits of segment offset. Each segment therefore contains 216/8=213=8192 bytes. If page size is P=2p bytes, the segment contains 8192/P pages and needs that many page-table entries. At 2 bytes each, its table occupies 16384/P bytes. The one-page requirement is 16384/P≤P, or P²≥16384=214. Thus p≥7 and the smallest allowed power of two is P=128. Verification: 8192/128=64 entries occupy 128 bytes exactly. The preceding power of two, 64 bytes, would need 128 entries or 256 bytes, exceeding one page. The hardware segment table does not add to the per-segment page-table storage being bounded.
A byte-addressed segmented-paging system has 2^16 bytes in each of its virtual and physical address spaces, divided into 8 equal virtual segments. The hardware segment table points to each segment’s page table in main memory. Each page-table entry is 2 bytes. GateForum visibly prints 2^16; GFG loses exponent formatting and appears as 216. With 512-byte pages, a direct-mapped TLB holds 16 virtual-page translations. How many tag bits per entry are needed?
Answer & solution
Answer: 3 tag bits (no official key was published)
A 512-byte page has 9 offset bits. Therefore the full 16-bit virtual address has 7 virtual-page-number bits. A 16-entry direct-mapped TLB uses 4 of those bits as its index, leaving 7−4=3 tag bits. In this segmented layout the address can be drawn as [segment:3 | page within segment:4 | byte offset:9]. Indexing by the low 4 virtual-page bits chooses the page number within a segment; the stored 3-bit segment tag distinguishes the eight segments that map to that same TLB slot. Page offset bits neither select a translation nor belong in its tag. This is the tag for the single address space described; unmentioned address-space identifiers or additional implementation status are not included.
A byte-addressed segmented-paging system has 2^16 bytes in each of its virtual and physical address spaces, divided into 8 equal virtual segments. The hardware segment table points to each segment’s page table in main memory. Each page-table entry is 2 bytes. GateForum visibly prints 2^16; GFG loses exponent formatting and appears as 216. With 512-byte pages, each entry has 1 valid bit, 3 protection bits and 1 dirty bit. How many bits remain for aging information?
Answer & solution
Answer: 4 aging bits (no official key was published)
There are 216/29=27 physical page frames, so a page-table entry needs 7 bits for the physical frame number. The offset is supplied by the original virtual address and is not stored in the entry. Each entry is 2 bytes=16 bits. The stated non-address metadata occupies 1+3+1=5 bits. Thus the aging budget is 16−7−5=4 bits. A valid field allocation is [frame number:7 | valid:1 | protection:3 | dirty:1 | aging:4], totaling 16. Subtracting a full 16-bit physical byte address would be wrong because a page frame is aligned and its low 9 offset bits need not be recorded. This answer assumes no additional unspecified fields consume the remaining capacity.
TSET register,flag atomically copies flag into register and sets flag=1. Give entry and exit pseudocode for a critical region.
Answer & solution
Answer: Spin until TSET returns 0; release by setting flag to 0. (no official key was published)
Initialize a shared flag to 0 before any competing process starts. Each process uses its own register r.
shared flag := 0
entry:
repeat
TSET r, flag
until r = 0
critical_region()
exit:
flag := 0
TSET must run on every retry; reading a stale r in a spin loop would never acquire the lock. When flag=0, exactly one atomic TSET can observe that 0 and simultaneously change flag to 1. That process enters; all later tests obtain 1 and continue waiting. Only the owner clears the flag on exit. This establishes mutual exclusion, assuming atomic release stores and the abstract sequentially consistent memory model of the question. Real machines additionally require appropriate acquire/release memory ordering. The scheme busy-waits and does not by itself guarantee bounded waiting or freedom from starvation.
A one-slot producer-consumer buffer uses count=0 initially. Tests and assignments of count are individually atomic. Producer repeats: produce item; if count=1 then sleep; put item in buffer; count:=1; wakeup(Consumer). Consumer repeats: if count=0 then sleep; remove item; count:=0; wakeup(Producer); consume item. Show an execution where both processes sleep.
Answer & solution
Answer: A wakeup between the consumer’s test and sleep is lost; producer later sleeps on the full buffer. (no official key was published)
Assume ordinary sleep/wakeup semantics: waking a process not currently asleep does not save a future wakeup token. The following interleaving is legal even though each test and assignment is atomic. 1. Consumer tests count=0 and gets true, but is preempted just before executing sleep. 2. Producer produces an item, tests count=1 (false), places the item, then atomically sets count=1. 3. Producer calls wakeup(Consumer). Consumer is not sleeping yet, so the notification is lost. 4. Consumer resumes at the pending sleep instruction and goes to sleep, without rechecking count. The buffer is full and count remains 1. 5. Producer begins its next iteration and produces another item. Its count=1 test is true, so it sleeps waiting for space. Now both processes are asleep. Only the sleeping consumer could remove the buffered item and wake the producer; only the sleeping producer could issue another consumer wakeup. Individual atomicity of test and assignment does not make the combined test-and-sleep sequence atomic. A semaphore that retains notifications, or correctly synchronized condition-variable wait with a predicate loop, prevents this lost-wakeup window.
Similar questions1 more → · asked again: GATE 1993, Q7.7
Resident loading support
Processes, Threads & System Calls
Tap to enlarge
In a resident-OS model, which software must remain available in main memory: assembler, linker, loader, compiler?
Your answer
Answer & solution
Answer: C in the traditional resident-loader model (no official key was published)
A loader brings executable code into memory and prepares it for execution. In the traditional resident monitor model, this loading support must remain available to bring in subsequent programs, motivating C. Assemblers, linkers and compilers can be ordinary separately loaded programs and need not be continuously resident. The universal wording is model-dependent: modern systems can page portions of loading software or use firmware and other mechanisms. The answer identifies the conventional resident component, not a theorem about all possible OS designs.
Similar questions2 more → · asked again: GATE 1992, Q2(xii)
A spooled device
I/O & Disk Scheduling
Tap to enlarge
Which is a spooled device: interactive input terminal, printer serving multiple jobs, virtual-memory backing storage, or swap area?
Your answer
Answer & solution
Answer: B (no official key was published)
Spooling first records output in a queue, usually on disk, and a service process feeds one job at a time to a device. A printer shared by many jobs is the standard example, B: jobs can finish producing output without holding the printer throughout. Paging and swapping also use disk, but their purpose is memory management rather than queued job output. Interactive terminal input is not the listed spooling example.
What is a computation whose result depends on relative process speeds called: cycle stealing, race condition, time lock, deadlock?
Your answer
Answer & solution
Answer: B (no official key was published)
A race condition occurs when competing execution orders affect the result of shared operations. For example, two processes that each read, increment and write a counter may overwrite one another’s update depending on timing. Synchronization is needed when the intended result must not depend on such an interleaving. This is B. Deadlock instead means processes cannot make progress, while cycle stealing describes bus access by a device.
Similar questions1 more → · asked again: GATE 1992, Q2(x)
Net semaphore updates
Synchronization & Concurrency
Tap to enlarge
A counting semaphore starts at 10. Six completed P(wait) and four completed V(signal) operations occur. Find the final value among 0, 8, 10, 12.
Your answer
Answer & solution
Answer: B: 8 (no official key was published)
Each completed wait consumes one available unit, decreasing the count by 1. Each signal adds one unit. Thus the net change is−6+4=−2, and the final count is 10−2=8. Because all six waits are stated to complete and the initial count is sufficient even before signals, no blocking ambiguity affects this arithmetic. Hence B; counting only the signals would incorrectly increase the initial value.
Similar questions7 more → · asked again: GATE 1992, Q2(xi)
Deadlock-free tape-drive bound
Deadlocks
Tap to enlarge
Six identical tape drives are shared by n processes, each needing at most two. Find the largest n guaranteeing no resource deadlock among 6, 5, 4, 3.
Your answer
Answer & solution
Answer: B: 5 under unrestricted incremental allocation (no official key was published)
The dangerous state gives each process one drive while it waits for a second. With n≤5, at least one of six drives remains free, so some waiting process can receive its second, finish and release both; repeat to complete others. With n=6, all six can hold one and wait forever for a second, producing deadlock. Therefore the largest guaranteed-safe n is 5, B. This is a worst-case allocation guarantee, assuming eventual release and no other resources; an avoidance policy could safely serialize more processes.
Overlay tree: root 2 KB; children A 4, B6, C8; A has D6, E8; B has F2; C has G4. Minimum partition size among 12, 14, 10, 8 KB?
Your answer
Answer & solution
Answer: B: 14 KB (no official key was published)
Only one sibling overlay branch needs to coexist at a time, but a descendant must coexist with its ancestors. Compute root-to-leaf sums: root-A-D=2+4+6=12; root-A-E=2+4+8=14; root-B-F=2+6+2=10; root-C-G=2+8+4=14 KB. The largest is 14 KB, so B. Summing every module would ignore overlay sharing; allocating only the largest individual module would omit resident ancestors. Module sizes were cross-checked in the clearer alternate diagram.
n processes share CPU; switches cost s seconds and quantum is q. Minimize overhead while each process gets a turn at least every t seconds. Options use q≤or≥(t−ns)/(n−1) or denominators n+1.
Your answer
Answer & solution
Answer: A for maximum off-CPU waiting; start-to-start wording differs (no official key was published)
After a process’s quantum ends, n−1 other quanta occur before it runs again. Including the n intervening switches gives waiting time (n−1)q+ns. Requiring this≤t yields q≤(t−ns)/(n−1), A, for n>1 and feasible t>ns. Switching overhead fraction decreases as q grows, so choose equality to minimize it within that constraint. If “every t seconds” instead measures successive start times, the interval includes the process’s own quantum: n (q+s)≤t, giving q≤t/n−s. The listed answer assumes off-CPU waiting, not literal start-to-start spacing.
An instruction takes i microseconds; one page fault per k instructions adds j microseconds. Find effective instruction time.
Your answer
Answer & solution
Answer: A: i+j/k (no official key was published)
Over k instructions, ordinary execution costs ki microseconds. The average one fault adds j, so the total for that block is ki+j. Divide by k to obtain i+j/k per instruction, option A. The word additional matters: the base instruction cost is already counted and must not be divided away or counted twice. This is an average-cost calculation and does not require faults to occur at perfectly periodic positions.
Fixed partition sizes are 4,8,20,2 KB. Jobs in order have (size KB, execution time): (2,4),(14,10),(3,2),(6,1),(6,4),(10,1),(20,8),(2,6). With best-fit allocation, when does the 20 KB job finish?
Answer & solution
Answer: At time 19 under listed-order, nonpreemptive fixed-partition scheduling. (no official key was published)
Assume all jobs are available at time 0, listed order resolves admission priority, partitions are fixed and not split, runtimes are elapsed times while resident, and loading/switching costs are zero. Best fit places an admitted job in the smallest currently free partition that accommodates it. Call the listed jobs J1 through J8.
At time 0, J1 occupies 2 KB until t=4, J2 occupies 20 KB until t=10, J3 occupies 4 KB until t=2, and J4 occupies 8 KB until t=1. J5, J6 and J7 cannot yet fit. At t=1, J4 finishes and J5 enters the 8 KB partition for four units, finishing at t=5.
The critical resource is the 20 KB partition. J6 needs 10 KB, so it cannot use the 4,8 or 2 KB partitions. J7 needs the entire 20 KB partition. At t=10, J2 releases it. Listed-order priority admits J6 first for one unit, t=10 to 11. Then J7 runs for eight units, t=11 to 19. Thus the requested completion time is 10+1+8=19.
J8 may enter a smaller partition earlier if the allocator bypasses blocked jobs, or later under strict head-of-line waiting; this does not change the listed-order use of the 20 KB partition. Best fit alone specifies a partition choice, not a scheduling discipline or arrival times. If arbitrary priority allowed J7 ahead of J6 at t=10, it would finish at 18. Therefore 19 is the conventional answer with the stated order assumptions, not a consequence of the phrase “best fit” alone.
Read 35 sectors on a soft-sectored, two-sided floppy, 8 sectors/track, 8 ms track step, 300 rpm, starting sector 3 of track 10 with head initially on track 10. Controller has one-sector buffer. Find total time.
Answer & solution
Answer: 875 ms transfer time; a unique total needs rotational phase, layout/skew and servicing assumptions. (no official key was published)
One revolution takes 60/300=0.2 s=200 ms, so a sector takes 200/8=25 ms. Reading the 35 payload sectors therefore needs 35×25=875 ms of on-media transfer. Starting at sector 3, the track portions contain 6,8,8,8,5 sectors, so five surface-tracks are visited and four surface-track boundaries crossed.
A two-sided disk does not necessarily seek at all four boundaries. With cylinder-major allocation starting on side 0, the order is cylinder 10 side 0, cylinder 10 side 1, cylinder 11 side 0, cylinder 11 side 1, cylinder 12 side 0. Ignoring head-switch time, this requires two radial steps, totaling 16 ms. A simplified additive estimate with no initial or boundary rotational waiting is then 891 ms. If 'track' instead means successive tracks of one surface requiring four steps, the corresponding estimate is 907 ms.
Neither estimate is an unconditional exact answer. The initial angular position is not specified. Without track skew, an 8 ms seek after sector 8 can miss the start of sector 1, requiring a wait for its next revolution. Under the cylinder-major example, zero initial wait, aligned sector numbering and instantaneous head switches, each of the two step boundaries costs an entire 200 ms including seek plus rotational wait, giving 875+400=1275 ms. A suitably skewed layout changes that boundary cost.
Finally, a one-sector buffer does not specify how quickly the host drains it. Missing the next sector while transferring a buffer can add whole rotations. A defensible expression is 875 ms + initial rotational wait + radial-step time + head-switch time + boundary/buffer waiting. The supplied facts fix only some terms, so report assumptions rather than invent an exact total.
Four jobs with expected run times 6,3,5,x are waiting. In what order should they run to minimize average response time?
Answer & solution
Answer: Shortest expected processing time first, subject to standard all-arrived nonpreemptive assumptions. (no official key was published)
Assume one processor, all four jobs ready at time zero, no scheduling overhead, and response interpreted as time to completion (or waiting time to first execution under nonpreemptive execution). Consider adjacent jobs of lengths a>b starting at time t. Their completion-time sum in order a,b is (t+a)+(t+a+b)=2t+2a+b. Reversing them gives 2t+2b+a, smaller by a−b. Other jobs' completion times do not change, because the pair's total length is unchanged. Repeatedly removing inversions proves ascending processing time is optimal.
Thus for x≥0: if x≤3, use x,3,5,6; if 3≤x≤5, use 3,x,5,6; if 5≤x≤6, use 3,5,x,6; if x≥6, use 3,5,6,x. Ties can be broken either way. For random run times the same exchange proof minimizes expected mean completion using their expected durations, when the decision is a fixed order and those expectations are known.
The answer is not a universal interactive-response policy: different release times, preemption or defining response as first service with arbitrarily small time slices changes the optimization problem. These are not specified, so the conventional nonpreemptive model is stated.
Represent the graph with edges S1→S2,S1→S3,S1→S4,S1→S5,S2→S4,S4→S5,S3→S5 using parbegin/parend.
Answer & solution
Answer: S1; parbegin {S2;S4} || {S3} parend; S5. (no official key was published)
S1 must finish first. Afterward S3 can run independently of the chain S2 then S4. S5 must wait for both branches. A structured program is:
begin
S1;
parbegin
begin
S2;
S4;
end
S3;
parend;
S5;
end
Here parbegin starts its two child statements concurrently, and parend joins them. The first child is a sequential block, so S2 precedes S4. The second child is S3. The final join guarantees both S3 and S4 finish before S5. Edges S1→S4 and S1→S5 are already implied by the paths through S2/S4, but are still satisfied. There is no imposed order between S3 and S2 or between S3 and S4, so the program preserves the graph's available parallelism rather than unnecessarily serializing it.
Disk addresses take d bits; a disk has B blocks, F free. When does a free list occupy less storage than a bitmap?
Answer & solution
Answer: Fd<B in the conventional address-list accounting. (no official key was published)
A bitmap uses one bit for every disk block, allocated or free, so its size is B bits. An explicit list storing one d-bit address per free block uses Fd bits. Thus the list is smaller precisely when Fd<B, or F/B<1/d. Equality is a tie, not a reduction. For example d=32 means the list wins below a free-block fraction of 1/32 under this model.
This compares payload metadata. An additional list-head pointer, count or alignment changes the inequality by the corresponding overhead, for example (F+1)d<B if one extra d-bit head is counted only for the list. A linked free list may store next pointers inside otherwise free blocks; in that implementation physical placement and reserved-memory costs differ from an external address array. The simple condition requested assumes the conventional one-address-per-free-block versus one-bit-per-total-block accounting.
A disk has C cylinders,t tracks/cylinder,s sectors/track, sector length sl. A contiguous file begins at (cL,tL,sL), with record length rl=sl. Derive cylinder,track,sector of logical record n.
Answer & solution
Answer: For zero-based disk coordinates and one-based n, j=((cL*t+tL)*s+sL)+(n−1); decode j by division. (no official key was published)
Assume disk coordinates cL,tL,sL are zero-based, records are numbered from 1, and the file starts at a sector boundary. Since each record equals one sector, record n is n−1 sectors beyond the initial address. Linearize the starting location as j0=(cL*t+tL)*s+sL and set j=j0+n−1.
Then cylinder=floor(j/(t*s)); within-cylinder remainder r=j mod(t*s); track=floor(r/s); sector=r mod s. These divisions automatically carry across track and cylinder boundaries. For n=1, quotient/remainder reconstruction returns exactly the starting triple. Crossing a sector boundary from s−1 adds one track; crossing track t−1 adds one cylinder.
Require 0≤j<C*t*s so the record fits on the disk. If sector labels are one-based, replace the starting sL by sL−1 before linearization and add 1 to the final sector result. If all three disk labels are one-based, first subtract 1 from each and then add 1 to each output. If records themselves are numbered from zero, use n rather than n−1. Without these conventions an off-by-one ambiguity remains; the physical addressing rule is otherwise the same.
A page reference always repeats the previous page, is likely among recently used pages, always hits resident memory, or always faults.
Your answer
Answer & solution
Answer: B (no official key was published)
Temporal locality is the tendency to reuse recently accessed data or instructions, for example within a loop. Hence the next page reference is likely to be among a recent working set, B. This is a statistical tendency, not an absolute guarantee. A program can move to a new phase and access a different page, and whether that page is resident depends on available memory and replacement history. Thus the three statements containing always are too strong.
Match disk scheduling, batch processing, time sharing, interrupt processing to SCAN, FIFO, round robin, LIFO respectively.
Your answer
Answer & solution
Answer: C: 2, 4, 1, 3 (no official key was published)
SCAN moves the disk head systematically across pending requests. FIFO is the basic batch-job queue discipline. Round robin rotates time slices among runnable processes. Nested interrupts return in reverse order of entry, a LIFO stack behavior. The resulting mapping is 2, 4, 1, 3, C. Actual schedulers may add priorities or other refinements; the question asks for these conventional associations.
Does I/O redirection rename files, allow an existing file to supply program input, necessarily connect two programs by a pipe, or none?
Your answer
Answer & solution
Answer: B (no official key was published)
Redirection changes where a program’s input/output stream is connected. For example, connecting standard input to an existing file lets a program read that file using its usual input operations, which is B. The file need not be renamed. A pipe connects streams between processes and is related but distinct; redirection to a regular file does not require a second program. Therefore C is not a necessary description.
When an interrupt occurs, does the OS ignore it, always block the current process, always resume it, or may it block/schedule another process?
Your answer
Answer & solution
Answer: D in the broad interrupt/trap model (no official key was published)
The handler’s action depends on the event. An ordinary completed-I/O interrupt may simply update device state and return, while a fault or trap requiring an unavailable resource may block the current process and allow another to run. Thus neither always blocking nor always resuming is a general rule. D correctly expresses a possible outcome. This uses interrupt broadly enough to include synchronous traps/faults; a narrow device-only definition would need more careful distinctions about why the interrupted process blocks.
Thrashing reduces page I/O, decreases multiprogramming by definition, implies excessive page I/O, or improves performance?
Your answer
Answer & solution
Answer: C (no official key was published)
Thrashing occurs when processes repeatedly fault because their active working sets do not fit in available frames. The system spends excessive time moving pages rather than executing useful instructions, so C describes it. It increases rather than reduces paging traffic and degrades performance. Reducing the degree of multiprogramming may be a remedy, but is not automatically the meaning or inevitable direct effect of thrashing, so B confuses response with condition.
Does a page dirty bit avoid unnecessary disk writes, record LRU order, enforce read-only access, or none?
Your answer
Answer & solution
Answer: A (no official key was published)
A dirty bit records whether a page has been modified since its backing-store copy was synchronized. On eviction, a clean page can be discarded because an up-to-date copy already exists; a dirty page normally needs writeback. This avoids unnecessary writes for unchanged pages, A. Recent use is tracked by reference/access information or timestamps, while write protection uses permission bits. Those functions should not be confused with modification status.
Similar questions7 more → · asked again: GATE 2014 Set 3, Q31
Resource count excluding deadlock
Deadlocks
Tap to enlarge
Three processes each may require two units of one resource. Minimum units guaranteeing no allocation deadlock among 3, 5, 4, 6?
Your answer
Answer & solution
Answer: C: 4 (no official key was published)
With only three units, each process can hold one and wait for a second, creating deadlock. With four units, if all unfinished processes hold at most one, at least one unit remains available to give some process its second. It can finish and release its units, after which the argument repeats. Therefore four is sufficient and three can fail, so C. This is the standard worst-case incremental-allocation guarantee with eventual completion and no other resources; a restrictive admission policy could safely serialize processes with fewer units.
Nine processes repeat P(mutex);critical section;V(mutex). A tenth replaces its initial P by V. What maximum number can be inside simultaneously?
Your answer
Answer & solution
Answer: D: 10, none of 1, 2, 3 (no official key was published)
The faulty process never consumes a permit when entering and adds permits both before entering and after leaving. With a counting semaphore, it can complete enough loops to accumulate at least nine permits while the others wait to run. Then schedule all nine correct processes through P and pause each inside its critical section. Finally let the faulty process enter too: all ten are inside. Ten is the absolute upper bound because only ten processes exist, so it is attained. Even a saturating binary semaphore can be repeatedly reopened by the faulty process to admit more peers before they leave. Thus D.
Three processes use a shared resource R mutually exclusively and nonpreemptively. Each has a unique fixed priority in {1,2,3}, with 3 highest. Shared state: semaphore mutex=1; semaphores proceed[1..3]=0; Boolean R_requested[1..3]=false; Boolean busy=false. Each process repeats request_R(my_priority); P(proceed[my_priority]); use R; release_R(my_priority). The supplied request_R(p) performs P(mutex); if busy then R_requested[p]:=true else begin V(proceed[p]); busy:=true end; V(mutex). Give release_R so each allocation goes to the highest-priority current requester. The shared-data declaration is printed as process[3] in the reproduction, while uses consistently say proceed; normalize that apparent naming typo explicitly.
Answer & solution
Answer: Under mutex, select the highest set request flag, clear it and signal that process while retaining busy=true; set busy=false only if no process waits. (no official key was published)
The release operation must inspect request flags and either transfer ownership or mark the resource free as one atomic critical section. Otherwise a new requester could take R between checking the flags and waking a waiting process. This code uses the same proceed array as the process and request routines; the source's isolated process spelling is treated as a declaration typo.
procedure release_R(my_priority):
P(mutex)
chosen := 0
for p := 3 downto 1 do
if R_requested[p] then
chosen := p
break
if chosen = 0 then
busy := false
else
R_requested[chosen] := false
busy := true
V(proceed[chosen])
V(mutex)
The parameter my_priority identifies the releasing owner but is not needed to select the next one. Preconditions are that only the current owner calls release_R, each process has at most one outstanding request, and P/V have standard semaphore semantics. The no-waiter branch does not signal a semaphore: the next arriving requester will signal its own proceed entry in request_R before doing P on it.
Why keep busy true during handoff? A signaled process may not run immediately. The resource is nevertheless reserved for it; setting busy false would let a newcomer receive a second grant. Clearing the chosen flag prevents a later release from treating the same already-granted request as still waiting. Lower-priority flags remain set, preserving their requests.
Since priorities are unique and the loop scans 3,2,1, it chooses the highest pending priority at the moment of allocation. A higher-priority process arriving after that atomic choice must wait: the resource is nonpreemptive, so priority does not revoke an existing grant. At most one grant exists at a time, maintaining mutual exclusion. This scheme can starve a low-priority requester if higher-priority requests keep arriving; starvation freedom was not requested and does not follow from strict priority allocation.
A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. Records are unblocked and the program uses no buffering. Find elapsed time.
Answer & solution
Answer: 17,000 ms = 17 s. (no official key was published)
One record's transfer time is its byte count divided by the byte rate: 3200/(800×103) seconds = 0.004 seconds = 4 ms. The 10 ms access time is a separate per-read cost, so reading one unblocked record takes 10+4=14 ms. With no buffering, the program reads a record, waits for that read to finish, processes it for 3 ms, and only then starts the next record's read.
The per-record serial schedule is therefore [10 ms access][4 ms transfer][3 ms processing], lasting 17 ms. Repeating it for 1000 records gives 1000×17=17,000 ms=17 seconds. The first record's access and the last record's processing are already included, so no extra startup or drain term should be appended.
The word consecutive does not by itself remove the explicitly supplied access cost. The usual model of this question charges one access for each unblocked read; a continuous streaming device model that pays access only once would be a different assumption. Likewise, the rate is in bytes per second, so no factor of eight belongs in the calculation. The result uses the decimal rate 800×103 exactly as printed.
Without read-ahead storage there is no valid overlap between reading the next record and processing the current one in this model. Using max(14,3) per record would silently introduce buffering, which is the separate next part of the question.
A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. Records are unblocked and the program uses one buffer, always reading ahead into it. Find elapsed time.
Answer & solution
Answer: 14,003 ms = 14.003 s, under the stated ideal one-buffer read-ahead model. (no official key was published)
A record read takes 10 ms access plus 3200/(800×103) seconds transfer, or 14 ms total. The first read fills the buffer at t=14 ms. Copy record 1 into the program's local record variable at negligible cost, freeing the buffer immediately. The device can now read record 2 while the CPU processes record 1.
The timeline begins: 0–14 ms: read record 1; CPU has no record yet. 14–17 ms: process local record 1; read record 2 during 14–28 ms. 28–31 ms: process local record 2; read record 3 during 28–42 ms.
Because each read lasts 14 ms and each computation only 3 ms, the CPU finishes before the next record arrives. Record k is available at 14k ms. The final record, number 1000, arrives at 14,000 ms and must still be processed for 3 ms. Total elapsed time is 14,000+3=14,003 ms.
Equivalently, for N records, read time I and compute time C, this ideal single-record-buffer/local-variable pipeline takes I+(N−1)max(I,C)+C. Here it becomes 14+999×14+3. This formula includes the initial fill and final drain. The common shortcut N×max(I,C) would miss the last 3 ms.
One buffer is enough because the current record is moved out of that buffer before processing; CPU work uses the local copy while the device writes the next record to the buffer. This is not the same as processing in place in the sole buffer, which would prevent safe read-ahead. The source's negligible-copy assumption is what permits the overlap.
A program processes 1000 consecutive records of a sequential file on a device, without file-system facilities. Each record is 3200 bytes. Device access time is 10 ms per read; transfer rate is 800×10^3 bytes/s; CPU processing time is 3 ms per record. Copying a record from a buffer to a local variable takes negligible CPU time. Ignore additional overhead, and include startup and final processing time. The file uses blocking factor 2: each device block contains two records. The program uses one buffer. Find elapsed time, explicitly stating when the next read may begin and whether the program can retain a whole block outside the buffer.
Answer & solution
Answer: 10.503 s with one-record local storage and reads starting only after the whole buffer is free; 9.006 s with whole-block staging or early overlap (no official key was published)
There are 1000/2=500 blocks. Each block holds 6400 bytes, so its transfer takes 6400/(800×103)=0.008 s=8 ms. Including the 10 ms access, one block read takes I=18 ms. Processing its two records takes 6 ms total. The words one buffer do not alone determine how the unread second record is protected while another read is started.
Model 1: one block buffer, one-record local variable, and a new block-read operation starts only after the buffer is entirely free. The first block arrives at t=18 ms. Copy record 1 locally and process it during 18–21. Record 2 must remain in the buffer during that computation. At 21, copy record 2 locally; the buffer is now free, so start the second block read during 21–39 while processing record 2 during 21–24. Thus each block arrival is 21 ms after the preceding one, not 18 ms: three CPU milliseconds are needed before the unread second record can leave the buffer.
The kth block arrives at 18+(k−1)×21 ms. For block 500 this is 10,497 ms. After it arrives, both final records still require 6 ms, giving 18+499×21+6=10,503 ms=10.503 s. Only the last record of each nonfinal block overlaps the following read. This schedule never overwrites a record that has not been copied out.
Model 2: copy the whole two-record block into separate local staging at negligible cost, releasing the input buffer immediately. Then all 6 ms of computation can overlap the following 18 ms read. The pipeline time is 18+499×max(18,6)+6=9006 ms=9.006 s. This model needs enough staging for two records, not just the single local record explicitly used in Model 1.
A second way to attain 9.006 s is to allow the next device access phase to begin before the buffer is free, while delaying actual writes until it is safe. Start the next 10 ms access immediately when the prior block arrives. The buffer's remaining record is copied out after 3 ms, well before the subsequent 8 ms transfer begins. Block arrivals can then remain 18 ms apart even with one-record local storage. That requires an I/O interface/scheduler that supports this early access, which the question does not explicitly describe.
Accordingly 9.006 s is the conventional whole-block-pipeline result, and 10.503 s is the stricter one-record/cannot-start-until-free result. Neither should be presented as unconditionally forced by the supplied wording. The distinction is about storage and I/O scheduling, not the arithmetic of the 18 ms block read.
Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can deadlock ever arise? Prove your answer.
Answer & solution
Answer: No resource deadlock: every wait-for edge points from a younger process to an older process, so a cycle is impossible. (no official key was published)
Form a wait-for graph whose vertices are active processes. Add an edge P→Q when P is blocked waiting for a resource currently held by Q. The rules allow that wait only when TS(Q)<TS(P). If the holder is younger, the requester does not wait; it wounds the holder, whose resources are released on restart. Therefore timestamps strictly decrease along every wait-for edge.
Suppose a resource deadlock existed. For ordinary exclusive resources, a finite set of processes each blocked on resources held within the set contains a directed cycle P1→P2→…→Pk→P1. The edge rule would imply TS(P1)>TS(P2)>…>TS(Pk)>TS(P1), which is impossible for distinct ordered timestamps. Thus the wait-for graph is acyclic and the stated resource protocol cannot create deadlock.
For intuition, an older process can force a younger holder to release its resources rather than becoming dependent on it. A younger process may depend on an older one, but dependencies can never turn back toward a younger timestamp to close a cycle. This is the wound-wait scheme, not wait-die: the older requester survives and restarts the younger holder.
The restart must release all resources of the victim, as the source explicitly states; retaining them while the victim cannot proceed would not implement this proof's protocol. Resource grants, victim removal and wait-queue updates are assumed to be performed consistently by the OS. The argument rules out resource deadlock, not every possible lack of progress. An unfair CPU scheduler or a process that never finishes could still delay other processes indefinitely; those are separate starvation/liveness issues addressed under additional assumptions in the next part.
Each process receives a unique timestamp when it starts, increasing with time; smaller means older. On requesting a resource: if it is free, the OS grants it; if holder Q is older than requester P (TS(Q)<TS(P)), P waits; if Q is younger (TS(Q)>TS(P)), the OS restarts Q and grants the resource to P. Restarting takes back all Q's resources, kills Q, and starts it again with the same timestamp. When a resource is released, the waiting process with smallest timestamp receives it. A process asks for resources, uses them for some time, then exits. Can a process be starved? Prove or qualify your answer.
Answer & solution
Answer: No protocol-induced starvation under finite older predecessors, finite terminating work, and fair execution; an unconditional guarantee without these progress assumptions is not justified. (no official key was published)
Fix a process P. When it begins there are only finitely many older processes in the usual finite-system model, and every later arrival has a larger timestamp. Because a restarted process keeps its original timestamp, repeated restarts do not move P behind newcomers. Only processes older than P can wound it or outrank it on a waiting queue.
First consider the oldest active process. It cannot be wounded, and it cannot be forced to wait for a younger holder: it wounds that holder and obtains the resource. Under fair CPU execution and the stated assumption that a process does finite work and exits, this oldest process eventually completes and releases its resources. Apply the same argument successively to the remaining older processes. Since P has finitely many older predecessors, eventually they have all completed.
P is then the oldest remaining process. New arrivals remain younger and cannot wound P. A resource held by a younger process is obtained by wounding that holder; if P is already waiting when a resource is released, smallest-timestamp selection gives it precedence over younger waiters. With finite resource requests/work and fair execution, P therefore finishes. This proves absence of starvation caused by the allocation protocol under the usual progress assumptions.
Retaining timestamps is crucial. Assigning a fresh, ever-larger timestamp after every restart would destroy the fixed finite-predecessor argument. Conversely, deadlock freedom by itself would not prove starvation freedom: an acyclic system could still repeatedly favor newcomers under a different queue rule.
The question's finite-use-and-exit wording motivates the normal no-starvation answer, but scheduler fairness is not explicitly specified. If the CPU never schedules P, or an older process never finishes, P may wait indefinitely despite the timestamp rules. Those countermodels violate the progress assumptions used in the proof; they do not exhibit a starvation defect in wound-wait itself. State the assumptions rather than claiming unconditional termination from timestamp ordering alone.
A process-state diagram includes ready→running, running→ready, running→blocked and blocked→ready. What scheduler feature does the usual diagram indicate?
Your answer
Answer & solution
Answer: B: preemptive scheduling (no official key was published)
Dispatch moves a ready process into running. An I/O or resource wait moves it into blocked, and completion moves it back to ready. In the standard scheduling diagram, the extra running→ready edge represents the scheduler taking the CPU away, for example at time-slice expiry. That is preemption, giving B. A real system may also let a process voluntarily yield into ready; the unlabeled graph alone would then not prove involuntary preemption. The answer uses the conventional interpretation of this textbook state-transition diagram.
What distinguishes a critical section of a program?
Your answer
Answer & solution
Answer: C: access to shared resources (no official key was published)
A critical section is code that accesses shared state or a shared resource in a way requiring coordination with other concurrent executions. Uncontrolled overlap can violate an invariant, so a mutual-exclusion mechanism is typically needed. The definition does not require a semaphore specifically: locks, monitors, atomic operations or other protocols may enforce the required property. Nor is every short or computationally important block a critical section. The shared-resource access is the relevant characteristic, C.
Which listed device is naturally served by spooling?
Your answer
Answer & solution
Answer: A: line printer (no official key was published)
A printer consumes output serially and relatively slowly. Spooling first stores each job in a disk-backed queue, allowing producing processes to continue while a spooler feeds complete jobs to the device in order. This avoids intermixing different jobs and decouples application execution from printing speed. A line printer is therefore the standard example. Spooling is not merely a CPU cache or an arbitrary buffer: its key role here is queued management of an exclusive sequential output device.
A 1000-Kbyte variable-partition memory has two allocated partitions of 200 and 260 Kbytes, with no compaction. What smallest integer-Kbyte request could be denied?
Your answer
Answer & solution
Answer: B: 181 Kbytes (no official key was published)
Free space totals 1000−200−260=540 Kbytes. Two occupied contiguous partitions divide linear memory into at most three free holes. Therefore at least one hole has size at least 540/3=180 Kbytes, so every request of at most 180 Kbytes can fit somewhere. This bound is attainable by arranging hole 180,allocation 200,hole 180,allocation 260,hole 180. In that layout a request of 181 Kbytes fails despite sufficient total free memory. Thus 181 is the smallest integer request that could fail; the question asks a possible worst layout, not a guarantee for every layout.
Which fork-taking rule prevents dining-philosopher deadlock: all left first, all right first, or one philosopher reversing the order used by everyone else?
Your answer
Answer & solution
Answer: C: one reverses the order (no official key was published)
If every philosopher takes the same side first, all can hold one fork and wait for the next, forming a circular wait. Reversing one philosopher’s order breaks that directed cycle: the neighboring philosophers compete for a common first fork, so they cannot all simultaneously hold distinct first forks while each awaits the next. Consequently the full circular-wait deadlock is impossible in the standard ring model. This prevents deadlock, not necessarily starvation without a fairness assumption. The uniform-left and uniform-right rules both retain the circular wait.
Similar questions1 more → · asked again: GATE 1993, Q7.10
Completion time under round robin
CPU Scheduling
Tap to enlarge
At time 0, jobs A,B,C,D arrive in that order with CPU bursts 4,1,8,1. With quantum 1 and no overhead, when does A complete?
Your answer
Answer & solution
Answer: D: time 9 (no official key was published)
The first four one-unit slices execute A,B,C,D, ending at time 4. B and D have now finished; A has three units left and C has seven. The next slices are A from 4–5, C from 5–6, A from 6–7, C from 7–8, and A from 8–9. A’s fourth unit therefore finishes at time 9. Counting four slices for A alone would ignore the CPU time given to other ready jobs. The result assumes the stated arrival order determines the initial queue and there is no context-switch cost.
A demand-paged system has 16-bit virtual addresses, 256-byte pages, 1 KiB physical memory, and LRU order [17,1,63] from least to most recent. Process hexadecimal addresses 00FF,010D,10FF,11B0 in order. Only three initial residents are listed, so assume the fourth frame is free. Give the new list after each access.
Answer & solution
Answer: [17,1,63,0]; [17,63,0,1]; [63,0,1,16]; [0,1,16,17]. (no official key was published)
The offset occupies eight bits because a page has 28 bytes. Discard the low two hexadecimal digits to obtain decimal page references 0,1,16,17. Physical memory holds 1024/256=4 pages.
At 00FF, page 0 is absent: fault, load into the free frame, order [17,1,63,0]. At 010D, page 1 is present: hit, remove it from its old LRU position and append it, order [17,63,0,1]. At 10FF, page 16 is absent and memory is full: evict 17, append 16, order [63,0,1,16]. At 11B0, page 17 is absent because the previous reference evicted it: evict 63, append 17, order [0,1,16,17].
A page fault need not cause a replacement when a free frame exists; this distinction matters for the first reference. The initial figure shows three residents despite four-frame capacity. If an unprinted fourth resident was intended instead, its identity and recency are necessary for a unique trace. We do not invent that page or silently change memory capacity to three frames.
A demand-paged system has 16-bit virtual addresses, 256-byte pages, 1 KiB physical memory, and LRU order [17,1,63] from least to most recent. Process hexadecimal addresses 00FF,010D,10FF,11B0 in order. Only three initial residents are listed, so assume the fourth frame is free. Identify the accesses causing page faults.
Answer & solution
Answer: Faults at 00FF,10FF,11B0; 010D is a hit. (no official key was published)
The offset occupies eight bits because a page has 28 bytes. Discard the low two hexadecimal digits to obtain decimal page references 0,1,16,17. Physical memory holds 1024/256=4 pages.
At 00FF, page 0 is absent: fault, load into the free frame, order [17,1,63,0]. At 010D, page 1 is present: hit, remove it from its old LRU position and append it, order [17,63,0,1]. At 10FF, page 16 is absent and memory is full: evict 17, append 16, order [63,0,1,16]. At 11B0, page 17 is absent because the previous reference evicted it: evict 63, append 17, order [0,1,16,17].
A page fault need not cause a replacement when a free frame exists; this distinction matters for the first reference. The initial figure shows three residents despite four-frame capacity. If an unprinted fourth resident was intended instead, its identity and recency are necessary for a unique trace. We do not invent that page or silently change memory capacity to three frames.
A demand-paged system has 16-bit virtual addresses, 256-byte pages, 1 KiB physical memory, and LRU order [17,1,63] from least to most recent. Process hexadecimal addresses 00FF,010D,10FF,11B0 in order. Only three initial residents are listed, so assume the fourth frame is free. Identify page replacements, if any.
Answer & solution
Answer: 00FF: free frame; 010D: none; 10FF: replace 17 with 16; 11B0: replace 63 with 17. (no official key was published)
The offset occupies eight bits because a page has 28 bytes. Discard the low two hexadecimal digits to obtain decimal page references 0,1,16,17. Physical memory holds 1024/256=4 pages.
At 00FF, page 0 is absent: fault, load into the free frame, order [17,1,63,0]. At 010D, page 1 is present: hit, remove it from its old LRU position and append it, order [17,63,0,1]. At 10FF, page 16 is absent and memory is full: evict 17, append 16, order [63,0,1,16]. At 11B0, page 17 is absent because the previous reference evicted it: evict 63, append 17, order [0,1,16,17].
A page fault need not cause a replacement when a free frame exists; this distinction matters for the first reference. The initial figure shows three residents despite four-frame capacity. If an unprinted fourth resident was intended instead, its identity and recency are necessary for a unique trace. We do not invent that page or silently change memory capacity to three frames.
fork L creates a new process starting at label L while the original continues. join V atomically decrements V and terminates the arriving process unless the new value is zero. For N=2; M=2; fork L3; fork L4; S1; L1: join N; S3; L2: join M; S5; goto next; L3: S2; goto L1; L4: S4; goto L2; next:, draw the precedence graph for S1..S5. The goto next after S5 is present in GFG but omitted in GateForum.
Answer & solution
Answer: Edges S1→S3, S2→S3, S3→S5, S4→S5 (no official key was published)
After the two forks there are three branches. The original executes S1, the L3 branch executes S2, and the L4 branch executes S4. There is no synchronization among those three statements, so they can occur in any order or overlap.
The S1 and S2 branches both reach join N. Because N starts at 2, the first arrival changes N to 1 and terminates; the second changes N to 0 and survives. Exactly one process therefore continues to S3, and S3 cannot start until both S1 and S2 have finished. This gives edges S1→S3 and S2→S3. The identity of the surviving process is irrelevant to the statement ordering.
The branch completing S3 and the branch completing S4 both reach join M. The same counting argument, with M initially 2, permits S5 exactly once, after both predecessors finish. Add edges S3→S5 and S4→S5. These four edges form the transitive reduction: draw S1 and S2 feeding S3, then S3 and S4 feeding S5. The additional transitive relations S1→S5 and S2→S5 need not be drawn.
This finite five-statement interpretation uses the paper's explicit goto next after S5. Its execution is not captured by the intended one-node-per-statement DAG. Omitting the jump is a material control-flow variant, not harmless punctuation.
Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Show that this can be a state admitted by the Banker’s algorithm.
Answer & solution
Answer: Safe sequence P1→P2→P0; Work evolves (2,2,0)→(2,5,1)→(3,5,3)→(4,5,5). (no official key was published)
Step through it (5 steps)
The table heading “Maximum Need” gives total claims, not outstanding requests. Subtract each allocation to obtain remaining Need: P0=(3,1,0), P1=(1,2,0), P2=(0,2,1). The total resource vector is Available plus all allocations, namely (4,5,5); every maximum is individually within this total.
Run the safety test with Work=(2,2,0). P0 cannot finish yet because it needs 3 units of R0 but only 2 are free. P2 cannot finish because it needs one R2 while none is free. P1 can finish since (1,2,0) is componentwise at most (2,2,0). After it finishes, Work increases by its current allocation (0,3,1), yielding (2,5,1). Adding allocation, rather than maximum, is correct: its extra temporary requests are returned too, leaving the net increase equal to the allocation it already held.
Now P2's need (0,2,1) fits, so its completion releases (1,0,2) and Work becomes (3,5,3). Finally P0's need (3,1,0) fits; releasing (1,0,2) yields (4,5,5). Thus P1,P2,P0 is a safe sequence, proving that all claims can be satisfied in a suitable order. Safety does not assert that every possible future request is immediately grantable; it establishes at least one completion schedule from the current allocations.
Three processes P0,P1,P2 share resource types R0,R1,R2. Maximum total claims are P0=(4,1,2), P1=(1,5,1), P2=(1,2,3). Current allocations are P0=(1,0,2), P1=(0,3,1), P2=(1,0,2), and Available=(2,2,0). Determine what happens when P0 requests one unit of R1.
Answer & solution
Answer: Defer P0’s request: tentative Available=(2,1,0) is unsafe although the unit is available. (no official key was published)
Step through it (4 steps)
The request vector is R=(0,1,0). First check R<=Need0=(3,1,0), so the request does not exceed P0's remaining claim. Also R<=Available=(2,2,0), so the requested unit is physically available. These necessary checks alone do not justify granting it.
Tentatively allocate the unit. Available becomes (2,1,0), P0's allocation becomes (1,1,2), and P0's remaining need becomes (3,0,0). The other needs remain P1=(1,2,0), P2=(0,2,1). Begin the safety test with Work=(2,1,0). P0 cannot finish because 3>2 in R0; P1 cannot finish because 2>1 in R1; P2 cannot finish because it needs 2 R1 and 1 R2, while only 1 R1 and 0 R2 are free. No process can be the first in a guaranteed completion sequence.
The tentative state is therefore unsafe. The Banker rolls back the tentative change and makes P0 wait, preserving Available=(2,2,0) and the original safe allocations. This is not a claim that the request is invalid or that an actual deadlock has already occurred. It is a refusal to enter a state from which completion under all declared maximum claims cannot be guaranteed. The one free unit's availability is precisely why a full safety test, rather than a simple availability check, is needed.
A one-level file system uses 4K-byte disk blocks. Disk block 0 contains a FAT with one 8-bit next-data-block address entry per data block. Disk block 1 is a directory with one 32-bit entry per file. Disk blocks 2,3,... are data blocks 1,2,... . Take K=1024. Find the maximum possible number of files.
Answer & solution
Answer: 1024 directory entries/files when empty files are permitted; nonempty-file capacity is additionally data-block limited. (no official key was published)
The directory occupies one block, so its storage is 4×1024=4096 bytes. A directory entry uses 32 bits=4 bytes. Hence it contains 4096/4=1024 entries and can name at most 1024 files. This is a directory-capacity bound; the FAT entry count must not be substituted into this division.
Attaining that many named files does not require one data block for every file if zero-length files are allowed. Empty files can occupy directory entries without owning data blocks, so the customary directory-capacity interpretation gives 1024 files. If instead the question requires every file to be nonempty, the result also depends on the number of addressable data blocks and the unspecified pointer conventions. Under a uniform 8-bit data-block address convention with all 256 patterns usable, at most 256 one-block nonempty files fit, and reserved FAT markers reduce that number.
There is a related source-design omission: a 4096-byte FAT can physically hold 4096 one-byte entries, but one-byte next pointers cannot name all 4096 positions under a uniform address scheme. Thus table capacity, pointer addressability, and directory capacity are three distinct quantities. The problem does not specify empty-file policy, reserved values, or actual disk capacity; 1024 is the unambiguous maximum directory entry count, not a proof that 1024 nonempty files can simultaneously occupy the disk.
A one-level file system uses 4K-byte disk blocks. Disk block 0 contains a FAT with one 8-bit next-data-block address entry per data block. Disk block 1 is a directory with one 32-bit entry per file. Disk blocks 2,3,... are data blocks 1,2,... . Take K=1024. Find the maximum possible file size in data blocks.
Answer & solution
Answer: Conventional answer: 256 data blocks (1 MiB), conditional on uniform 8-bit identifiers without reserved codes; literal exact bound depends on unspecified encoding. (no official key was published)
A FAT-linked file is a chain: its directory entry identifies the first data block, and each block's FAT entry identifies the next. With a uniform 8-bit data-block addressing convention there are 28=256 possible address values. If all values are usable data-block identifiers and termination is represented separately (for example by known file length), a file can traverse at most 256 distinct data blocks. It would occupy 256×4096=1,048,576 bytes. This is the conventional intended pointer-width answer.
The 4KB FAT itself has room for 4096 one-byte entries, but room to store an entry is not the same as enough pointer bits to address its block. Therefore 4096 blocks is not justified merely by dividing FAT size by entry size. A pointer width of at least 12 bits would be required to name 4096 data blocks uniformly.
The literal question does not define end-of-file encoding or whether addresses refer to physical disk blocks or data-block ordinals. Reserving one of the 256 values for EOF leaves at most 255 usable uniform data-block addresses. If physical block numbers 0 and 1 are also excluded as metadata locations, the usable range changes again. These are specification choices, not values established by the paper. Accordingly 256 blocks is conditional on the standard all-patterns-usable data-block model; an exact implementation-level maximum cannot be certified without the address and termination conventions. The directory entry's 32 bits do not by themselves repair the short next pointers.
Why might a paged-segmented memory scheme give the segment table itself a page table?
Your answer
Answer & solution
Answer: A: the segment table can be too large for one page (no official key was published)
A large segment table can span multiple pages. Paging that table lets its pieces be placed in separate physical frames and, where supported, brought in on demand. A page table is then needed to translate addresses of the segment-table pages themselves. This is distinct from the page tables belonging to individual program segments. The wording “must” is architecture dependent: a small segment table or an architecture requiring contiguous resident tables need not use this extra paging level. A describes the motivation within the assumed paged-table design.
Which replacement policy can have more page faults after increasing the frame count: OPT, LRU, FIFO, or OPT and FIFO?
Your answer
Answer & solution
Answer: C: FIFO (no official key was published)
FIFO removes the page that has been resident longest, independent of recent use or future demand. Its resident sets with different frame counts need not be nested, so adding a frame can alter the eviction order disadvantageously. The classic string 1,2,3,4,1,2,5,1,2,3,4,5 gives nine FIFO faults with three frames and ten with four. LRU and OPT have the stack-inclusion property and do not suffer this anomaly. Therefore C is the correct policy.
Which policy is most suitable for a time-shared OS: shortest job first, round robin, FCFS or elevator?
Your answer
Answer & solution
Answer: B: round robin (no official key was published)
Round robin gives each ready process a bounded time slice and cycles through the queue. This prevents one long CPU-bound job from monopolizing the processor and supports responsive interactive use. FCFS can make short interactive requests wait behind a long job. SJF requires burst predictions and can disadvantage long jobs; elevator is chiefly a disk-head scheduling rule. Round robin is therefore the standard choice here, with quantum size balancing response time against context-switch overhead.
Nonpreemptive jobs (arrival,burst) are 1:(0,9),2:(0.6,5),3:(1,1). Which listed sequence is optimal, with how much idle time?
Your answer
Answer & solution
Answer: A: [3,2,1],idle 1, for minimum total completion/turnaround time (no official key was published)
Wait until time 1, run job 3 to time 2, job 2 to time 7 and job 1 to time 16. Completion times sum to 25. For each of the six orders, starting each job as early as its order permits gives sums 38,34,27.8,35.8,25,29 respectively for 123,132,231,213,321,312. Thus 321 minimizes their sum and leaves the CPU idle for one initial time unit. Subtracting fixed arrival times shows the same order minimizes mean turnaround and waiting time. The source says “optimal” without specifying this objective; minimizing makespan alone would instead avoid initial idling.
With 100 records per page and one initially free frame, access 0100,0200,0430,0499,0510,0530,0560,0120,0220,0240,0260,0320,0370. How many faults?
Your answer
Answer & solution
Answer: C: 7 (no official key was published)
Treating addresses as the stated decimal record numbers, integer division by 100 gives pages 1,2,4,4,5,5,5,1,2,2,2,3,3. With just one frame, a fault occurs on the first reference and each change of page. The seven consecutive runs are 1 | 2 | 4,4 | 5,5,5 | 1 | 2,2,2 | 3,3. Thus there are seven faults. Leading zeros are address formatting here, not C octal literals; interpreting them as octal would be incompatible with the printed digit 9.
Must the CPU-addressable virtual space be smaller or larger than physical memory and secondary storage?
Your answer
Answer & solution
Answer: C under the textbook larger-than-RAM/smaller-than-backing-store model; no universal “must” (no official key was published)
Virtual memory commonly lets a process use an address space larger than the currently installed RAM, with inactive pages backed by secondary storage. Under a simple fully backed textbook model, this motivates larger than physical memory and smaller than backing storage, choice C. But address-bit width defines a possible address space, not a promise that every possible address is allocated or backed simultaneously. Sparse mappings, demand-zero pages and reservation policies break the claimed universal inequality. Thus the word “must” is too strong without the fully allocated/backed model, and actual capacity ratios are architecture and configuration dependent.
1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Draw both memory allocation sequences.
Answer & solution
Answer: First fit admits all jobs; best fit cannot admit J6. (no official key was published)
Use half-open address intervals in K so that [0,200) has size 200. Both algorithms initially allocate J1=[0,200), J2=[200,550), J3=[550,850), leaving [850,1000) free. When J1 finishes, the holes are [0,200) and [850,1000).
First fit: J4 takes [0,120), leaving holes [120,200) of size 80 and [850,1000) of size 150. J5 cannot fit in 80, so it occupies [850,1000). J6 then exactly fills [120,200). Final low-to-high layout is J4:120 | J6:80 | J2:350 | J3:300 | J5:150.
Best fit: J4 takes the smaller adequate hole [850,1000), occupying [850,970) and leaving 30K. J5 takes [0,150), leaving [150,200) of size 50. J6 needs 80K but neither the 50K nor 30K hole suffices. Final layout is J5:150 | free:50 | J2:350 | J3:300 | J4:120 | free:30, with J6 waiting.
The total free space is 80K, equal to J6’s request, but it is split into nonadjacent holes. This is external fragmentation, not a shortage of aggregate space.
1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Answer & solution
Answer: First fit. (no official key was published)
First fit places the 120K job in the initial 200K hole, preserving an 80K remainder. It then puts the 150K job in the separate 150K hole and admits the final 80K job into the exact remainder. Consequently every arriving job is resident at the end, filling all 1000K.
Best fit uses the 150K hole for the 120K request, leaving 30K. The later 150K request takes 150K out of the 200K hole, leaving 50K. Although 50+30=80, the final 80K request requires one contiguous region and cannot be admitted without relocation or compaction. First fit therefore performs better on the stated admission/utilization criterion. This trace is a counterexample to the intuition that the locally smallest leftover always leads to the best future allocation. It is not a proof that first fit dominates best fit for every workload.
Draw the precedence graph of nine concurrent branches (separated here by |): S1;V(a);V(b) | P(a);S2;V(c);V(d) | P(c);S4;V(e) | P(d);S5;V(f) | P(e);P(f);S7;V(k) | P(b);S3;V(g);V(h) | P(g);S6;V(i) | P(h);P(i);S8;V(j) | P(j);P(k);S9. All variables a through k are semaphores. This is the GFG version. GateForum instead has V(c) after S4 and P(j);P(j);P(k) before S9. Initial semaphore values are not explicitly supplied; state the synchronization assumption.
Answer & solution
Answer: With semaphores initially zero: 1→2, 1→3, 2→4, 2→5, 4→7, 5→7, 3→6, 3→8, 6→8, 7→9, 8→9 (no official key was published)
Assume the usual precedence convention: every semaphore initially equals zero, P waits for and consumes one signal, and V supplies one signal. Initialization is essential: positive initial tokens would allow some statements to run before their supposed predecessors. With initially-zero semaphores, map each signal after a statement to the wait before another statement.
The labeled dependency edges are S1−a→S2, S1−b→S3; S2−c→S4, S2−d→S5; S4−e→S7, S5−f→S7; S3−g→S6, S3−h→S8; S6−i→S8; S8−j→S9 and S7−k→S9. This edge list is a complete exact specification of the requested graph. To draw it, put S1 at the top, S2 and S3 below it, S4/S5 below S2, S6 below S3, S7 below S4/S5, S8 below S6, and S9 below S7/S8; include the additional direct S3→S8 edge. That direct edge is transitively redundant because S3→S6→S8 already holds, but faithfully represents semaphore h.
S7 is a join: it cannot execute until both S4 and S5 have completed. Similarly S8 waits for both signals from S3 and S6, and S9 joins the two sides. Statements on different sides need not execute in a fixed order.
Its V(c) after S4 supplies no e token, so S7 is permanently blocked at P(e). Its final branch also waits twice on j, although S8 signals j only once, so S9 blocks at its second P(j), even independently of the missing k signal. Under fair execution, S1,S2,S3,S4,S5,S6,S8 may finish; S7 and S9 do not.
A disk has tracks 0–99. Its head is at track 55, and the pending FIFO queue is 10,70,75,23,65. Calculate total head movement for FCFS and SSTF and say which is smaller.
Answer & solution
Answer: FCFS:204 tracks. SSTF:85 tracks. SSTF saves 119 tracks. (no official key was published)
Step through it (2 schedules)
Head movement is the sum of absolute differences between consecutive serviced track numbers, including the initial position. FCFS must preserve arrival order: 55→10→70→75→23→65. Its successive movements are 45,60,5,52,42, totaling 204 tracks.
SSTF repeatedly chooses the nearest pending request from the current position, not the request nearest the original position. From55 the distances to 10,70,75,23,65 are 45,15,20,32,10, so choose 65. From65 choose 70 (distance 5), then 75 (distance 5). Of the remaining tracks 23 and 10, track 23 is 52 away and 10 is 65 away, so service 23 then 10. Thus the route is 55→65→70→75→23→10, and the total is 10+5+5+52+13=85. There are no distance ties in this instance.
SSTF therefore requires 119 fewer track movements, assuming seek effort is being compared by track distance. Neither algorithm requires a sweep to track 0 or 99; that would be a different scheduling policy. No return to the starting track is requested. The conclusion concerns this finite queue, not a claim that SSTF prevents starvation or always optimizes every possible workload.
A heavily used page was loaded early and remains in constant use. Which listed policy can evict it because of its age: LRU, FIFO, generic replacement, or none?
Your answer
Answer & solution
Answer: B: FIFO (no official key was published)
FIFO orders resident pages by when they entered memory, ignoring later references. A page loaded early can therefore reach the front of the eviction queue even while frequently accessed. LRU updates recency information when the page is used, so constant recent use protects it relative to less recently referenced pages. The question contrasts these policy criteria, not an absolute guarantee that a page can never be evicted under any workload. FIFO’s load-age rule is the specific explanation.
Which is true: nested macro definitions are impossible; overlays allow a program larger than address space; virtual memory exceeds address space; or high-level interrupt routines are impossible?
Your answer
Answer & solution
Answer: B under the total-program-overlay interpretation (no official key was published)
An overlay design keeps only selected mutually exclusive program portions resident at once and loads others into reused addresses. Its total stored program can therefore exceed the simultaneously addressable space, provided each active configuration fits. Virtual memory can exceed installed physical RAM, but it does not by itself enlarge the architecture’s virtual address space. Nested macros and high-level interrupt routines are possible in suitable tools, so the blanket impossibility claims fail.
The pictured heap has allocated lengths 50,300,600 separating free holes of lengths 150 and 350. Can requests 300,25,125,50 be satisfied by first fit, best fit, both or neither?
Your answer
Answer & solution
Answer: B: first fit but not best fit (no official key was published)
Both policies allocate the first request in the 350 hole, leaving free lengths [150,50]. First fit places 25 in the first hole, leaving [125,50], then 125 there, leaving [0,50], and finally fits 50. Best fit places 25 in the 50 hole, leaving [150,25], then 125 in the 150 hole, leaving [25,25]. The final 50 fits neither hole, though total free space is 50. Hence only first fit succeeds.
Precedence versus control flow in conditional code
Synchronization & Concurrency
Tap to enlarge
The printed straight-line code is S1: read n; S2: i:=1; S3: if i>n goto next; S4: a(i):=i+1; S5: i:=i+1; S6: next: write a(i). No backward jump is printed. Draw its precedence graph, stating the treatment of conditional execution.
Answer & solution
Answer: Precedence 1→3, 2→3, 3→4, 4→5, 5→6, 3→6; statements 4 and 5 run only on the false branch (no official key was published)
The source calls for a precedence graph but contains a conditional jump, so an ordinary unguarded task DAG cannot by itself specify whether S4 and S5 execute. A faithful control-flow graph is S1→S2→S3, with S3 true→S6 and S3 false→S4→S5→S6. This edge list completely specifies the literal execution graph; there is no loop-back edge.
For potential parallel execution, S1 and S2 are independent initial tasks: the former writes n and the latter writes i. S3 needs both values, giving S1→S3 and S2→S3. On the false branch, keep S3→S4→S5→S6. S4 must precede S5 because it reads the old i both as an index and as the right-side operand; S5 changes i. S6 must see the incremented i on this branch. On the true branch, S6 follows S3 directly without executing S4 or S5. Thus a conservative guarded precedence description has edges 1→3,2→3,3→4,4→5,5→6,3→6, with 4 and 5 guarded by i≤n.
Do not conflate this graph with a pure data-dependence graph, which would omit some control edges and include direct uses of i. Also do not insert a guessed loop. With n≥1 the literal code assigns a(1), increments i to 2, then writes a(2), which it has not initialized. With n<1 it immediately writes a(1), also not initialized here. These are semantic concerns in the printed fragment, not permission to change its instructions. The question lacks enough conventions for a unique unqualified concurrency graph.
The printed straight-line code is S1: read n; S2: i:=1; S3: if i>n goto next; S4: a(i):=i+1; S5: i:=i+1; S6: next: write a(i). No backward jump is printed. Can its graph be converted into a concurrent program using parbegin–parend only?
Answer & solution
Answer: Not with parbegin–parend alone preserving the conditional skip. With an ordinary conditional as well, S1 and S2 can run in parallel, followed by S3-controlled work. (no official key was published)
A parbegin–parend block starts all of its component branches and waits for them all to finish. It expresses fork/join synchronization, not a data-dependent choice to omit a branch. In the printed program S4 and S5 must be skipped if i>n, and must execute in order otherwise. Therefore an unconditional composition using only sequential composition and parbegin–parend cannot represent the exact conditional semantics. This is the sense in which the answer is no.
If ordinary conditionals are allowed alongside parbegin–parend, a simple equivalent ordering is: parbegin read n; i:=1 parend; if i≤n then begin a(i):=i+1; i:=i+1 end; write a(i). The first two statements have disjoint write sets, so running them concurrently is safe; the join ensures both values are ready before the test. The remaining statements retain their branch and anti-dependence order. This transformation preserves even the original fragment's possible uninitialized-array access; it does not repair it.
One must distinguish this semantic issue from the graph-theoretic claim that every precedence DAG can be expressed by nested fork/join. That latter claim is false in general, but no particular non-series-parallel graph should be asserted here without specifying which dependence convention produced it. The conservative dependency ordering of part (a), once branch guards are disregarded, is structurally fork/join compatible. The actual obstacle under the literal word “only” is conditional execution. If the examiner intended a different dependence-only graph or omitted loop, that intent is not established by the paper.
Deadlock detection with multiple resource instances
Deadlocks
Tap to enlarge
Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. Does the depicted resource-allocation graph represent deadlock?
Answer & solution
Answer: No, under the standard assumption that a process finishes and releases its holdings after its depicted requests are granted. (no official key was published)
Read each dot-to-process arrow as an allocated instance and each process-to-resource arrow as an outstanding request. In resource order (r1,r2,r3), total resources are (2,3,2). The allocation rows are P0=(1,0,1), P1=(1,1,0), P2=(0,1,0), P3=(0,1,0); their sum is (2,3,1), leaving Work=(0,0,1). The request rows are P0=(0,1,1), P1=(1,0,0), P2=(0,0,1), P3=(1,2,0). The two parallel P3→r2 arrows mean two requested instances, not a duplicated decorative edge.
Initially P2 is the process whose request vector is componentwise at most Work. Give it the free r3 instance. Under the standard graph-reduction model it completes, releasing that temporary grant and its held r2 instance. Consequently Work increases by its original allocation, from (0,0,1) to (0,1,1). P0 can now receive its requested r2 and r3 instances and complete, increasing Work to (1,1,2). P1 can then finish and increase Work to (2,2,2). Finally P3's request (1,2,0) is satisfiable, so it also completes.
All process nodes can be removed, so the current graph does not describe a deadlock. Cycles alone are insufficient to infer deadlock when resource types have multiple instances. This is a reduction of the displayed current requests, not a claim of Banker safety against unknown additional future maximum demands; no such maxima are supplied.
Resource types r1,r2,r3 have respectively 2,3,2 instances. Assignments are r1→P1 and r1→P0; r2→P1, r2→P2 and r2→P3; r3→P0, leaving one r3 instance free. Outstanding requests are P1→r1; P0→r2 and P0→r3; P2→r3; P3→r1 and two P3→r2 arrows. If the system is not deadlocked, give a safe completion sequence.
Answer & solution
Answer: P2 → P0 → P1 → P3. (no official key was published)
Use the available-vector test in resource order (r1,r2,r3). Initially Work=(0,0,1). P2 requests (0,0,1), so its request fits. On completion its original holding (0,1,0) returns to the available pool, giving Work=(0,1,1). It is important not to count the temporarily granted r3 twice: allocation-based reduction adds only the allocation it held before this simulated completion.
Next P0 requests (0,1,1), exactly within Work. It finishes and releases original allocation (1,0,1), making Work=(1,1,2). P1's outstanding request (1,0,0) now fits; releasing its original allocation (1,1,0) gives Work=(2,2,2). P3 can finally receive (1,2,0); releasing its original holding (0,1,0) gives Work=(2,3,2), the complete resource inventory. Thus P2,P0,P1,P3 is a valid completion sequence.
Indeed the initial choices are forced by the displayed requests: P0 initially lacks r2, while P1 and P3 lack r1. After P2, P0 is the only remaining satisfiable process. After P0, P3 still needs two free r2 instances but only one is available, forcing P1 before P3. Under simultaneous satisfaction of the displayed request vectors this order is therefore unique. As in part (a), “safe” means all these displayed requests can be satisfied and the processes finish; the graph does not state maximum possible future claims, so a stronger Banker's-algorithm safety assertion is outside the supplied data.
Similar questions1 more → · asked again: GATE 1998, Q1.25
What software must always remain resident
Processes, Threads & System Calls
Tap to enlarge
Which listed system software must reside in main memory under all circumstances: editor,assembler,linker,loader,or none?
Select all that apply
Answer & solution
Answer: D in the conventional resident-loader model; E for the literal universal claim (no official key was published)
A simple textbook system keeps a resident loader or loading service available to bring executable code into memory, motivating D. Editors,assemblers and linkers can be loaded only when needed. But “under all circumstances” is too strong: a bootstrap loader can finish and release its memory; loading can be implemented by firmware or by parts of an OS rather than a permanently resident standalone loader. Therefore no listed application is universally required to remain in RAM for every architecture. The conventional answer is retained conditionally, not elevated into an architecture-independent fact.
Where should the root directory be placed: (A) fixed address in main memory, (B) fixed location on its disk, (C) anywhere on its disk, (D) fixed location on the system disk, or (E) anywhere on the system disk?
Select all that apply
Answer & solution
Answer: B for a fixed-root layout; a discoverable pointer permits arbitrary placement (no official key was published)
The filesystem must be able to locate its root from known metadata. In a simple fixed-root layout this is achieved by placing the root at a predefined disk location, giving B; each disk or filesystem can have its own root, so it need not reside on a separate system disk. Modern designs can instead store a root block or inode pointer in a discoverable superblock, allowing the root itself to be elsewhere. Thus fixed placement is one implementation convention, not a universal requirement. A fixed RAM address does not establish persistent disk organization.
Three processes have maximum same-resource demands 3,4,6. Among m=7,9,10,13,15,which supplies guarantee no resource deadlock?
Select all that apply
Answer & solution
Answer: D,E: 13 and 15; exact threshold 11 (no official key was published)
If all three unfinished processes hold one less than their maxima, they can hold 2+3+5=10 units and still each request another. Thus ten units can deadlock, and smaller listed supplies can also be exhausted among unsatisfied processes. With eleven units, at least one additional unit is available whenever all processes are below their maxima, enabling some process to reach its demand, finish and release resources. Repeating resolves the rest. Therefore every supply at least eleven is safe under the standard completion model; the listed qualifying values are 13 and 15, not only the smaller of them.
Similar questions1 more → · asked again: GATE 1996, Q2.20
Round-robin completion of p
CPU Scheduling
Tap to enlarge
At time 0 jobs p,q,r,s,t arrive in that order with bursts 4,1,8,1,2. Quantum is 1. Find p’s completion time.
Select all that apply
Answer & solution
Answer: C: 11 (no official key was published)
The first round executes p,q,r,s,t from time 0 to 5; q and s then finish. The second round runs p from 5–6,r from 6–7,t from 7–8, completing t. The remaining queue is p,r. They run p8–9,r9–10,p10–11. This is p’s fourth unit, so it completes at 11. Context-switch overhead is assumed zero, and the arrival order determines the initial queue. A simple burst-only count would miss the intervening slices consumed by the other ready jobs.
Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.
Answer & solution
Answer: 9 faults, at reference positions 1,2,3,4,7,8,11,12,13. (no official key was published)
Step through it (16 steps)
The first four distinct references each fault and fill the four frames. On a later miss, evict the oldest entry in the policy order below. For LRU that means least recently used; for FIFO it means earliest loaded. LRU moves a referenced resident page to most-recent position even on a hit. Thus after references 5 and 6 the order is 2,4,1,3, and page 2 is evicted for page 5 at reference 7.
The full trace lists reference position, requested page, result, and policy order from eviction candidate to newest: 1: page 1, fault, order 1 2: page 2, fault, order 1,2 3: page 3, fault, order 1,2,3 4: page 4, fault, order 1,2,3,4 5: page 1, hit, order 2,3,4,1 6: page 3, hit, order 2,4,1,3 7: page 5, fault, order 4,1,3,5 8: page 2, fault, order 1,3,5,2 9: page 1, hit, order 3,5,2,1 10: page 5, hit, order 3,2,1,5 11: page 4, fault, order 2,1,5,4 12: page 3, fault, order 1,5,4,3 13: page 2, fault, order 5,4,3,2 14: page 3, hit, order 5,4,2,3
There are 9 faults. Positions are reported rather than only page values because the same page can fault more than once. Initially empty frames cause compulsory faults too; omitting them would undercount.
Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under FIFO.
Answer & solution
Answer: 8 faults, at reference positions 1,2,3,4,7,9,13,14. (no official key was published)
Step through it (16 steps)
The first four distinct references each fault and fill the four frames. On a later miss, evict the oldest entry in the policy order below. For LRU that means least recently used; for FIFO it means earliest loaded. FIFO changes its insertion order only on a fault. Hits at references 5 and 6 do not refresh pages 1 and 3. Therefore page 1, the oldest arrival, is evicted for page 5 at reference 7.
The full trace lists reference position, requested page, result, and policy order from eviction candidate to newest: 1: page 1, fault, order 1 2: page 2, fault, order 1,2 3: page 3, fault, order 1,2,3 4: page 4, fault, order 1,2,3,4 5: page 1, hit, order 1,2,3,4 6: page 3, hit, order 1,2,3,4 7: page 5, fault, order 2,3,4,5 8: page 2, hit, order 2,3,4,5 9: page 1, fault, order 3,4,5,1 10: page 5, hit, order 3,4,5,1 11: page 4, hit, order 3,4,5,1 12: page 3, hit, order 3,4,5,1 13: page 2, fault, order 4,5,1,2 14: page 3, fault, order 5,1,2,3
There are 8 faults. Positions are reported rather than only page values because the same page can fault more than once. Initially empty frames cause compulsory faults too; omitting them would undercount.
Implement DAG edges S1→S2,S1→S3,S2→S4,S2→S5,S3→S5,S6→S4,S6→S5 using parbegin/parend and semaphores. Note S6 is a source, not a sink.
Answer & solution
Answer: One zero-initialized semaphore per edge; each task waits on incoming edges and signals outgoing edges. (no official key was published)
Use semaphores e12,e13,e24,e25,e35,e64,e65, each initialized to zero. P(e) waits and decrements atomically; V(e) signals. Run these six branches in one parbegin/parend block:
begin S1; V(e12); V(e13) end begin P(e12); S2; V(e24); V(e25) end begin P(e13); S3; V(e35) end begin P(e24); P(e64); S4 end begin P(e25); P(e35); P(e65); S5 end begin S6; V(e64); V(e65) end
For each edge u→v, its semaphore can be signalled only after Su finishes, and Sv cannot start until its wait succeeds. Hence every required precedence is enforced. Distinct edge semaphores prevent one successor from consuming another's notification. They also allow a signal to arrive before its matching wait without being lost.
Only S1 and S6 have no predecessors, so they can begin concurrently. S4 awaits S2 and S6, while S5 awaits S2,S3,S6. In particular, the arrows drawn upward from S6 end at S4 and S5; reversing them would implement a different graph. No extra ordering is imposed between incomparable task executions, although a blocked wait can hold a branch until all its own predecessors finish. With terminating tasks and fair scheduling this acyclic dependency system has no synchronization deadlock.
Similar questions1 more → · asked again: GATE 1998, Q1.31
Counting completed semaphore operations
Synchronization & Concurrency
Tap to enlarge
A counting semaphore starts at 7. Twenty P and fifteen V operations complete. What is its final value?
Select all that apply
Answer & solution
Answer: B: 2 (no official key was published)
Each completed P consumes one permit, decreasing the value by one; each V adds one. The net change is −20+15=−5, so the final value is 7−5=2. The word completed matters: blocked, uncompleted waits cannot simply be counted as successful acquisitions in a nonnegative semaphore convention. The stated totals permit an interleaving with enough signals before later waits, so no contradiction is implied by having twenty waits after an initial value of only seven.
Similar questions7 more → · asked again: GATE 1998, Q1.32
Maximum process count with six drives
Deadlocks
Tap to enlarge
Six identical tape drives are shared by n processes, each possibly needing three. What maximum n guarantees no resource deadlock without restrictive allocation?
Select all that apply
Answer & solution
Answer: A: n=2 (no official key was published)
A worst-case deadlock can have every process hold two drives and wait for its third. To rule that out for n processes, at least 2n+1 drives suffice under the standard completion model. With six drives, this requires n≤2. For three processes, each can hold two, exhausting all six and waiting forever. For two processes, their combined maximum demand is six, so both can be fully satisfied. The guarantee assumes eventual completion after required resources are granted and no additional resource types or faulty nontermination.
Similar questions2 more → · asked again: GATE 1998, Q1.29
A spooled device
I/O & Disk Scheduling
Tap to enlarge
Which is a spooled-device example: interactive input terminal, virtual-memory backing store, line printer serving jobs, or none?
Select all that apply
Answer & solution
Answer: C: line printer (no official key was published)
Spooling places jobs in a queue, usually on disk, and lets a dedicated service feed an exclusive sequential device at its own speed. A printer serving several jobs is the standard example: applications finish depositing their output without waiting for physical printing, and each job can be kept separate. A terminal’s interactive input and demand paging have different purposes, even though they may involve buffers or secondary storage. The presence of a buffer alone does not make an operation spooling.
Which page-replacement policy can have more faults when memory size increases?
Answer & solution
Answer: FIFO: Belady’s anomaly (no official key was published)
FIFO evicts the page loaded earliest, not necessarily the least useful page. With different frame counts, the order of subsequent evictions can change so that the larger memory performs worse. For example the reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 has nine FIFO faults with three frames but ten with four. LRU and optimal replacement have the stack-inclusion property and avoid this anomaly. The question asks for a policy that sometimes exhibits it, not a claim that adding frames always hurts FIFO.
Draw the precedence graph for this concurrent program. Within begin/end statements are sequential; parbegin/parend runs its components concurrently and joins them: S1; parbegin begin S2; S4 end; begin S3; parbegin S5; begin S6; S8 end parend end; S7 parend; S9
Answer & solution
Answer: Edges: 1→2,3,7; 2→4; 3→5,6; 6→8; 4,5,8,7→9. (no official key was published)
S1 executes before the outer fork. Its three branches start with S2, S3, and S7. In the first branch S2 precedes S4. In the second branch S3 precedes a nested fork: S5 runs in parallel with the sequential pair S6 then S8. The outer join waits for S4, both S5 and S8, and S7 before permitting S9.
The precedence graph (arrows are immediate dependencies) is:
Its exact edge set is {(S1,S2),(S1,S3),(S1,S7),(S2,S4),(S3,S5),(S3,S6),(S6,S8),(S4,S9),(S5,S9),(S8,S9),(S7,S9)}. This is a transitive reduction: edges such as S1→S9 are implied and need not be drawn. It uses only statement vertices; explicit fork/join vertices would be an equivalent representation.
Do not add S4→S3, S5→S6, or S8→S7: textual order among separate parallel branches does not force execution order. Conversely, S9 must not start after just one branch finishes. The structure imposes control dependencies only; no extra read/write data dependencies are supplied.
With working-set window Δ=4, process the page references c c d b c e c e a d. Initially W(0)={a,d,e}; the latest initial references are a at t=0, d at t=−1, and e at t=−2. Find each working set, the total faults, and average frames used.
Answer & solution
Answer: 5 page faults; average |W(t)| for t=1…10 is 3.2 frames. (no official key was published)
Use the standard discrete-reference window W(t) containing pages referenced at times t−3 through t, i.e. the last four references including the current one. Immediately before reference t, resident pages are W(t−1); a fault occurs exactly when the requested page is absent there. After serving the request, remove pages no longer in the new window. The specified W(0) fixes initial residency; any unspecified t=−3 reference expires at t=1 and does not affect the trace.
t page W(t) size fault?
0 a {a,d,e} 3 initial state
1 c {a,c,d,e} 4 yes
2 c {a,c,d} 3 no
3 d {a,c,d} 3 no
4 b {b,c,d} 3 yes
5 c {b,c,d} 3 no
6 e {b,c,d,e} 4 yes
7 c {b,c,e} 3 no
8 e {c,e} 2 no
9 a {a,c,e} 3 yes
10 d {a,c,d,e} 4 yes
For example at t=6 the four references are d,b,c,e, whereas at t=8 they are c,e,c,e, using only two distinct frames. The last d reference at t=3 has expired by t=7, so d faults again at t=10. Fault times are 1,4,6,9,10: five faults.
The frame sum over the ten requested-reference instants is 4+3+3+3+3+4+3+2+3+4=32, so the conventional post-reference average is 32/10=3.2 frames. If one instead includes the supplied initial snapshot as an eleventh sample, the average is 35/11; if averaging pre-reference residency W(0)…W(9), it is 31/10. These are different sampling conventions, not different working-set traces. The reported 3.2 explicitly averages W(1)…W(10).
What property must a process precedence graph have to be expressed using only properly nested parbegin/parend and sequential composition?
Answer & solution
Answer: It must admit a series-parallel decomposition (no official key was published)
A sequential composition places every process in one component before every process in the next. A parbegin/parend composition runs its child components independently and joins after all finish. Starting from individual processes and repeatedly applying these two constructions yields the series-parallel class of precedence structures. Conversely, its recursive decomposition directly supplies a nested program. An arbitrary acyclic graph can contain cross-dependencies that cannot be represented by these nested constructs alone without extra synchronization or unnecessary ordering. The statement concerns the precedence relation, allowing omission of redundant transitive edges.
Match buddy system, interpretation, virtual memory, pointer with P runtime type checking; Q segmentation; R memory allocation; S garbage collection.
Answer & solution
Answer: Buddy–R; interpretation–P; virtual memory–Q; pointer–S as the intended associations (no official key was published)
Buddy allocation splits power-of-two blocks and merges free buddies, so R is direct. Segmentation is one way to implement a virtual address space, making Q the intended virtual-memory association. Dynamically typed interpreters commonly check types during execution, suggesting P. Pointer reachability underlies tracing garbage collection, suggesting S. The last three are associations, not necessities: interpreters can execute statically typed languages, virtual memory can use paging rather than segmentation, and pointer-supporting languages need not provide garbage collection. The matching should not be promoted into universal implementation laws.
GFG asks false statements: A virtual memory limited by secondary storage; B critical sections require indivisible instructions such as test-and-set; C monitors ensure no deadlock; D LRU may thrash; E best fit prevents fragmentation. Forum omits C and misprints thrashing as hashing.
Select all that apply
Answer & solution
Answer: C and E are false; B is false if it means a special atomic read-modify-write is required; A depends on the memory model (no official key was published)
Monitors enforce mutual exclusion but can still deadlock through circular waits, so C is false. Best fit may leave many tiny holes, so E is false. LRU can thrash when the working set exceeds available frames, so D is true. B needs care: Peterson-style algorithms use atomic reads/writes without test-and-set, refuting a requirement for a special read-modify-write instruction. Yet they still rely on indivisible basic accesses in the usual model, so the broader literal claim about any indivisible instruction is not refuted that way. A conventionally concerns committed backing capacity, not virtual-address-space width. The common intended false set B, C, E is conditional on those readings.
Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat: flag[i] := true while flag[j] or flag[k]: case turn: j: if flag[j]: flag[i] := false while turn != i: skip flag[i] := true k: if flag[k]: flag[i] := false while turn != i: skip flag[i] := true critical section if turn == i: turn := j flag[i] := false noncritical section Does this scheme ensure mutual exclusion? Explain.
Answer & solution
Answer: Yes, under atomic reads/writes and sequential consistency; this does not guarantee progress. (no official key was published)
First separate safety from liveness. A process sets its flag true before testing the outer while condition, and a process admitted to its critical section keeps that flag true until after leaving the critical section. Withdrawing its flag happens only inside the entry loop, never while it is in the critical section.
Suppose two distinct processes p and q were simultaneously in their critical sections. Consider the final assignments flag[p]=true and flag[q]=true preceding these particular admissions. Assume p's assignment occurred first. Its flag remains true from that assignment through its critical section: if it had withdrawn and raised the flag again, the assignment chosen was not final. Process q performs its successful outer test after its own final assignment, hence after p's final assignment. If q enters while p is still inside, q must encounter flag[p]=true and cannot pass the test. If p has already left when q reads false, the two critical sections do not overlap. This contradiction proves mutual exclusion. The argument works with separate atomic flag reads as well: a continuously true competing flag cannot be read as false.
The turn variable controls who backs off, but the persistent true flag is the safety invariant. No fairness assumption is needed for this safety proof. Atomic coherent shared-memory operations are needed; the bare pseudocode is not automatically a correct implementation on a weak-memory machine without suitable synchronization.
Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat: flag[i] := true while flag[j] or flag[k]: case turn: j: if flag[j]: flag[i] := false while turn != i: skip flag[i] := true k: if flag[k]: flag[i] := false while turn != i: skip flag[i] := true critical section if turn == i: turn := j flag[i] := false noncritical section Can a waiting process fail forever to enter? Give an execution and a corrected algorithm.
Answer & solution
Answer: Yes. Two contenders can spin forever when turn names an inactive third process. A three-process bakery lock is a correct replacement. (no official key was published)
Take turn=2, with process 2 remaining in its noncritical section and flag[2]=false. Let processes 0 and 1 both set their flags true before either completes its outer test. Each sees the other's true flag. Its case selects process 2, but the guarded branch sees flag[2]=false, so neither process withdraws or changes turn. They repeat forever, even under fair scheduling of all active processes. Only a critical-section exit changes turn, and neither contender can reach such an exit. Thus progress fails, not merely a timing bound. An inner waiter can also be stranded when turn is handed to an inactive process.
A safe repair is to replace the entire entry/exit protocol with Lamport's bakery algorithm, rather than merely skipping a false flag: false can mean a temporarily withdrawn waiter, not an uninterested process. Use separate choosing and ticket arrays, initially false and zero. Atomic reads/writes and sequential consistency are assumed, and mathematical tickets are unbounded integers.
For process i:
choosing[i] := true
ticket[i] := 1 + max(ticket[0], ticket[1], ticket[2])
choosing[i] := false
for r := 0 to 2, r != i:
while choosing[r]: skip
while ticket[r] != 0 and (ticket[r],r) < (ticket[i],i): skip
critical section
ticket[i] := 0
noncritical section
repeat
Pairs are compared lexicographically, first by ticket and then process number. The choosing flag prevents observing a half-completed ticket selection as if the process were absent. If two processes competed to enter, the one with larger pair must wait for the smaller pair's nonzero ticket; both cannot be inside together. A process which starts choosing after i has published its ticket obtains a larger ticket and cannot overtake i. Only finitely many already competing choices can precede i. Under fair scheduling, finite ticket-selection and critical-section execution, and no process failures, those predecessors finish, so i eventually enters. An inactive process has choosing=false and ticket=0 and is ignored. These assumptions are necessary: no software lock can promise entry if its current owner stops forever.