View Single Post
  #10   Spotlight this post!  
Unread 01-21-2009, 08:53 PM
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Semaphores and Synchronized's

Semaphores basically prevent critical regions from executing at the same time. The Synchronized class basically handles semGive() and semTake() automatically. To mark the start of a critical region, you use the macro CRITICAL_REGION(semID) and END_REGION, which automatically wraps the area of code in a Synchronized class. To create a semaphore ID, simply declare a SEM_ID. Any critical regions that you do not want to run at once should share the semaphore ID. No further configuration of the semaphore ID is needed unless you want to use an advanced type of semaphore (such as a counting semaphore). More information can be found here:

http://www.slac.stanford.edu/exp/gla...ef/semLib.html
__________________

Last edited by slavik262 : 01-21-2009 at 08:55 PM.
Reply With Quote