4 ms·
Another example. Working "correctly" with threads is not something I would typically think of as a distinguishing feature of stack allocation. All basic c alloc
by jamesaguilar 13y ago
Another example. Working "correctly" with threads is not something I would typically think of as a distinguishing feature of stack allocation. All basic c allocation techniques work equally well with threads. That is, they all work fine when only one thread attempts to perform transactions on the memory, and none of them do if more than one does (sans locks, of course).
- mpyne 13y agoOn the contrary, every thread has its own stack. In fact the stack was the original "thread local storage".
- jamesaguilar 13y agoYes, my point is that if you try to operate on memory from another thread's stack, it is equally unsafe as operating on memory from the heap you received from another thread. The allocation method is irrelevant to whether it is safe. What is important is whether it is being accessed concurrently.