Index: doc/uC++toCFA/uC++toCFA.tex
===================================================================
--- doc/uC++toCFA/uC++toCFA.tex	(revision 83a581a8f2e532e5f2eb1bec3d03ece122c091e5)
+++ doc/uC++toCFA/uC++toCFA.tex	(revision 135a2d8361c24f82280a1727d6e30b5e673a77f2)
@@ -11,6 +11,6 @@
 %% Created On       : Wed Apr  6 14:53:29 2016
 %% Last Modified By : Peter A. Buhr
-%% Last Modified On : Tue Oct 22 17:45:48 2024
-%% Update Count     : 6068
+%% Last Modified On : Fri Nov  8 08:22:25 2024
+%% Update Count     : 6107
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -394,6 +394,6 @@
 struct S {
 	int i, j;
-	S( int i, int j ) { S::i = i; S::j = j; }
-	~S() {}
+	@S@( int i, int j ) { S::i = i; S::j = j; }
+	@~S@() {}
 };
 S s = { 1, 2 }, s2{ 1, 2 };
@@ -407,6 +407,6 @@
 	int i, j;
 };
-void ?{}( S & s, int i, int j ) { s.[i, j] = [i, j]; }
-void ^?{}( S & s ) {}
+void @?{}( S & s@, int i, int j ) { s.[i, j] = [i, j]; }
+void @^?{}( S & s@ ) {}
 S s = { 1, 2 }, s2{ 1, 2 };
 S * s3 = &(*malloc()){ 1, 2 };
@@ -504,15 +504,15 @@
 \begin{uC++}
 
-_Coroutine C {
+@_Coroutine@ C {
 	// private coroutine fields
 	void main() {
-		... suspend(); ...
-		... _Resume E( ... ) _At partner;
-		... uThisCoroutine(); ...
+		... @suspend();@ ...
+		... @_Resume E( ... ) _At partner;@
+		... @uThisCoroutine();@ ...
 
 	}
   public:
 	void mem( ... ) {
-		... resume() ...
+		... @resume();@ ...
 	}
 };
@@ -521,15 +521,15 @@
 \begin{cfa}
 #include <$coroutine$.hfa>
-coroutine C {
+@coroutine@ C {
 	// private coroutine fields
 
 };
 void main( C & c ) {
-	... suspend; ... // keyword not routine
-	... resumeAt( partner, ExceptionInst( E, ... ) );
-	... active_coroutine(); ...
+	... @suspend;@ ... // keyword not routine
+	... @resumeAt( partner, ExceptionInst( E, ... ) );@
+	... @active_coroutine();@ ...
 }
 void mem( C & c, ... ) {
-	... resume( c ); ...
+	... @resume( c );@ ...
 }
 \end{cfa}
@@ -548,5 +548,5 @@
 #include <uCobegin.h>
 int main() {
-	COBEGIN
+	@COBEGIN@
 		BEGIN osacquire( cout ) << "A" << endl; END
 		BEGIN osacquire( cout ) << "B" << endl; END
@@ -554,6 +554,6 @@
 		BEGIN osacquire( cout ) << "D" << endl; END
 		BEGIN osacquire( cout ) << "E" << endl; END
-	COEND
-	COFOR( i, 1, 10,
+	@COEND@
+	@COFOR@( i, 1, 10,
 		osacquire( cout ) << i << endl;
 	)
@@ -566,5 +566,5 @@
 int main() {
 	{
-		corun { mutex( sout ) sout | "A"; }
+		@corun@ { mutex( sout ) sout | "A"; }
 		corun { mutex( sout ) sout | "B"; }
 		corun { mutex( sout ) sout | "C"; }
@@ -572,5 +572,5 @@
 		corun { mutex( sout ) sout | "E"; }
 	}
-	cofor( i; 10 ) {
+	@cofor@( i; 10 ) {
 		mutex( sout ) sout | i;
     }
@@ -712,16 +712,33 @@
 \section{Monitors}
 
+Internal Scheduling
 \begin{cquote}
 \begin{tabular}{@{}l|ll@{}}
 \begin{uC++}
 
-@_Monitor@ M {
-	@uCondition@ c;
-	bool avail = true;
+@_Monitor@ BoundedBufferI {
+	@uCondition@ full, empty;
+	int front = 0, back = 0, count = 0;
+	int elements[20];
   public:
 
-	void rtn() {
-		if ( ! avail ) c.wait();
-		else avail = false;
+
+
+	@_Nomutex@ int query() const { return count; }
+
+	void insert( int elem ) {
+		if ( count == 20 ) @empty.wait();@
+		elements[back] = elem;
+		back = ( back + 1 ) % 20;
+		count += 1;
+		@full.signal();@
+	}
+	int remove() {
+		if ( count == 0 ) @full.wait();@
+		int elem = elements[front];
+		front = ( front + 1 ) % 20;
+		count -= 1;
+		@empty.signal();@
+		return elem;
 	}
 };
@@ -730,17 +747,88 @@
 \begin{cfa}
 #include <$monitor$.hfa>
-@monitor@ M {
-	@condition@ c;
-	bool avail;
-};
-void ?{}( M & m ) { m.avail = true; }
-void rtn( M & m ) with( m ) {
-	if ( ! avail ) wait( c );
-	else avail = false;
-}
-
-\end{cfa}
-\\
-\multicolumn{2}{@{}l@{}}{\lstinline{M m;}}
+@monitor@ BoundedBufferI {
+	@condition@ full, empty;
+	int front, back, count;
+	int elements[20];
+};
+void ?{}( BoundedBufferI & buf ) with( buf ) {
+	front = back = count = 0;
+}
+int query( BoundedBufferI & buf ) { return buf.count; }
+int remove( BoundedBufferI & @mutex@ buf ); // forward
+void insert( BoundedBufferI & @mutex@ buf, int elem ) with( buf ) {
+	if ( count == 20 ) @wait( empty );@
+	elements[back] = elem;
+	back = ( back + 1 ) % 20;
+	count += 1
+	@signal( full );@
+}
+int remove( BoundedBufferI & @mutex@ buf ) with( buf ) {
+	if ( count == 0 ) @wait( full );@
+	int elem = elements[front];
+	front = ( front + 1 ) % 20;
+	count -= 1;
+	@signal( empty );@
+	return elem;
+}
+
+\end{cfa}
+\end{tabular}
+\end{cquote}
+\enlargethispage{1000pt}
+External Scheduling
+\begin{cquote}
+\begin{tabular}{@{}l|ll@{}}
+\begin{uC++}
+
+_Monitor BoundedBuffer {
+	int front = 0, back = 0, count = 0;
+	int elements[20];
+  public:
+	_Nomutex int query() const { return count; }
+	void insert( int elem );
+	int remove();
+};
+
+void BoundedBuffer::insert( int elem ) {
+	if ( count == 20 ) @_Accept( remove );@
+	elements[back] = elem;
+	back = ( back + 1 ) % 20;
+	count += 1;
+}
+int BoundedBuffer::remove() {
+	if ( count == 0 ) @_Accept( insert );@
+	int elem = elements[front];
+	front = ( front + 1 ) % 20;
+	count -= 1;
+	return elem;
+}
+\end{uC++}
+&
+\begin{cfa}
+#include <$monitor$.hfa>
+monitor BoundedBuffer {
+	int front, back, count;
+	int elements[20];
+};
+void ?{}( BoundedBuffer & buf ) with( buf ) {
+	front = back = count = 0;
+}
+int query( BoundedBuffer & buf ) { return buf.count; }
+int remove( BoundedBuffer & @mutex@ buf ); // forward
+void insert( BoundedBuffer & @mutex@ buf, int elem ) with( buf ) {
+	if ( count == 20 ) @waitfor( remove : buf );@
+	elements[back] = elem;
+	back = ( back + 1 ) % 20;
+	count += 1;
+}
+int remove( BoundedBuffer & @mutex@ buf ) with( buf ) {
+	if ( count == 0 ) @waitfor( insert : buf );@
+	int elem = elements[front];
+	front = ( front + 1 ) % 20;
+	count -= 1;
+	return elem;
+}
+\end{cfa}
 \end{tabular}
 \end{cquote}
