Thread


Question 1
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?
A
Page table base register
B
Stack pointer
C
Program counter
D
General purpose registers
GATE CSE 2023   Operating System
Question 2
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?
[MSQ]
A
Both P1 and P2 will print the value of x as 2.
B
At least of P1 and P2 will print the value of x as 4.
C
At least one of the threads will print the value of y as 2.
D
Both T1 and T2, in both the processes, will print the value of y as 1.
GATE CSE 2021 SET-2   Operating System


Question 3
Which of the following is/are shared by all the threads in a process ?
I. Program counter
II. Stack
III. Address space
IV. Registers
A
I and II only
B
III only
C
IV only
D
III and IV only
GATE CSE 2017 SET-2   Operating System
Question 4
Threads of a process share
A
global variable but not heap.
B
heap but not global variables.
C
neither global variables nor heap.
D
Both heap and global variables.
GATE CSE 2017 SET-1   Operating System
Question 5
Which one of the following is FALSE?
A
User level threads are not scheduled by the kernel
B
When a user level thread is blocked, all other threads of its process are blocked.
C
Context switching between user level threads is faster than context switching between kernel level threads.
D
Kernel level threads cannot share the code segment
GATE CSE 2014 SET-1   Operating System


There are 5 questions to complete.

Leave a Comment