Correct option is C
Threads within the same process share certain resources to enable efficient communication and execution. While each thread has its own
thread ID and
program counter, they share the
code section and
data section of the process. This shared memory model allows threads to access the same program instructions and data, facilitating collaboration and reducing memory overhead. Therefore, the correct answer is (c) code section and data section.
Important Key Points:
1.
Thread Characteristics:
· Threads are lightweight processes that share resources within a single process.
· Each thread has its own
thread ID and
program counter, which are unique to the thread.
2.
Shared Resources:
·
Code Section: All threads within a process share the same executable code.
·
Data Section: Threads share global variables, heap memory, and other data structures within the process.
3.
Non-Shared Resources:
·
Thread ID: Each thread has a unique identifier.
·
Program Counter: Each thread maintains its own program counter to track the execution point.
·
Stack: Each thread has its own stack for local variables and function calls.
Knowledge Booster:
· Threads within the same process share:
·
Code Section: The executable instructions of the program.
·
Data Section: Global variables, heap memory, and static data.
·
Open Files: File descriptors and other I/O resources.
· Threads have their own:
·
Stack: For local variables and function calls.
·
Thread ID: A unique identifier for each thread.
·
Program Counter: To track the execution point.
· Thread synchronization mechanisms, such as
mutexes and
semaphores, are used to manage access to shared resources and avoid race conditions.
· Multithreading improves performance by enabling concurrent execution but requires careful management of shared resources.