Difference between revisions of "Producer&Consumer MP-asincrono"

From Sistemi Operativi
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang="C"> MP-asincrono Procuder(){ produce(x); asend(x,Consumer); while(1){ areceive(Consumer); produce(x); asend(x,Consumer); } } Consumer(){ ...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<syntaxhighlight lang="C">
 
<syntaxhighlight lang="C">
MP-asincrono  
+
MP-sincrono dato quello asincrono  
  
Procuder(){
+
Producer(){
 
produce(x);
 
produce(x);
 
asend(x,Consumer);
 
asend(x,Consumer);
Line 28: Line 28:
 
#include <slideconcorrenzapg201.h>
 
#include <slideconcorrenzapg201.h>
  
Procuder(){
+
Producer(){
 
while(1){
 
while(1){
 
produce(x);
 
produce(x);
Line 42: Line 42:
 
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
Fede & Pirata

Latest revision as of 20:25, 21 March 2014

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