Tutorial5 - CSCC69 Tutorial 5 Dan Zingaro June 7 2010 Exercise 2 Code Reading I What is a trapframe I mips/include/trapframe.h I Which functions

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSCC69 Tutorial 5 Dan Zingaro June 7, 2010 Exercise 2 Code Reading I What is a trapframe? I mips/include/trapframe.h I Which functions call mi_switch ? I A. thread_yield calls mi_switch with S_READY . I The thread that yielded is still runnable, so mi_switch puts it on the ready queue. I B. thread_sleep calls mi_switch with S_SLEEP . I Reason: to put the current thread on the sleepers queue. I C. thread_exit calls mi_switch with S_ZOMB . I Reason: by making the thread a zombie, it will be fully cleaned up when the zombie queue is next cleaned. The pid System I Each thread has a pid info block (see thread/pid.c ) struct pidinfo { int pi_pid; // process id of this thread int pi_ppid; // process id of parent thread volatile int pi_exited; // true if thread has exited int pi_exitstatus; // status (only valid if exited) //Add to this! I All pid info blocks are stored in a table (array) I Right now, we have race conditions on the table I e.g. two threads could ask for and get the same pid The pid System... I Task: add synchronization to the table I You can use locks, semaphores, or CVs — see thread/synch.c I Only one thread should be executing in the pid system at once; think of the pid system as a monitor I All externally-callable procedures must first “get the monitor lock” I pid_alloc : allocate a pid I pid_unalloc : free a pid for a thread that fcould not be created I . . . and any other external procedures you add! Joining Threads int thread_join(pid_t pid, int *status) I Suspend until pid terminates, and retrieve its exit status I pid must be joinable, and a child of the caller I Read the handout carefully to learn about the various errors...
View Full Document

This note was uploaded on 02/05/2011 for the course CS 69 taught by Professor Cathy during the Summer '10 term at University of Toronto- Toronto.

Page1 / 19

Tutorial5 - CSCC69 Tutorial 5 Dan Zingaro June 7 2010 Exercise 2 Code Reading I What is a trapframe I mips/include/trapframe.h I Which functions

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online