80 likes | 214 Views
ecs150 Spring 2014 midterm (Key). Name: Student ID: Email:. Open book and totally 3 questions, 8 pages.
E N D
ecs150 Spring 2014 midterm (Key) Name: Student ID: Email: Open book and totally 3 questions, 8 pages. Please write precise and clean answers (should be around half to one full page). But, please do not leave it blank there as I will give partial credits. Please READ the questions VERY CAREFULLY before putting down the final answer. And, also please mark your answer clearly. You can use the back of the pages. Every page of this exam book needs to be returned back. Also, while turning in your exam book, please make sure to SIGN the special sign-up sheet. If you do NOT sign up and in case WE LOSS your exam book, it will be hard to convince us that you actually turn in the exam book back to us. If we suspect any cheating behavior, we will pass the case to the academic committee immediately. Score: ___/16 ecs150 spring 2014, midterm exam
Q-01 (System Calls 4%) Please describe one key difference, leveraging the following memory map diagram of FreeBSD, between system calls (e.g., fork, open, read) and regular library function calls (such as sqrt or malloc/free). Please note that your answer MUST leverage the diagram below. Per-process Kernel Stack The difference here is that for system calls, the service code will be executed on the per-Process kernel stack. User-stack Disk Heap Initialized data Initialized data text text elf header Memory elf magic number ecs150 spring 2014, midterm exam
Q-02 (FreeBSD Scheduling 4%) The following code segment is the implementation of FreeBSD 5.4 scheduling (i.e., runq_choose) for single CPU core. Please explain what ** LINE (2) ** is doing. Find the first non-zero bit, which represents the highest priority run queue with at least one KSE in a READY state. struct kse * runq_choose(struct runq *rq) { struct rqhead *rqh; struct kse *ke; int pri; (1) mtx_assert(&sched_lock, MA_OWNED); (2) while ((pri = runq_findbit(rq)) != -1) { (3) rqh = &rq->rq_queues[pri]; (4) ke = TAILQ_FIRST(rqh); (5) KASSERT(ke != NULL, ("runq_choose: no proc on busy queue")); (6) CTR3(KTR_RUNQ, "runq_choose: pri=%d kse=%p rqh=%p", pri, ke, rqh); (7) return (ke); } (8) CTR1(KTR_RUNQ, "runq_choose: idleproc pri=%d", pri); (9) return (NULL); } ecs150 spring 2014, midterm exam
Q-03 (Priority Inversion, Inheritance, and Ceiling, 8%, 2% each) This question is regarding priority ceiling protocol. Somewhat similar to the example we went over in the class, the following diagram shows four tasks and their independent execution sequences, of course, assuming no contention of any resources: 1 L L S1 S2 L 2 L L S3 S2 L 3 L L 4 L S2 S2 S2 S2 L 0 2 4 6 8 10 12 14 16 18 The meanings of the labels are: L: Local execution, B: blocked, Si: Semaphore I, C: Ceiling-Driven blocking, F: Finishing, P: Preempted. Please use the charts in the next few pages to lay out the schedules (using the label characters above) for regular priority scheduling (i.e., without solutions like priority inheritance, ceiling, and emulation), basic priority inheritance, priority ceiling, and priority ceiling emulation. Please also put down the effective prioritywhen priority inheritance occurs. Also, if you encounter a deadlock, please point it out as well. ecs150 spring 2014, midterm exam
Regular Priority Scheduling 1 2 3 4 0 2 4 6 8 10 12 14 16 18 ecs150 spring 2014, midterm exam
Basic Priority Inheritance 1 2 3 4 0 2 4 6 8 10 12 14 16 18 ecs150 spring 2014, midterm exam
Priority Ceiling Protocol 1 2 3 4 0 2 4 6 8 10 12 14 16 18 ecs150 spring 2014, midterm exam
Priority Ceiling Emulation 1 2 3 4 0 2 4 6 8 10 12 14 16 18 ecs150 spring 2014, midterm exam