// example of C-- semaphore usage

semaphore count; // a "general" semaphore
binarysem output; // a binary (0 or 1) semaphore for unscrambling output

void increment()
{
 	p(output); // obtain exclusive access to standard output
 	cout << "before v(count) value of count is " << count << endl;
	v(output);
	v(count); // increment the semaphore
} // increment

void decrement()
{
	p(output); // obtain exclusive access to standard output
	cout << "before p(count) value of count is " << count << endl;
	v(output);
	p(count); // decrement the semaphore (or stop -- see manual text)
} // decrement

main()
{
	initialsem(count,0);
	initialsem(output,1);
	cobegin {
		decrement(); increment();
 	}
} // main
