[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: translator enhancement needed, correction



> From heh Mon Jan 15 14:31:26 1990
> 
>   The smalltalk form for a critical section is ok (aSema4 critical: [block])
> but the c++ equivalent doesn't strike me as particularly obvious:
> 
> {
>   MUTEX_BEGIN(aSema4);
>   critical code
> }
> 
>   My problem is that the macro >declares< the start of the critical section,
> but then also >implies< (inobviously) the end (exit of the block).  I would
> prefer a name that doesn't seem so asymmetric.  How about:
> {
>   CRITICAL_BLOCK(aSema4);
>   ...
> }

Both strike me as odd, because the controlling macro lives INSIDE the
culkies, and there's no compiler-checking for code between the "{"
and the semaphore "P" operation, or for use of the macro inside a
loop, i.e.:

	while (...) {
		...
		FOO(aSema4);
		...
	}

This sort of thing would be generated by forgetting the extra "{}"s.
A second pass through the loop would V, then P, aSema4, allowing
some other process to sneak in, and this wouldn't be visible during
testing.

How about:

	CRITICAL_BLOCK(aSema4, {
		critical code;
	});

on the model of the BLAST_SHIELD() syntax?

	michael