Threads of a process sharea.Global variables but not heapb.Both heap and global variablesc.Neither global variables nor heapd.Heap but not global variables
Question
Threads of a process share
- a. Global variables but not heap
- b. Both heap and global variables
- c. Neither global variables nor heap
- d. Heap but not global variables
Solution
Threads of a process share both heap and global variables. So, the correct answer is b. Both heap and global variables.
Here's why:
-
Global Variables: All threads of a process share the global variables, as they are stored in the global memory area, which is accessible to all threads.
-
Heap: The heap is also shared among all threads of a process. When a process is created, it gets a heap segment where it can dynamically allocate memory. All threads can allocate, deallocate, and access memory on the heap.
So, threads of a process share both global variables and heap.
Similar Questions
Thread-local storage (TLS) is used by ---------------------Select one:a. user threadb. thread poolc. kernel thread
The memory space reserved when calling malloc is on:The stackThe heapI don't know
Why can't one process access variables of another process? If it tries to do, what will happen?
Which is the root for all thread groups in Java?a.None of theseb.systemc.maind.Both system and main
Dynamic memory allocation/linking of program is done duringSelect one:a. compilationb. executionc. none of the aboved. loading
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.