Threads Cannot Be Implemented As a Library: Reading Question


A student keen on solving the register promotion problem discussed in §4.3 modifies the pthread standard to include a statement that reads:

If a variable that is used inside a critical section is promoted to a register, any write or read of the memory location intended to synchronize the variable must occur inside the crtical section.

As a result, the code snippet in §4.3 becomes:

r = x;
for (...) {
  ...
  if (mt) {
    pthread_mutex_lock(...); x = r; r = x;
  }
  r = ... r ...
  if (mt) {
    x = r; r = x; pthread_mutex_unlock(...);
  }
}
x = r;

Does this solve the problem presented in the §4.3? Why or why not?


Submitting


Local Stanford students should write up their response on a sheet of paper that includes their name. The sheet of paper with the response should be submitted immediately before lecture.

SCPD students should write up their response in a text file named response.boehm.txt and upload it via the submission and grades page. You’ll need to sign in with your SUNetID to access the page. Responses will be accepted until one week after the corresponding paper’s lecture.

In either case, the response should be short, likely only a pithy paragraph in length.

Lecture

Tuesdays and Thursdays
4:30pm - 5:50pm
Gates B1

Office Hours

Dawson
Mondays
3:00pm - 5:00pm
Gates 314

Sergio
Mondays and Wednesdays
6:00pm - 7:30pm
Gates 288

Staff List

Dawson Engler
Instructor
Gates 314

Sergio Benitez
Instructor
Gates 288

Questions?

Ask on Piazza!

Previous Terms

Spring 2015
Spring 2014
Winter 2013
Spring 2013
Spring 2012
Spring 2011
Spring 2010