View Single Post
  #13   Spotlight this post!  
Unread 30-09-2003, 21:04
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Thread Synchronization

Quote:
Originally posted by catlin101
Hey, I was looking at a few examples of PIC micro code, and the ones with interrupts didn't say anything about thread synchronization. Does anyone know of any functions like LockInterrupts() or anything like that, or are we just supposed to hope that an interrupt doesn't modify data while the main thread or another interrupt is using it
Microcontrollers have an assembly instruction to disable interrupts. I'm guessing Innovation FIRST will provide a library that will implement a DisableInterrupts() type function in C which will simply call that assembly instruction (to prevent the need for teams to deal with assembly directly).

BTW (and it sounds like you probably know this already), you should never "hope" that an interrupt (or thread in a multithreaded system) won't modify data at the same time as another task. It will happen eventually, and it causes problems that can be really tough to debug.