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 )

  • A

    {(4,4)}

  • B

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

  • C

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

  • D

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

Question 2

Threads are effective only if the CPU is:

  • A

    Multi-core

  • B

    Single-core

  • C

    High speed

  • D

    Idle

Question 3

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

  • A

    Stack

  • B

    Program counter

  • C

    Register set

  • D

    Code section

Question 4

Which component is NOT unique to each thread?

  • A

    Thread ID

  • B

    Program Counter

  • C

    Stack

  • D

    Address space

Question 5

The OS data structure maintained for a thread includes:

( GATE 2016 | MCQ )

  • A

    Page table, open file table, signal table

  • B

    Program counter, register set, stack

  • C

    Both (a) and (b)

  • D

    Only PCB

Question 6

Which statement about threads is TRUE?

( GATE 2023 | MCQ )

  • A

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

  • B

    A thread can exist without a process.

  • C

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

  • D

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

Question 7

Which one of the following is FALSE?

( GATE 2014 | MCQ )

  • A

    User-level threads are not scheduled by the kernel.

  • B

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

  • C

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

  • D

    Kernel-level threads cannot share the code segment.

Question 8

Which of the following is FALSE?

( GATE 2002 | MCQ )

  • A

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

  • B

    Blocking one kernel-level thread blocks all related threads.

  • C

    User-level threads do not require hardware support.

  • D

    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 )

  • A

    OS maintains only CPU registers per thread.

  • B

    OS does not maintain a separate stack per thread.

  • C

    OS does not maintain virtual memory state per thread.

  • D

    OS maintains only scheduling information per thread.

Question 10

Main difference between a process and a thread is:

  • A

    Processes share memory, threads do not

  • B

    Threads share memory, processes do not

  • C

    Threads are heavier than processes

  • D

    Processes are faster to create than threads

There are 12 questions to complete.

Take a part in the ongoing discussion