View Single Post
  #7   Spotlight this post!  
Unread 09-10-2010, 09:04
flameout flameout is offline
AKA Ryan Van Why
FRC #0957 (SWARM)
Team Role: Alumni
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Oregon
Posts: 168
flameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to allflameout is a name known to all
Re: Lego NXT -- NXC blocking bluetooth IO

I spent a couple hours debugging an issue where threads would randomly crash on it. I thought it could be a race condition, but only two variables are shared between threads, and reads/writes are atomic (boolean).

I then found the -safecall option to nbc. This fixed it.

From now on, my code will have to grab a mutex just to run. I hope Wait() is multithread-safe, but if it isn't, I can write my own (I assume Acquire, Release, and Yield are threadsafe).

Thank you.

EDIT: It's been running fine for a while now, so I thinkk Wait() is threadsafe.

EDIT2:
I am running into another weird bug. If I run 4 threads (I don't know about numbers larger than four) and use a mutex (in only two of the threads), I get a delay in the bluetooth reception. The code doesn't slow down, but the controls run with a delay.

Last edited by flameout : 10-10-2010 at 01:03. Reason: Another issue