Thoughts from the office by Ed Ball
Friday, September 30, 2005

This session by Joe Duffy had more practical advice about programming with concurrency. Some highlights:

  • It is important to maintain invariants (“assumed conditions in your code”), even in the face of exceptions.
  • Asynchronous exceptions like thread aborts can happen almost anywhere, which can make invariant maintenance difficult, but .NET prevents them from being thrown from certain sensitive areas, such as catch/finally blocks, static constructors, and native code.
  • Generally speaking, when you write a class, you should make any static state thread-safe, but require your client to lock access to your class instances, since you can’t predict their concurrency needs.
  • Always protect shared memory with locks. In .NET, locks do more than prevent concurrent access; they also guard the code against hardware instruction reordering, etc.
  • In the future, parallel programming will be the only way to leverage the increasing speed of computers, as the speed of a single CPU is nearing its physical maximum.
9/30/2005 1:37:11 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] | Development#
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Search
Archive
Links
Categories
Administration
Blogroll