main() {
pel Producer() p;
pel Consumer(p);
}
(mel item val<10>) Producer () {
try {
while ( !timeToPunchOut() )
?val<20msec> = produce();
}
catch (val!NOREADER) {
printf ("Consumer has done consuming. I go home too");
}
}
void Consumer (Producer p) {
try {
while ( 1 )
consume(?p!val<50min>);
}
catch (p!TERMINATE){
printf ("Producer has done producing. I go home too");
}
catch (p!val!NOWRITER) {
printf ("Producer has disappeared. I get out too");
}
}
In the above code, the Producer suggests to the run-time system to allocate 10 "buffer slots" for the mel variable val. This suggestion is similar to the register declaration in the C language. The run-time system may accept or ignore the buffer size directive.
Both the Producer and Consumer also indicate how long they will wait before raising the mel exceptions
NOREADER or NOWRITER. Again, these values are suggestions. The run-time system may or may not support the per call wait time directive.
No comments:
Post a Comment