After tracing few examples in the debugger, you should be able to understand how Pintos manages threads. Here are few questions to test your understanding:
-
What variable stores all information about the threads? Where is it defined in the code?
-
When are the different thread created?
-
What are the different status of a thread?
-
When you print the stack in gdb (using the command
backtrace
orbt
), the stack shown belongs to which thread? -
When the scheduler is called (function
schedule
, line 553 inthread.c
), how is the next thread selected? -
When (i.e where in the code) is the scheduler called:
-
Could you give two situations when
thread yield
is called: -
When the scheduler switches to the next thread, can you precisely locate in the code where the current instruction pointer (eip) and stack pointer (esp) are recorded and replaced by the ones for the next thread?
-
When the CPU receives an interrupt, can you precisely locate in the code where the current current instruction pointer (eip) and stack pointer (esp) are saved and later restored?
-
When the CPU receives an interrupt, how does the interrupt handler knows which interrupt has been triggered?