In an operating system, what resources are consumed when a new thread is created, and how does this differ from the resources needed when a new process is created?

Difficulty: Medium

Correct Answer: A new thread gets its own stack and register context but shares code, data and open files with its process, while a new process receives a separate address space and its own resources.

Explanation:


Introduction / Context:
Many modern operating systems support both processes and threads as units of execution. Understanding the resource cost of creating a thread compared to creating a process is essential for system design and performance tuning. This question tests your conceptual knowledge of how threads share resources within a process and why thread creation is usually considered lighter than process creation.


Given Data / Assumptions:

  • The operating system supports multithreading within a process.
  • Processes have their own virtual address spaces and process control blocks.
  • Threads within the same process can share many resources.
  • No numerical calculations are needed, only conceptual reasoning.


Concept / Approach:
A process is a heavy weight unit that includes a private virtual address space, code, data, heap, stack segments and kernel maintained process control structures. When a new process is created, the kernel must allocate and initialise a new address space and a full set of control structures, which is relatively expensive. A thread, on the other hand, is a light weight execution context within a process. Threads share the process address space, code and open file descriptors but have their own stack, program counter and register set. Therefore a new thread consumes fewer resources and is created faster than a new process.


Step-by-Step Solution:
Step 1: Recall that a process owns the address space and global resources like open files and signal handlers. Step 2: Recall that threads exist inside a process and share the same address space and global resources. Step 3: Identify the minimal resources unique to each thread, such as its stack, program counter and register context. Step 4: Compare this with process creation, where the kernel must allocate a fresh address space and duplicate or map code and data segments. Step 5: Choose the option that correctly states that threads share code, data and open files, while processes do not.


Verification / Alternative check:
Standard operating systems textbooks describe threads as light weight processes that share an address space. Many programming interfaces, such as POSIX threads, explicitly document that threads share file descriptors and global variables within the same process. Process creation functions, such as fork and exec in Unix like systems, involve more substantial kernel work, confirming that process creation is more resource intensive than thread creation.


Why Other Options Are Wrong:
Option B is incorrect because it ignores the sharing nature of threads and describes only processes. Option C reverses the reality by asserting that threads require more resources, which contradicts the definition of light weight threads. Option D is wrong because in practice thread creation and process creation are not identical; they involve different kernel paths and resource allocations.


Common Pitfalls:
Learners sometimes confuse the logical abstraction of a thread with the implementation details in a specific operating system, leading them to believe that threads always behave like separate processes. Another common mistake is assuming that all resources, including global variables, are private to each thread; in fact, that sharing is what makes data races and the need for synchronisation important topics in concurrent programming.


Final Answer:
A new thread gets its own stack and register context but shares code, data and open files with its process, while a new process receives a separate address space and its own resources.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion