GATE 2021 (Session 1)
65 questions
MCQ 34 · MSQ 13 · NAT 181-mark 30 · 2-mark 35
Questions 21–25 of 65
In the context of operating systems, which of the following statements is/are correct with respect to paging?
One or more options are correct.
Answer: (A), (C)
Check every option:
- (A) Any free frame can hold any page, so paging gives no external fragmentation. TRUE.
- (B) With larger pages, more space is wasted in the last page of a process (internal fragmentation). So page size does have an impact. FALSE.
- (C) Page tables use memory (and paging also needs the TLB and extra memory accesses). TRUE.
- (D) Multi-level paging is used to make page tables smaller. It is not used to support different page sizes. FALSE.
Answer: (A), (C)
- (A) Any free frame can hold any page, so paging gives no external fragmentation. TRUE.
- (B) With larger pages, more space is wasted in the last page of a process (internal fragmentation). So page size does have an impact. FALSE.
- (C) Page tables use memory (and paging also needs the TLB and extra memory accesses). TRUE.
- (D) Multi-level paging is used to make page tables smaller. It is not used to support different page sizes. FALSE.
Answer: (A), (C)
Let < M > denote an encoding of an automaton M. Suppose that . Which of the following languages is/are NOT recursive?
One or more options are correct.
Answer: (D)
A language is recursive when some Turing machine decides it. Go through each case:
- (A) DFA emptiness: see if any final state can be reached from the start state this is decidable.
- (B) DFA universality: swap the final and non-final states to get the complement DFA, and test it for emptiness this is decidable.
- (C) PDA emptiness: change the PDA into a CFG and see if S generates any string this is decidable.
- (D) PDA universality (): it is undecidable, so this language is not recursive. The reason is a reduction from Turing machine acceptance. For a Turing machine and input , the strings that are not an accepting computation history of on form a context-free language, because a PDA can check for a wrong step in the sequence of configurations. This language is all of exactly when does not accept . A decider for PDA universality would then decide Turing machine acceptance, which is impossible.
Answer: (D)
- (A) DFA emptiness: see if any final state can be reached from the start state this is decidable.
- (B) DFA universality: swap the final and non-final states to get the complement DFA, and test it for emptiness this is decidable.
- (C) PDA emptiness: change the PDA into a CFG and see if S generates any string this is decidable.
- (D) PDA universality (): it is undecidable, so this language is not recursive. The reason is a reduction from Turing machine acceptance. For a Turing machine and input , the strings that are not an accepting computation history of on form a context-free language, because a PDA can check for a wrong step in the sequence of configurations. This language is all of exactly when does not accept . A decider for PDA universality would then decide Turing machine acceptance, which is impossible.
Answer: (D)
Suppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the database either during the transactions or during recovery.
Which of the following statements is/are correct?
Which of the following statements is/are correct?
One or more options are correct.
Answer: (A)
With no checkpoints, recovery always begins from the log. Idempotent means that doing undo and redo again gives the same result. So after a second crash, the system builds the same undo and redo lists from the log and applies them again.
Recovery is still possible, and the database stays consistent.
Answer: The same undo and redo list will be used while recovering again
Recovery is still possible, and the database stays consistent.
Answer: The same undo and redo list will be used while recovering again
Which of the following standard C library functions will always invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?
One or more options are correct.
Answer: (A), (C)
Let us look at each function:
- exit: it has to ask the kernel to end the process so it is always a system call.
- sleep: it has to ask the kernel to suspend the process so it is always a system call.
- malloc: it is often served from heap memory that is already allocated. It calls brk/mmap only some of the time.
- strlen: it is a pure user-space computation.
Answer: exit, sleep
- exit: it has to ask the kernel to end the process so it is always a system call.
- sleep: it has to ask the kernel to suspend the process so it is always a system call.
- malloc: it is often served from heap memory that is already allocated. It calls brk/mmap only some of the time.
- strlen: it is a pure user-space computation.
Answer: exit, sleep
Consider a linear list based directory implementation in a file system. Each directory is a list of nodes, where each node contains the file name along with the file metadata, such as the list of pointers to the data blocks. Consider a given directory foo.
Which of the following operations will necessarily require a full scan of foo for successful completion?
Which of the following operations will necessarily require a full scan of foo for successful completion?
One or more options are correct.
Answer: (A), (C)
Let us look at each operation:
- Create: we must make sure no file with the same name is already there so the whole list is scanned.
- Rename: we must make sure the new name is not already in use so the whole list is scanned.
- Delete or open an existing file: the search ends once the file is found so a full scan is not always needed.
Answer: Creation of a new file, Renaming of an existing file
- Create: we must make sure no file with the same name is already there so the whole list is scanned.
- Rename: we must make sure the new name is not already in use so the whole list is scanned.
- Delete or open an existing file: the search ends once the file is found so a full scan is not always needed.
Answer: Creation of a new file, Renaming of an existing file