All pastes #12337 Raw Edit

Anonymous

public text v1 · immutable
#12337 ·published 2005-05-21 16:17 UTC
rendered paste body
static void *GoSubwayGo(void *index)
{
	clock_t start, stop;
	double diff;
	int Subway;
	int Status;
	int GotThere = 1;

	Subway = atoi((char*) index);

	printf("Subway %d started\n", Subway+1);
   	while (GotThere != 0)
   	{
		printf("Subway: %d\n", Subway+1);
	   	start = clock();
		diff = difftime(stop = clock(), start);
	    	if((Status = pthread_mutex_lock(&mutex)) != 0);
		{
			fprintf(stderr,"%s: Error Mutex_Lock\n", pProgname);
			exit(EXIT_FAILURE);
		}
		if(value.nNowDistance[Subway] >= value.nSpeed[Subway])
		{
			value.nNowDistance[Subway] = value.nNowDistance[Subway] - value.nSpeed[Subway];
		}
		else value.nNowDistance[Subway] = 0;		
		GotThere = value.nNowDistance[Subway];
		if((Status =pthread_mutex_unlock(&mutex)) != 0)
		{
			fprintf(stderr,"%s: Error Mutex_Unlock\n", pProgname);
			exit(EXIT_FAILURE);
		}			
	}
	pthread_exit((void *) 0);
}