Threads in Operating Systems

    Last Updated :
    Discuss
    Comments

    Question 1

    Consider the following two threads T1 and T2. Initially, a = b = 1. Each statement executes atomically.

    C++
    T1: a = a + 1;
        b = b + 1;
    
    T2: b = 2 * b;
        a = 2 * a;
    

    Which lists all possible values of (a, b) after both threads finish?

    ( GATE 2020 | MCQ )

    • {(4,4)}

    • {(3,3), (4,4)}

    • {(3,3), (4,4), (3,4), (4,3)}

    • {(2,2), (2,4), (3,3), (3,4), (4,3), (4,4)}

    Question 2

    Threads are effective only if the CPU is:

    • Multi-core

    • Single-core

    • High speed

    • Idle

    Question 3

    Which of the following is shared among all threads in a process?

    • Stack

    • Program counter

    • Register set

    • Code section

    Question 4

    Which component is NOT unique to each thread?

    • Thread ID

    • Program Counter

    • Stack

    • Address space

    Question 5

    The OS data structure maintained for a thread includes:

    ( GATE 2016 | MCQ )

    • Page table, open file table, signal table

    • Program counter, register set, stack

    • Both (a) and (b)

    • Only PCB

    Question 6

    Which statement about threads is TRUE?

    ( GATE 2023 | MCQ )

    • Two threads of the same process cannot run simultaneously on a single-core CPU.

    • A thread can exist without a process.

    • Threads share address space but have separate stacks and program counters.

    • Switching threads of different processes is cheaper than within the same process.

    Question 7

    Which one of the following is FALSE?

    ( GATE 2014 | MCQ )

    • User-level threads are not scheduled by the kernel.

    • When a user-level thread is blocked, all threads of the process are blocked.

    • Context switching between user-level threads is faster than between kernel-level threads.

    • Kernel-level threads cannot share the code segment.

    Question 8

    Which of the following is FALSE?

    ( GATE 2002 | MCQ )

    • Context switching is slower for kernel-level threads than user-level threads.

    • Blocking one kernel-level thread blocks all related threads.

    • User-level threads do not require hardware support.

    • Kernel-level threads can run on different processors.

    Question 9

    A thread is called a lightweight process because it shares resources with other threads. Which of the following is TRUE?

    ( GATE 2011 | MCQ )

    • OS maintains only CPU registers per thread.

    • OS does not maintain a separate stack per thread.

    • OS does not maintain virtual memory state per thread.

    • OS maintains only scheduling information per thread.

    Question 10

    Main difference between a process and a thread is:

    • Processes share memory, threads do not

    • Threads share memory, processes do not

    • Threads are heavier than processes

    • Processes are faster to create than threads

    There are 12 questions to complete.

    Take a part in the ongoing discussion