a) Hardware implication of Channel, streaming Channel
b) As soon as I declare "int" variable, is 32 bits of space is allocated in RAM (is this right?). If it's true, what is happening when I declare chan and streaming chan variables?
c) In the following program, I am trying to send data from Thread X to Thread Y using streaming Channel. Whats wrong in my code? Its not working properly. I mean desired output is not showing up!!
Code: Select all
#include <xs1.h>
#include <platform.h>
#include <print.h>
void transmit(streaming chanend);
void receive(streaming chanend);
void main(){
streaming chan c;
par{
{transmit(c);} //Thread 1
{receive(c);} //Thread 2
}
}
void transmit(streaming chanend c){
int data[20]={1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10};
int i=0;
for(i=0;i<20;i++){
c <: data[i];
printstr("Thread1:");
printuint(data[i]);
}
}
void receive(streaming chanend c){
int temp;
c :> temp; //will wait till c gets an value?!
temp = temp+1;
printstr("Thread2:");
printuint(temp);
}