News for hackers. Stuff that matters.
Re:Memory management in C programs by jamesaguilar on Monday March 17, 2014 @03:08AM (#7413575)
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).
Re:Memory management in C programs by mpyne on Monday March 17, 2014 @02:50PM (#7417177)
On the contrary, every thread has its own stack. In fact the stack was the original "thread local storage".
Re:Memory management in C programs by jamesaguilar on Monday March 17, 2014 @08:39PM (#7419165)
Yes, 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.