hw9_xv6_sleep

hw9_xv6_sleep - Homework: sleep and wakeup This assignment...

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

View Full Document Right Arrow Icon
Homework: sleep and wakeup Read : pipe.c Hand-In Procedure You are to turn in this homework at the beginning of lecture. Please write up your answers to the questions below and hand them in to a 6.828 staff member at the beginning of lecture. Introduction Remember in lecture 7 we discussed locking a linked list implementation. The insert code was: struct list *l; l = list_alloc(); l->next = list_head; list_head = l; and if we run the insert on multiple processors simultaneously with no locking, this ordering of instructions can cause one of the inserts to be lost: CPU1 CPU2 struct list *l; l = list_alloc(); l->next = list_head; struct list *l; l = list_alloc(); l->next = list_head; list_head = l; list_head = l; (Even though the instructions can happen simultaneously, we write out orderings where only one CPU is "executing" at a time, to avoid complicating things more than necessary.) In this case, the list element allocated by CPU2 is lost from the list by CPU1's update of list_head. Adding a lock that protects the final two instructions makes the read and write
Background image of page 1

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

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

Page1 / 2

hw9_xv6_sleep - Homework: sleep and wakeup This assignment...

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

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