Lecture Notes Project B by Beverly Guangji XU Develop plan · Milestone A(requires most work): Non-preemptive (coroutine with scheduler) · Milestone B (small step from A): Non-preemptive with priorities (uth_join call) · Milestone C (medium step from B ): Preemptive with synchronization: o generate spontaneous interrupts that don't interfere each other o the ability to block the interrupts · Milestone D (medium step): condition variable Notes on the source code: ucontext-basic · Don't need to deal with dynamic stack size so far. 64kB is large enough. · 'child' and 'parent' are typedef structs that allocate memory · the concept of 'Context' includes: o Hardware Regs. * Stack Pointer * Program Counter * General purpose Reg. o Misc. (Signal mask) · the Control: the parent gets the current execution context by calling 'getcontext'; it then calls 'makecontext(&A,&B, arg) 'to create the new context, and pass the 'arg' along with it; it calls 'swapcontext (&B,&A)' to do the context switch between main thread and child thread (from B to A);after the child context is executed, the context is switched again by calling 'swapcontext (&A,&B)'; at the end, it exits and frees the stack. B-public · tickSz is the measured in millisecond. If tickSz is 0, it is non-preemptive; if tickSz is non-zero, it is preemptive. · uth_exit call exits a single thread, you can add another call to do 'stack-destroy'.