What is stack memory?

You probably remember being taught that stack memory is just memory but with a special push/pop semantic; the memory you push last resides at the top of the stack, and if you perform a pop operation, that memory gets popped off – removed from – the stack.

The pedagogical example of visualizing a stack of dinner plates is a good one: the plate you place last is at the top, and you take the top plate off to give it to your dinner guest (of course, you could insist that you give them the plate from the middle or bottom of the stack, but we think that the plate on the very top would be the easiest one to pop off).

Some literature also refers to this push/pop behavior as Last In First Out (LIFO). Fair enough.

The high end ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.