#include <stdio.h>

typedef enum{
	eLOCK = 0,
	eUNLOCK
}teStatus;

int mutex(teStatus status )
{
	static int lock = 0;
	
	if(status == eLOCK )
	{
		if(!lock)
		{
			lock = 1;
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	if(status == eUNLOCK)
	{
		if(lock)
		{
			lock = 0;
			return 1;
		}
		else
		{
			return 0;
		}
	}
}

void function1()
{
	while(!mutex(eLOCK));
	// do some task here.
	mutex(eUNLOCK);
}

void function2()
{
	while(!mutex(eLOCK));
	// do some task here.
	mutex(eUNLOCK);
}


int main(void) {
	// your code goes here
	return 0;
}
