Thread

Question 1
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 2
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 3
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 4
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
Question 5
A thread is usually defined as a 'light weight process' because an operating system (OS) maintains smaller data structures for a thread than for a process. In relation to this, which of the followings is TRUE?
A
On per-thread basis, the OS maintains only CPU register state
B
The OS does not maintain a separate stack for each thread
C
On per-thread basis, the OS does not maintain virtual memory state
D
On per thread basis, the OS maintains only scheduling and accounting information
GATE CSE 2011   Operating System
Question 6
Let the time taken to switch between user and kernel modes of execution be t1 while the time taken to switch between two processes be t2. Which of the following is TRUE?
A
t_{1}\gt t_{2}
B
t_{1}=t_{2}
C
t_{1}\lt t_{2}
D
Nothing can be said about the relation between t1 and t2
GATE CSE 2011   Operating System
Question 7
Consider the following statements about user level threads and kernel level threads. Which one of the following statements is FALSE?
A
Context switch time is longer for kernel level threads than for user level threads.
B
User level threads do not need any hardware support.
C
Related kernel level threads can be scheduled on different processors in a multi-processor system.
D
Blocking one kernel level thread blocks all related threads.
GATE CSE 2007   Operating System
Question 8
Which one of the following is NOT shared by the threads of the same process ?
A
Stack
B
Address Space
C
File Descriptor Table
D
Message Queue
GATE IT 2004   Operating System
Question 9
Consider the following statements with respect to user-level threads and kernel-supported threads

(i) context switch is faster with kernel-supported threads
(ii) for user-level threads, a system call can block the entire process
(iii) Kernel supported threads can be scheduled independently
(iv) User level threads are transparent to the kernel
Which of the above statements are true?
A
(ii), (iii) and (iv) only
B
(ii) and (iii) only
C
(i) and (iii) only
D
(i) and (ii) only
GATE CSE 2004   Operating System
There are 9 questions to complete.

Leave a Comment

Like this FREE website? Please share it among all your friends and join the campaign of FREE Education to ALL.