# call sends for reply
resource cs()
	op f(int x) returns int  y{call,send}
	op semop() {send}
	op done() {send}
	int  c = 0 # number of f's done.

	send semop()
	send f(3)
	write( f(5), f(7) )
	send f(2)
	for [ i = 1 to 4 ] { receive done(); }
	write(c)

	proc f(x) returns y  {
		y = 0
		for [ i = 1 to x ] {
			y = y+i
		}
		reply
		y = 99999999
		receive semop(); c++; send semop()
		send done()
	}
end
