Skip to content
tarcuri edited this page Sep 22, 2011 · 1 revision

For my SP2 project our professor used the isr_restore function to initialize a processes context. It relied on a specific order for saving context register when entering and leaving the ISR stub. The order that the registers are saved on the stack is replicated in the context_t data structure.

The idea is to allocate a new context, fill in the segment registers which known values, as well as eip and eflags with known values. In particular eip should point to the processes entry point. Then set a global pointer for the current process to the newly initlized PCB. Once the context is initialized, the code jmp'd to isr_restore. Once there the current process pointer was stored in esp. Now when isr_restore continues to pop the registers (in the known, specified order0, they are popped from the C context data structure, instead of the system stack created originally. Finally once all the registers are popped, iret is executed and control should return to the new context as if returning from a normal interrupt with execution beginning at eip.

Clone this wiki locally