Which one of the following is NOT shared by the threads of the same pr...
Threads can not share stack (used for maintaining function calls) as they may have their individual function call sequence.
View all questions of this test
Which one of the following is NOT shared by the threads of the same pr...
Threads can not share stack (used for maintaining function calls) as they may have their individual function call sequence.
Which one of the following is NOT shared by the threads of the same pr...
Introduction:
In a multi-threaded process, multiple threads are executed concurrently within the same process. These threads share several resources and attributes, such as memory space, file descriptors, and message queues. However, there is one resource that is not shared among threads of the same process, and that is the stack.
Explanation:
1. Stack:
Each thread in a process has its own stack, which is used to store local variables, function call information, and other data. The stack is a region of memory that grows and shrinks dynamically as functions are called and return. It is organized as a stack data structure, where new elements are added at the top and removed from the top.
2. Address Space:
All threads within a process share the same address space. This means that they can access and modify the same variables, functions, and data structures in memory. Any changes made by one thread to the address space are visible to all other threads.
3. File Descriptor Table:
The file descriptor table is a data structure that maintains information about open files in a process. Each thread within a process shares the same file descriptor table, which allows them to read from and write to the same files. When a thread opens a file or creates a socket, a file descriptor is assigned to it, and this file descriptor is stored in the file descriptor table.
4. Message Queue:
Message queues are used for inter-process communication, allowing different processes to send and receive messages. In a multi-threaded process, all threads share the same message queue. This means that any thread can send a message to the queue, and any other thread can receive that message.
Conclusion:
Among the given options, the stack is the only resource that is not shared by the threads of the same process. Each thread has its own stack, which is used to store local variables and function call information. The other resources, such as the address space, file descriptor table, and message queue, are shared among all threads in the process.