the following code runs forever... I think a volatile key word would be able to fix this one...
Code:
#include <acknex.h>

#define PRAGMA_POINTER

void semaphorewait(int* semaphore)
{
	*semaphore= 0;
	
	wait(-2);
	
	*semaphore= 1;
}



void main(void)
{
	int semaphore;
	
	semaphorewait(&semaphore);
	wait(1);
	while (semaphore== 0) {
		wait(1);
	}
	
	sys_exit("");
}




this code works...

Code:
#define PRAGMA_POINTER

void semaphorewait(int* semaphore)
{
	*semaphore= 0;
	
	wait(-2);
	
	*semaphore= 1;
}

	int semaphore;


void main(void)
{
	
	semaphorewait(&semaphore);
	wait(1);
	while (semaphore== 0) {
		wait(1);
	}
	
	sys_exit("");
}



Last edited by Gordon; 12/17/11 14:48.

Our new web site:Westmarch Studios