Thread · Operating System
11 questions · asked in 8 of 27 years (2000–2026)
MCQ 8 · MSQ 31-mark 10 · 2-mark 1
2000Questions per year2026
Questions 1–5 of 11
Which of the following statements about threads is/are TRUE?
One or more options are correct.
Answer: (D)
Let us look at each statement one by one:
- Threads can be built in user space too (user-level threads) FALSE.
- The file descriptor table is part of the process, and all its threads use it together FALSE.
- Each thread has its own stack (and its own registers and PC) FALSE.
- All threads use the same address space, so one thread can read or overwrite the data of another thread. They are not protected from each other TRUE.
Answer: Threads belonging to a process are by default not protected from each other
- Threads can be built in user space too (user-level threads) FALSE.
- The file descriptor table is part of the process, and all its threads use it together FALSE.
- Each thread has its own stack (and its own registers and PC) FALSE.
- All threads use the same address space, so one thread can read or overwrite the data of another thread. They are not protected from each other TRUE.
Answer: Threads belonging to a process are by default not protected from each other
Which one or more of the following need to be saved on a context switch from one thread (T1) of a process to another thread (T2) of the same process?
One or more options are correct.
Answer: (B), (C), (D)
Both threads belong to the same process, so they use the same address space. The page table base register stays the same. It does not need to be saved.
Every thread runs with its own context. This context is the stack pointer, the program counter and the general purpose registers all of these have to be saved.
Answer: Stack pointer, Program counter, General purpose registers
Every thread runs with its own context. This context is the stack pointer, the program counter and the general purpose registers all of these have to be saved.
Answer: Stack pointer, Program counter, General purpose registers
Consider the following multi-threaded code segment (in a mix of C and pseudo-code), invoked by two processes P1 and P2, and each of the processes spawns two threads T1 and T2:
int x = 0; // global
Lock L1; // global
main () {
create a thread to execute foo( ); // Thread T1
create a thread to execute foo( ); // Thread T2
wait for the two threads to finish execution;
print(x);}
foo() {
int y = 0;
Acquire L1;
x = x + 1;
y = y + 1;
Release L1;
print (y);} Which of the following statement(s) is/are correct?One or more options are correct.
Answer: (A), (D)
Let us check each statement:
- P1 and P2 are different processes, so each has its own copy of x. In each process, the two threads add 1 to x while holding the lock so each process prints x = 2.
- y is a local variable of foo, so every thread has its own y that starts at 0 so every thread prints y = 1.
Answer: (A), (D)
- P1 and P2 are different processes, so each has its own copy of x. In each process, the two threads add 1 to x while holding the lock so each process prints x = 2.
- y is a local variable of foo, so every thread has its own y that starts at 0 so every thread prints y = 1.
Answer: (A), (D)
Threads of a process share
Answer: (D)
All threads inside one process use the same address space. This means they share the global variables and the heap. Each thread keeps its own stack and registers.
Answer: Both heap and global variables
Answer: Both heap and global variables
Which of the following is/are shared by all the threads in a process ?
I. Program counter
II. Stack
III. Address space
IV. Registers
I. Program counter
II. Stack
III. Address space
IV. Registers
Answer: (B)
Every thread keeps its own program counter, its own stack and its own registers. The address space is what all threads of one process share. This covers code, data, heap and open files.
Answer: III only
Answer: III only
Keep practising