GATE 2024 (Session 2)
65 questions
MCQ 32 · MSQ 18 · NAT 151-mark 30 · 2-mark 35
Questions 21–25 of 65
Consider the following two sets:
Which one of the following options is the CORRECT match from Set X to Set Y ?
Which one of the following options is the CORRECT match from Set X to Set Y ?
Answer: (B)
What each compiler phase gives or uses:
- P. Lexical Analyzer gives tokens (2)
- Q. Syntax Analyzer gives a parse tree (3)
- R. Intermediate Code Generator uses the abstract syntax tree / IR (1)
- S. Code Optimizer does constant folding (4)
Answer: P-2; Q-3; R-1; S-4
- P. Lexical Analyzer gives tokens (2)
- Q. Syntax Analyzer gives a parse tree (3)
- R. Intermediate Code Generator uses the abstract syntax tree / IR (1)
- S. Code Optimizer does constant folding (4)
Answer: P-2; Q-3; R-1; S-4
Which one of the following regular expressions is equivalent to the language accepted by the DFA given below?
Answer: (A)
In the DFA, 0 keeps the state, and 1 switches between the start state and the final state. So it accepts the strings with an odd number of 1s.
Check : stays at the start state, the first 1 moves to the final state, and then each is the loop at the final state, while each goes back to the start state, loops on 0s, and returns to the final state. Every string with an odd number of 1s is split this way, so (A) matches the DFA.
Why the others fail:
- (B) gives the empty string (zero 1s, so the DFA rejects it) and never gives "1" (every block has three 1s).
- (C) cannot give "111", which has three 1s: after the first 1, every next block starts with 0.
- (D) must start with 0, so it cannot give "1".
Answer: (A)
Check : stays at the start state, the first 1 moves to the final state, and then each is the loop at the final state, while each goes back to the start state, loops on 0s, and returns to the final state. Every string with an odd number of 1s is split this way, so (A) matches the DFA.
Why the others fail:
- (B) gives the empty string (zero 1s, so the DFA rejects it) and never gives "1" (every block has three 1s).
- (C) cannot give "111", which has three 1s: after the first 1, every next block starts with 0.
- (D) must start with 0, so it cannot give "1".
Answer: (A)
Node X has a TCP connection open to node Y. The packets from X to Y go through an intermediate IP router R. Ethernet switch S is the first switch on the network path between X and R. Consider a packet sent from X to Y over this connection.
Which of the following statements is/are TRUE about the destination IP and MAC addresses on this packet at the time it leaves X?
Which of the following statements is/are TRUE about the destination IP and MAC addresses on this packet at the time it leaves X?
One or more options are correct.
Answer: (B)
Recall how the addresses change along the path:
- IP addresses work end-to-end, so the destination IP stays the IP of Y on the whole path.
- MAC addresses work hop-by-hop, so the destination MAC is that of the next IP hop, which is router R. A switch only forwards frames, and it is never the destination MAC.
So the only true statement is: destination IP = IP of Y.
Answer: The destination IP address is the IP address of Y
- IP addresses work end-to-end, so the destination IP stays the IP of Y on the whole path.
- MAC addresses work hop-by-hop, so the destination MAC is that of the next IP hop, which is router R. A switch only forwards frames, and it is never the destination MAC.
So the only true statement is: destination IP = IP of Y.
Answer: The destination IP address is the IP address of Y
Which of the following tasks is/are the responsibility/responsibilities of the memory management unit (MMU) in a system with paging-based memory management?
One or more options are correct.
Answer: (B), (C), (D)
The MMU is a hardware unit placed between the CPU and the memory. Check each option:
- (A) The OS (software) allocates a page table for a new process when it creates the process. The MMU does not do this. Not its job.
- (B) The MMU translates a virtual address to a physical address by using the page table. True.
- (C) It raises a trap (page fault) when the page table entry is invalid or not present. True.
- (D) It raises a trap when a write is tried on a read-only page. True.
Answer: (B), (C), (D)
- (A) The OS (software) allocates a page table for a new process when it creates the process. The MMU does not do this. Not its job.
- (B) The MMU translates a virtual address to a physical address by using the page table. True.
- (C) It raises a trap (page fault) when the page table entry is invalid or not present. True.
- (D) It raises a trap when a write is tried on a read-only page. True.
Answer: (B), (C), (D)
Consider a process P running on a CPU. Which one or more of the following events will always trigger a context switch by the OS that results in process P moving to a non-running state (e.g., ready, blocked)?
One or more options are correct.
Answer: (A), (B)
- (A) A blocking disk read makes P wait for the I/O, so the OS moves P to the blocked state and switches to another process. This always happens.
- (B) A page fault on a page in swap space means the page must be read from disk. P waits for it, so it is blocked and a context switch always happens.
- (C) A disk interrupt for another process is handled by the OS, which makes that process ready. P can keep running, so this does not always switch P out.
- (D) On a timer interrupt, P may still have time left in its slice, or the scheduler may pick P again. So P does not always leave the running state.
Answer: (A), (B)
- (B) A page fault on a page in swap space means the page must be read from disk. P waits for it, so it is blocked and a context switch always happens.
- (C) A disk interrupt for another process is handled by the OS, which makes that process ready. P can keep running, so this does not always switch P out.
- (D) On a timer interrupt, P may still have time left in its slice, or the scheduler may pick P again. So P does not always leave the running state.
Answer: (A), (B)