Producer&Consumer MP.

From Sistemi Operativi
Revision as of 20:31, 21 March 2014 by Pirata (talk | contribs) (Created page with "<syntaxhighlight lang="C"> MP-sincrono dato quello asincrono Producer(){ produce(x); asend(x,Consumer); while(1){ areceive(Consumer); produce(x); asend(x,Consumer); ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
MP-sincrono dato quello asincrono

Producer(){
	produce(x);
	asend(x,Consumer);
	while(1){
		areceive(Consumer);
		produce(x);
		asend(x,Consumer);
	}
}


Consumer(){
	while(1){
		x = areceive(Producer);
		consume(x);
		asend(ACK,Producer);
	}
}
	



MP-asincrono dato quello sincrono

#include <slideconcorrenzapg201.h>

Producer(){
	while(1){
		produce(x);
		asend(x,Consumer);	
	}

Consumer(){
	while(1){
		x=areceive(Producer);
		consume(x);
	}
}

Fede&Pirata