GATE 2025 (Session 1)
65 questions
MCQ 30 · MSQ 13 · NAT 221-mark 30 · 2-mark 35
Questions 11–15 of 65
Suppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives:
(i) The processor saves the content of the program counter.
(ii) The program counter is loaded with the start address of the ISR.
(iii) The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
(i) The processor saves the content of the program counter.
(ii) The program counter is loaded with the start address of the ISR.
(iii) The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
Answer: (A)
When an asynchronous interrupt arrives, the processor must first get to a safe state. Only then can it hand over control:
1. (iii) The processor finishes the present instruction — an interrupt is served only at the end of an instruction, never in the middle of one.
2. (i) The processor saves the content of the program counter — this lets the program continue later from the same place.
3. (ii) The program counter is loaded with the start address of the ISR — at this point control moves to the ISR.
Answer: (iii), (i), (ii)
1. (iii) The processor finishes the present instruction — an interrupt is served only at the end of an instruction, never in the middle of one.
2. (i) The processor saves the content of the program counter — this lets the program continue later from the same place.
3. (ii) The program counter is loaded with the start address of the ISR — at this point control moves to the ISR.
Answer: (iii), (i), (ii)
Which ONE of the following statements is FALSE regarding the symbol table?
Answer: (C)
Let us check each statement about the symbol table:
- It keeps track of the scope of variables — true. This is one of its main jobs.
- It can be built with a BST — true. BSTs (or hash tables) are common ways to build it.
- It is created during lexical analysis — true. Entries are usually first added when identifiers are tokenized.
- "Symbol table is not required after the parsing phase" — FALSE. The symbol table is needed long after parsing. Semantic analysis (type checking), intermediate code generation and code optimization (for example register allocation) all keep using it.
Answer: "Symbol table is not required after the parsing phase" is FALSE.
- It keeps track of the scope of variables — true. This is one of its main jobs.
- It can be built with a BST — true. BSTs (or hash tables) are common ways to build it.
- It is created during lexical analysis — true. Entries are usually first added when identifiers are tokenized.
- "Symbol table is not required after the parsing phase" — FALSE. The symbol table is needed long after parsing. Semantic analysis (type checking), intermediate code generation and code optimization (for example register allocation) all keep using it.
Answer: "Symbol table is not required after the parsing phase" is FALSE.
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
Answer: (B)
Live variable analysis finds, at every point in the program, the variables whose current values may be used later. These variables are called "live".
This is the very information needed to choose which variables should stay in fast registers and which can safely be removed from them. That is the main idea of register allocation/assignment.
Run-time function call management, strength reduction and constant folding are all real optimizations. But none of them depends on liveness information as much as register allocation does.
Answer: Register assignment to variables
This is the very information needed to choose which variables should stay in fast registers and which can safely be removed from them. That is the main idea of register allocation/assignment.
Run-time function call management, strength reduction and constant folding are all real optimizations. But none of them depends on liveness information as much as register allocation does.
Answer: Register assignment to variables
Consider a demand paging memory management system with 32-bit logical address, 20-bit physical address, and page size of 2048 bytes. Assuming that the memory is byte addressable, what is the maximum number of entries in the page table?
Answer: (A)
The page size bytes. So the offset field of the page needs bits.
The logical address has bits. The bits left over make the page number: bits.
The page table has one entry for each possible page number. So the maximum number of entries .
Answer:
The logical address has bits. The bits left over make the page number: bits.
The page table has one entry for each possible page number. So the maximum number of entries .
Answer:
A schedule of three database transactions , , and is shown. and denote read and write of data item by transaction , . The transaction aborts at the end. Which other transaction(s) will be required to be rolled back?
Answer: (C)
The schedule is: .
Before it aborts, writes . Any transaction that reads this value of afterward has read "dirty" data. That transaction must be rolled back too (cascading rollback).
- does after . So it reads the uncommitted write of . must roll back.
- also does later. No other transaction wrote in between, because only read it. So also reads the dirty value of . must roll back too.
Answer: Both T2 and T3
Before it aborts, writes . Any transaction that reads this value of afterward has read "dirty" data. That transaction must be rolled back too (cascading rollback).
- does after . So it reads the uncommitted write of . must roll back.
- also does later. No other transaction wrote in between, because only read it. So also reads the dirty value of . must roll back too.
Answer: Both T2 and T3