www.pudn.com > Tornado_Train_Workshop_demo_program.rar > badProg.c


#include "vxWorks.h" 
#include "taskLib.h" 
#include "stdio.h" 
#include "sysLib.h" 
 
void foo(); 
int busy = FALSE; 
 
STATUS startFoo (char *printStr) 
	{ 
	char flag; 
 
	flag = *printStr; 
 
	if (taskSpawn ("tFoo", 200, 0, 5000,  
		       (FUNCPTR) foo, (int)&flag, 0,0,0,0,0,0,0,0,0) == ERROR) 
		{ 
		perror ("startFoo"); 
		return (ERROR); 
		} 
	 
	taskDelay (sysClkRateGet () * 5); 
 
	return (OK); 
	} 
 
void foo (char *flag) 
	{ 
	FOREVER 
		{ 
		if (busy == FALSE) 
			{ 
			busy = TRUE; 
			if (*flag == 'y') 
				printf ("In the critical region\n"); 
			busy = FALSE; 
			} 
		taskDelay (sysClkRateGet() * 3); 
		} 
	}