Extra Question for Week 8

On the midterm, you were asked to implement Monitors in terms of Semaphores. For next Friday, please show how to implement counting semaphores in terms of mutexes:
	// assume existence of mutex_t and condition_t;
	typedef struct semaphore {


	...
	} *semaphore_t;

	
	// create a new semaphore initialized to count
	semaphore_t sem_create(int count)
	{



	}



	void sem_P(semaphore_t s)
	{
	

	}



	void sem_V(semaphore_t s)
	{


	}