cs162_fa08_mt1-10 - simultaneous Enqueue and Dequeue...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 162 Fall 2008 Midterm Exam I October 15, 2008 Page 12/21 Problem 3g[3pts]: For each of the following potential context switch points, state whether or not a context switch at that point could cause incorrect behavior of Dequeue(); Explain! Object Dequeue() { 1 QueueEntry oldprevHead = prevHead; 2 QueueEntry nextEntry = oldprevHead.next; 3 prevHead = nextEntry; return nextEntry.stored; } Point 1: Point 2: Point 3: Problem 3h[4pts]: Rewrite code for Dequeue() , using the CAS() operation, such that it will work for any number of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: simultaneous Enqueue and Dequeue operations. You should never need to busy wait. Do not use locking (i.e. dont use a test-and-set lock). The solution can be done in a few lines. We will be grading on conciseness. Do not use more than one CAS() or more than 10 lines total (including the function declaration at the beginning). Hint: wrap a do-while around vulnerable parts of the code identified above. Object Dequeue() { // Insert code here }...
View Full Document

This note was uploaded on 08/26/2009 for the course CS 162 taught by Professor Kubiatowicz during the Spring '02 term at University of California, Berkeley.

Ask a homework question - tutors are online