Project

General

Profile

Revision 1076

Fixed race condition for adding robots?

View differences:

branches/simulator/projects/simulator/simulator/core/robot.c
297 297

  
298 298
	while (1)
299 299
	{
300
		//sleep to avoid 100% CPU usage
301
		usleep(10000);
302
		while (pausing)
303
		{
304
			paused = 1;
305
			usleep(50000);
306
		}
307
		paused = 0;
308

  
300 309
		ret = pthread_mutex_lock(&all_finished_mutex);
301 310
		if(ret)
302 311
		  err(errno, "error locking mutex in even loop");
......
311 320
		
312 321
		ret = pthread_mutex_unlock(&all_finished_mutex);
313 322

  
314
		//sleep to avoid 100% CPU usage
315
		usleep(10000);
316
		while (pausing)
317
		{
318
			paused = 1;
319
			usleep(50000);
320
		}
321
		paused = 0;
322

  
323 323
		if(ret)
324 324
		  fprintf(stderr, "hmmm, error unlocking. errno: %d", errno);
325 325

  

Also available in: Unified diff