how does linux restores a thread's stack pointer, program counter and return address.