I'm getting a resource violation in the simple program below. When task2 sends over the channel to task1, a resource violation happens in the select statement of task1.
Any ideas?
#include <xs1.h>
void task1(chanend c){
select{
case c :> int val: // resource violation happens here when task2 sends over chan c
val++;
break;
}
}
void task2(chanend c){
timer t;
int time;
t :> time;
time += 1E8;
t when timerafter(time) :> int _;
outuint(c,0);
}
int main()
{
chan c;
par{
task1(c);
task2(c);
}
return 0;
}
Chanend in select causing exception
-
- Experienced Member
- Posts: 94
- Joined: Sun Feb 10, 2013 4:47 am
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
The reason you are getting the error is because, you are sending unsigned int value in task 2 over a channel and you are reading an int value in task 1 from channel c. You need to specify the data type consistently on both the channel ends.