uiz Space

May 2024 term · Operating Systems · BSCS4022

Operating Systems Quiz 1: 7 July 2024 (May 2024 term)

The IIT Madras BS Operating Systems (Operating Systems) Quiz 1 paper sat on 7 Jul 2024, in the May 2024 term: 19 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
19
Marks
50
Duration
120 min
MCQ
16
MSQ
3

Updated

Official paper: IIT M IMPROVEMENT AN EXAM QIM4 7 July 2024 · No negative marking.

Question 1

+1 markOne correct option

State True or False
In RISC-V, during system calls, the mstatus register stores the current mode of operation of the processor.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 2

+1 markOne correct option

The ecall instruction in the xv6 operating system facilitates the transition of the CPU from user mode to supervisor mode.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 3

+2 marksOne correct option

What is a race condition in an operating system?

  1. A

    Processes racing for CPU resources.

  2. B

    Concurrent access leading to unpredictable results

  3. C

    Incompatible hardware configurations.

  4. D

    System instability due to competing tasks.

Show answer

Correct answer

  • B

    Concurrent access leading to unpredictable results

Question 4

+2 marksOne correct option

What is the primary purpose of the kvminit function in the xv6 operating system?

  1. A

    Initializing the kernel’s virtual memory

  2. B

    Initializing user-level page tables

  3. C

    Configuring the interrupt vector table

  4. D

    Managing process scheduling

Show answer

Correct answer

  • A

    Initializing the kernel’s virtual memory

Question 5

+2 marksOne correct option

State True or False.
The init process, being the first process created by the system, can exit using the exit system call.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 6

+2 marksOne correct option

In the context of xv6 operating systems, what does the zombie state of a process refer to?

  1. A

    A process that has terminated, but whose resources have not yet been deallocated by the operating system.

  2. B

    A process that is suspended and waiting for user input.

  3. C

    A process that is ready to run but is waiting for CPU time.

  4. D

    None of these

Show answer

Correct answer

  • A

    A process that has terminated, but whose resources have not yet been deallocated by the operating system.

Question 7

+2 marksOne correct option

In the xv6 operating system, if a timer interrupt occurs while a process is executing, what will be the state transition of the process?

  1. A

    Running → Sleeping

  2. B

    Running → Unused

  3. C

    Running → Runnable

  4. D

    State remains unchanged

Show answer

Correct answer

  • C

    Running → Runnable

Question 8

+2 marksOne correct option
  1. A

    The number of CPUs supported by xv6 is 64.

  2. B

    The size of each struct proc is 64 bytes.

  3. C

    The array proc can dynamically resize to handle more than 64 processes.

  4. D

    The system can handle a maximum of 64 processes simultaneously.

Show answer

Correct answer

  • D

    The system can handle a maximum of 64 processes simultaneously.

Question 9

+3 marksOne correct option

If the memory map for a device starts from the offset 0x30004000 and has a size of 512 bytes in a 32-bit addressing scheme, what will be the last address in the memory map?

  1. A

    0x30004100

  2. B

    0x300041FF

  3. C

    0x30004200

  4. D

    0x30003FFF

Show answer

Correct answer

  • B

    0x300041FF

Question 10

+3 marksOne correct option

Consider the code segment given below.

c
#define PERIPHERAL_BASE 0x40000000
void init_peripheral(){
uint16_t *control_reg = (uint16_t*)(PERIPHERAL_BASE + 4);
*control_reg = 0x1234;
}
uint32_t read_data(){
uint32_t *data_reg = (uint32_t*)(PERIPHERAL_BASE + 8);
uint8_t *status_reg = (uint8_t*)(PERIPHERAL_BASE + 12);
while((*status_reg & 0x2) == 0);
return *data_reg;
}

Identify the correct sizes of control register, data register, and status register.

  1. A

    Sizes of all the registers are 4-byte.

  2. B

    Sizes of control register, data register, and status register are 2-byte, 4-byte, and 1-byte respectively.

  3. C

    Sizes of control register, data register, and status register are 2-byte, 4-byte, and 2-byte respectively.

  4. D

    Sizes of control register, data register, and status register are 16-byte, 32-byte, and 8-byte respectively.

Show answer

Correct answer

  • B

    Sizes of control register, data register, and status register are 2-byte, 4-byte, and 1-byte respectively.

Question 11

+3 marksOne correct option

What does the following xv6 code snippet accomplish?

c
int pid;
pid = fork();
if (pid > 0){
pid = wait();
} else{
execlp("pwd", "", NULL);
exit(0);
}
  1. A

    Both the parent and child processes execute the pwd command concurrently.

  2. B

    The parent process waits for the child process to finish executing the pwd command.

  3. C

    The parent process executes the pwd command and then waits for the child process to finish.

  4. D

    None of these

Show answer

Correct answer

  • B

    The parent process waits for the child process to finish executing the pwd command.

Question 12

+3 marksOne correct option

What is the correct sequence of setting up first user process?
(i) Find an unused proc entry.
(ii) Create trapframe.
(iii) Create empty user process page table.
(iv) Create context for process.

  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

  • A

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

Question 13

+3 marksOne correct option

Consider a process P1 that forks P2, P2 forks P3, and P3 forks P4. P1 and P2 continue to execute while P3 terminates. Now, what is the parent process of P4?

  1. A

    Process P1

  2. B

    Process P2

  3. C

    Process init

  4. D

    None of these

Show answer

Correct answer

  • C

    Process init

Question 14

+3 marksOne correct option

Consider the below code for the syscall function in kernel/syscall.c.

c
1 void
2 syscall(void)
3 {
4 int num;
5 struct proc *p = myproc();
6
7 num = p->tf->a7;
8 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
9 p->tf->a0 = syscalls[num]();
10 } else {
11 printf("%d %s: unknown sys call %d\n",
12 p->pid, p->name, num);
13 p->tf->a0 = -1;
14 }
15 }

What value is stored in the a7 register of the trapframe?

  1. A

    The return address of the user space

  2. B

    The number that is returned to the user space.

  3. C

    The number that identifies the system call.

  4. D

    The number that identifies the process

Show answer

Correct answer

  • C

    The number that identifies the system call.

Question 15

+3 marksOne or more correct options

Which of the following actions are performed by userinit?

Select all that apply.

  1. A

    It creates a page directory.

  2. B

    It invokes procinit.

  3. C

    It sets the process to a sleeping state.

  4. D

    It allocates a process id and trapframe.

  5. E

    It creates a user stack at 0X0.

Show answer

Correct answers

  • A

    It creates a page directory.

  • D

    It allocates a process id and trapframe.

Question 16

+3 marksOne or more correct options

Assume Process P2 and Process P4 are waiting for an input, Process P1 is running, and Process P3 was running before Process P1 and is now waiting for its turn to run. Select all the correct statements about the states of the processes.

Select all that apply.

  1. A

    Process P2 is in the RUNNABLE state

  2. B

    Process P4 is in the SLEEPING state.

  3. C

    Process P1 is in the RUNNING state.

  4. D

    Process P3 is in the SLEEPING state.

  5. E

    Process P3 is in the RUNNABLE state.

Show answer

Correct answers

  • B

    Process P4 is in the SLEEPING state.

  • C

    Process P1 is in the RUNNING state.

  • E

    Process P3 is in the RUNNABLE state.

Question 17

+4 marksOne correct option

Consider a system with a virtual memory space size of 8 GB and a single page table with 2¹⁸ entries. What is the size of each page frame?

  1. A

    32 MB

  2. B

    64 KB

  3. C

    16 KB

  4. D

    32 KB

Show answer

Correct answer

  • D

    32 KB

Question 18

+4 marksOne correct option

Consider a system with 64 MB of physical memory and a 32-bit virtual address space. Given a page size of 4 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 19

+4 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 = 20;
pid = fork();
if (pid == 0) {
printf("Parent\t %d\n", a);
} else {
printf("Child\t %d\n", a);
a = 15;
printf("Child\t %d\n", a);
}
return 0;
}

Select all that apply.

  1. A

    Child 20
    Child 15
    Parent 15

  2. B

    Child 20
    Child 15
    Parent 20

  3. C

    Parent 20
    Child 20
    Child 15

  4. D

    Parent 15
    Child 20
    Child 15

Show answer

Correct answers

  • B

    Child 20
    Child 15
    Parent 20

  • C

    Parent 20
    Child 20
    Child 15