Relative Content

Tag Archive for stack

Conceptually what does it mean when it is said that each thread gets its own stack?

I have been reading Java Concurrency in Practice by Brian Goetz and inside the section Stack Confinement it is mentioned that each thread gets its own stack and so local variables are intrinsically confined to the executing thread; they exist on the executing threads stack, which is not accessible to other threads. What does he mean that each thread has its own execution stack ?

Which are the fundamental stack manipulation operations?

I’m creating a stack oriented virtual machine, and so I started learning Forth for a general understanding about how it would work. Then I shortlisted the essential stack manipulation operations I would need to implement in my virtual machine:

Stack and heap – dynamic allocation question

Sources usually mention that dynamically created variables are allocated on the heap, while functions’ variables on the stack. Also the ones on the stack cease to exist automatically when e.g. the function which contains the variable exits. If I understand correctly, data fields of class are on the heap.
I do not understand, what is meant by ‘dynamic’? As I see it, when the code is running, anything being created is created dynamically on the fly, be it function variables or objects with variables inside them. I would be glad for simple explanation. Thanks

Heap overflow vs stack overflow

So as a general rule to avoid a stack overflow, big objects should be allocated to the heap (correct me if I am wrong). But, since the heap and the stack expand towards each other, wouldn’t this cause heap overflow or alternatively limit the space for the stack and higher the chances of stack overflow?

What is the purpose of red zone?

Red zone is a fixed size area in memory beyond the stack pointer that has not been “allocated”. Compilers do generate assembly to access that area in simple leaf functions.