Chris Quenelle's Weblog
Thoughts on developer tools.

All | Dbx | Development Tools | Life in General | OpenSolaris | plus | Software Philosophy | Sun Studio

fav comics

« Previous page | Main | Next page »
20060915 Friday September 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. Posted by Chris Quenelle ( Sep 15 2006, 04:23:16 PM PDT ) - Permalink - -

20060630 Friday June 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?  ;-)

Posted by Chris Quenelle ( Jun 30 2006, 10:39:35 AM PDT ) - Permalink - -

Older blog entries:

mug shot Chris Quenelle is a tools developer at Sun Microsystems. He's worked on performance and debugging tools at Sun for more than 10 years. He reads comic books and science fiction, and has more tivos than he can keep track of.

Calendar

RSS Feeds

Search

Links

Navigation

Referers