0

Memory layout for thread

How thread memory is allocated ? Does all thread have seperate individual stack ? Is heap common across all thread?

27th Mar 2021, 6:15 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Respostas
0
Thanks Martin Taylor .. Is below understanding correct? 1. local to thread i.e. variables declared inside function are always thread safe as those are on stack of thread 2. Global and static variables are not automatically thread safe as they go to common storage rather than stack. 3. Any function having heap allocated memory is not automatically thread safe.
28th Mar 2021, 5:21 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Is it not true ? Assume that function test has 100 lines of code. On line 1 , I am doing new and on line 100, I am having delete statement. Suppose this function is used for thread callable, so is not have high chance that one thread may allocate and other thread still feel that memory is not allocated ?
29th Mar 2021, 6:08 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
29th Mar 2021, 4:56 PM
Ketan Lalcheta
Ketan Lalcheta - avatar