© Thomas Kunz 2000
SCE 574
201
Stacks in a Concurrent Program
äWhat does the stack look like in a concurrent program?
äNo longer a single stack
äEach thread needs its own stack
äStack space can be allocated from a heap
äIssue becomes complex in a language like Ada with sophisticated scoping rules
äTask A specification and body
äLocal variable a
äTask B specification and body
äTask C specification and body
äProcedure D
äEnd Task A
äLocal variables are placed on the stack, how are they linked together?
äA complex multi-linked list data structure called a cactus stack!
äWhat would the assembler sequences look like for accessing a local variable in main from C?
D
A
B
C
Main
Body of A has called procedure D
These are two separate
stacks for tasks B and C
They can still access D and a
via A’s stack, and main’s
variables as well
More tasks
from main, each
task gets its own
stack