stack_switch function

Determine the active context of stack layout