 | | A thread uses its private stack to store local variables for each routine it has called (but not yet exited) up to its current point of execution.(It also leaves various pieces of procedure context information on the stack, like bread crumbs, so that it can find its way back to the previously executing routine when it exits the current one.) For instance, consider a worker thread in our ATM server. It calls process_request, does some processing, and pushes some of process_request's local variables on the stack. It then calls deposit, pushing some information that allows it to return to the next instruction in process_request when it exits deposit. Now, it pushes deposit's local variables on its stack. Suppose it then calls retrieve_account, and then some number-crunching routine, and then, and then....We'd certainly like our thread to have ample stack space for all routines in its current call chain. | |
|