uiz Space

January 2024 term · Operating Systems · BSCS4022

Operating Systems Quiz 1: 25 February 2024 (January 2024 term)

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term: 22 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
22
Marks
50
Duration
120 min
MCQ
18
MSQ
3
Numerical
1

Updated

Official paper: IIT M DEGREE AN2 EXAM QDB2 25 Feb 2024 · No negative marking.

Question 1

+1 markOne correct option

In monolithic kernels, there is direct communication between modules in the kernel by procedure calls.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 2

+1 markOne correct option

The _entry function in an operating system kernel like xv6 is called by each CPU core individually during the boot process, and it initializes the stack for each CPU core separately.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 3

+1 markOne correct option

“Daemons are deliberate orphan processes that become detached from user sessions and operate in the background.”

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 4

+2 marksOne correct option

If the memory map for the interrupt controller starts from the offset 0x20000000 and has a size of 256 bytes in a 32-bit addressing scheme then what will be the last address in the memory map?

  1. A

    0x200000FF

  2. B

    0x20000100

  3. C

    0x200001FF

  4. D

    0x20000200

Show answer

Correct answer

  • A

    0x200000FF

Question 5

+2 marksOne correct option

Which instruction in the xv6 operating system facilitates the transition of the CPU from user mode to supervisor mode?

  1. A

    jmp

  2. B

    syscall

  3. C

    ecall

  4. D

    None of these

Show answer

Correct answer

  • C

    ecall

Question 6

+2 marksOne correct option
  1. A

    It is the memory address where the proc array begins.

  2. B

    It is the total number of processes launched since the system boot.

  3. C

    It is the number of CPU cores available to xv6.

  4. D

    It is the maximum number of concurrent processes supported.

Show answer

Correct answer

  • D

    It is the maximum number of concurrent processes supported.

Question 7

+2 marksOne correct option
  1. A

    Managing process states

  2. B

    Handling timer interrupts

  3. C

    Managing system resources

  4. D

    Storing the return address for function calls

Show answer

Correct answer

  • D

    Storing the return address for function calls

Question 8

+2 marksOne correct option

What is the correct sequence of tasks that takes place as part of memory initializationof the xv6 kernel before turning on paging?
(i) Creation of page frames
(ii) Creation of page tables for kernel
(iii) Add each chunk of 4KB physical memory to the freelist
(iv) Set the page table bits in the satp register

  1. A

    (i) → (ii) → (iii) → (iv)

  2. B

    (i) → (iii) → (ii) → (iv)

  3. C

    (ii) → (i) → (iii) → (iv)

  4. D

    (ii) → (i) → (iv) → (iii)

Show answer

Correct answer

  • B

    (i) → (iii) → (ii) → (iv)

Question 9

+2 marksOne correct option

Select the incorrect statements regarding the exit function.

  1. A

    The exit function sets the state of the current process to ZOMBIE.

  2. B

    The exit function reparents the child processes to the init process using the reparent function.

  3. C

    The exit function changes the context of the current process to the parent process by returning the exit status to the wait function of the parent.

  4. D

    The exit function is responsible for closing all the opened files using fileclose function.

Show answer

Correct answer

  • C

    The exit function changes the context of the current process to the parent process by returning the exit status to the wait function of the parent.

Question 10

+2 marksOne correct option

Select all the incorrect statements regarding the wait function.

  1. A

    wait function runs an infinite loop until all the child processes of the parent are terminated.

  2. B

    wait function returns when it finds a terminated child process.

  3. C

    wait function returns the exit status of the child to the parent.

  4. D

    wait function returns the pid of the terminated child.

Show answer

Correct answer

  • A

    wait function runs an infinite loop until all the child processes of the parent are terminated.

Question 11

+3 marksOne correct option
  1. A

    stack0 + 3 + 4 * 1024

  2. B

    stack0 + 3 * 4* 1024

  3. C

    stack0 + 2 * 4 * 1024

  4. D

    stack0 + 2 + 4 * 1024

Show answer

Correct answer

  • C

    stack0 + 2 * 4 * 1024

Question 12

+3 marksOne correct option

Consider the size of the virtual memory space is 4 GB, and the number of entries in the page table is 2²¹. What is the size of each page frame?

  1. A

    3MB

  2. B

    3KB

  3. C

    6KB

  4. D

    6MB

Show answer

Correct answer

  • B

    3KB

Question 13

+3 marksOne correct option

Consider the following lines of code. Identify the TRUE statements.

c
int i=0, pid;
pid = fork();
if (pid > 0){
sleep(1);
printf("parent : %d\n", i);
wait();
} else{
i = i + 1;
printf("child : %d\n", i);
}

Figure 1:

(i) Output is parent : 0 child : 1
(ii) In the parent process, fork returns child pid, and in the child process, fork returns 0 (iii) wait returns the PID of an exiting parent process
(iv) When fork is called, all pages are easily shared between parent and child by copying the parent’s page tables

  1. A

    (i), (ii), and (iii)

  2. B

    (i), (iii), and (iv)

  3. C

    (i), (ii), and (iv)

  4. D

    (ii), (iii), and (iv)

Show answer

Correct answer

  • C

    (i), (ii), and (iv)

Question 14

+3 marksOne correct option

Find the correct match for the following functions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 15

+3 marksOne correct option

Consider a system with 32 MB of physical memory and a 32-bit virtual address space. Given a page size of 2 KB, what will be the number of frames?

  1. A

    2³² frames

  2. B

    2¹⁴ frames

  3. C

    2²⁰ frames

  4. D

    2¹⁵ frames

Show answer

Correct answer

  • B

    2¹⁴ frames

Question 16

+2 marksOne or more correct options

Assume process A is waiting for an input, process B is running, and process C was running before process B and is now waiting for its turn to run. Select all the correct statements from below.

Select all that apply.

  1. A

    A is in RUNNABLE state

  2. B

    A is in SLEEPING state

  3. C

    C is in RUNNABLE state

  4. D

    C is in SLEEPING state

Show answer

Correct answers

  • B

    A is in SLEEPING state

  • C

    C is in RUNNABLE state

Question 17

+2 marksOne or more correct options

Select all the correct statements about the first process in xv6 (sbin/init).

Select all that apply.

  1. A

    init process uses fork system call to create child processes and loads the other programs using exec system call in the child processes.

  2. B

    The init process uses the exec system call to create child processes.

  3. C

    init process is created by a fork system call using ecall instruction.

  4. D

    init process is created by an exec system call using ecall instruction.

Show answer

Correct answers

  • A

    init process uses fork system call to create child processes and loads the other programs using exec system call in the child processes.

  • D

    init process is created by an exec system call using ecall instruction.

Question 18

+3 marksOne or more correct options

Which of the following can be possible output of the following lines of code?

c
#include<stdio.h>
#include<stdlib.h>
int main() {
int a, pid;
a = 30;
pid = fork();
if(pid == 0)
{
printf("Parent\t %d\n", a);
}
else {
printf("Child\t %d\n", a);
a = 25;
printf("Child\t %d\n", a);
}
return 0;
}

Figure 2:

Select all that apply.

  1. A

    Child 30
    Child 25
    Parent 30

  2. B

    Child 30
    Child 25
    Parent 25

  3. C

    Parent 30
    Child 30
    Child 25

  4. D

    Parent 25
    Child 30
    Child 25

Show answer

Correct answers

  • A

    Child 30
    Child 25
    Parent 30

  • C

    Parent 30
    Child 30
    Child 25

Question 19

+2 marksOne correct option

Consider the code segment (for xv6) given below.

c
1 #define UART_BASE 0xA0004000
2
3 void init_uart(){
4 u16 *baud_reg = (u16*)UART_BASE;
5 *baud_reg = 0x7D;
6 }
7 u32 read_uart(){
8 u32 *rx_reg = (u32*)(UART_BASE + 8);
9 u8 *status_reg = (u8*)(UART_BASE + 12);
10 while((*status_reg & 0x4) == 0);
11 return *rx_reg;
12 }

In the code above baud_reg, rx_reg, and status_reg are the pointers to baud register, RX register and status register, respectively.

Based on the above data, answer the given subquestions.

  1. A

    The base address is 0x00000000, and content is 0x0000.

  2. B

    The base address is 0x00000000, and content is 0x7D.

  3. C

    The base address is 0xA0004000, and content is 0x0000.

  4. D

    The base address is 0xA0004000, and content is 0x007D.

Show answer

Correct answer

  • D

    The base address is 0xA0004000, and content is 0x007D.

Question 20

+3 marksOne correct option

Consider the code segment (for xv6) given below.

c
1 #define UART_BASE 0xA0004000
2
3 void init_uart(){
4 u16 *baud_reg = (u16*)UART_BASE;
5 *baud_reg = 0x7D;
6 }
7 u32 read_uart(){
8 u32 *rx_reg = (u32*)(UART_BASE + 8);
9 u8 *status_reg = (u8*)(UART_BASE + 12);
10 while((*status_reg & 0x4) == 0);
11 return *rx_reg;
12 }

In the code above baud_reg, rx_reg, and status_reg are the pointers to baud register, RX register and status register, respectively.

Based on the above data, answer the given subquestions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 21

+3 marksNumerical answer

Consider the following code for kvminit function in vm. c.

c
1 void
2 kvminit()
3 {
4 kernel_pagetable = (pagetable_t) kalloc();
5 memset(kernel_pagetable, 0, PGSIZE);
6
7 kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W);
8
9 kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);
10
11 kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);
12
13 kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);
14
15 kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);
16
17 kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
18
19 kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
20
21 kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
22 }

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 1024

Question 22

+3 marksOne correct option

Consider the following code for kvminit function in vm. c.

c
1 void
2 kvminit()
3 {
4 kernel_pagetable = (pagetable_t) kalloc();
5 memset(kernel_pagetable, 0, PGSIZE);
6
7 kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W);
8
9 kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);
10
11 kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);
12
13 kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);
14
15 kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);
16
17 kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
18
19 kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
20
21 kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
22 }

Based on the above data, answer the given subquestions.

What will be the values of the first 5 bits (from the right) of the page table entry after the execution of kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R |PTE_X); .

  1. A

    01110

  2. B

    10111

  3. C

    01011

  4. D

    10110

Show answer

Correct answer

  • C

    01011