{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tutorial5 - CSCC69 Tutorial 5 Dan Zingaro June 7 2010...

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

View Full Document Right Arrow Icon
CSCC69 Tutorial 5 Dan Zingaro June 7, 2010
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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!
Image of page 4
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 each function should return I A thread id and pid must be retained until that thread is joined or detached
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern