Friday Sep 15, 2006

Data Race in my last example

I got some polite email from Yuan Lin pointing out that my example program had a data race in it. He suggested that I should change my food_on_table function as follows to avoid the race.

From

int food_on_table() {
   pthread_mutex_lock(&foodlock);
   if (food>0) {
      food--;
   }
   pthread_mutex_unlock(&foodlock);
   return food;
}
to
int food_on_table() {
   int current_food;
   pthread_mutex_lock(&foodlock);
   current_food = food;
   if (food>0) {
      food--;
      current_food = food;
   }
   pthread_mutex_unlock(&foodlock);
   return current_food;
} 
Good catch, Yuan! Thanks for the tip. Next time I'll use our Data Race Detection Tool.

Friday Jun 30, 2006

Community and Terminology

I've been whining for years about the Solaris terminology problem where inside Sun in our planning and engineering documents we always refer to quarterly Solaris updates with a name like S10U2. But externally, our marketing folks require all our Solaris-related web pages refer to "Solaris 10 6/06". Presumably that's because the month of the release may change near the end of the schedule, and many of the planning documents are written far ahead of time.  Unfortunately, it's really hard to build a joint community of developers and users when they are speaking different languages.

Oh yeah, while I'm whinging... Some pages on sun.com talk about Solaris Express, and some pages talk about Software Express for Solaris. What's up with that? Will Sun Studio Express be renamed to Software Express for Sun Studio?  Who knows.  Why can't I search for information about Sun Studio without finding Elvis everywhere I look?  ;-)

About

Chris Quenelle

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today