cs162_fa08_mt1-7

cs162_fa08_mt1-7 - waiting process to sleep while it is...

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 9/21 Problem 3b[2pts]: Show how SWAP can be implemented using CAS. Don’t forget the return value. SWAP(&addr, reg1) { } Problem 3c[3pts]: With spinlocks, threads spin in a loop (busy waiting) until the lock is freed. In class we argued that spinlocks were a bad idea because they can waste a lot of processor cycles. The alternative is to put a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: waiting process to sleep while it is waiting for the lock (using a blocking lock). Contrary to what we implied in class, there are cases in which spinlocks would be more efficient than blocking locks. Give a circumstance in which this is true and explain why a spinlock is more efficient....
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 Berkeley.

Ask a homework question - tutors are online