I have written a program that runs very very strange.
The program uses steaming channels within the select guards, e.g. some of the case refers to streaming channel ends.
The compiler tolerates this without an error, but I can understand if the program executes in a strange way since no control token will be sent that sets the thread scheduler.
Can anyone confirm that it is "forbidden" to use streaming chan within a select.
You have to use a transaction, or use stestct(c_streaming) within the default: and not use a case
:!: :?:
Streaming channels in a select statement
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Streaming channels in a select statement
Probably not the most confused programmer anymore on the XCORE forum.
-
- Respected Member
- Posts: 259
- Joined: Thu Sep 16, 2010 9:15 am
From what I saw you can test for a control token only (testct or chkct) but if the tokens are not control tokens then you get nothing like there is no token. Then I do not know how the select will know that there is something to be read without pausing. You may get a hint of what goes wrong looking at the dissasembly of the select portion for a streaming channel and a normal channel.
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
You can use streaming channels in the cases of selects. Selects are implemented using events and a channel end will event as soon as there is token available regardless of whether or not that token is a control token.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Hmm, Yes this pure XC standalone program works without any strange behaviour.
I will have to delete components in the lager one until I find the bug (It has inline asm as well).
The thing is that even the debugger output looks very strange. And if I change the rows whitin a par the result becomes very different.
It looks like I have written some strange stuff here.
Code: Select all
#include <xs1.h>
#include <platform.h>
#include <print.h>
#define t0 100000000
int main(){
streaming chan c, c_Data;
chan c_p;
par{
on stdcore[0]:{
int event=0;
unsigned counter=0;
do{
select{
case c_p:>unsigned _void:
while(1);
break;
case c:>event:
printstrln("Event");
break;
default:
c_Data<:counter;
counter++;
c_Data:>unsigned _void;
break;
}
}while(event==0);
printint(t0/counter);
}
on stdcore[1]:{
unsigned data;
while(1){
c_Data:>data;
c_Data<:data;
}
}
on stdcore[0]:{
timer tmr;
int time;
tmr:>time;
tmr when timerafter(time+t0):>void;
c<:1;
}
}
return 0;
}
The thing is that even the debugger output looks very strange. And if I change the rows whitin a par the result becomes very different.
It looks like I have written some strange stuff here.
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
Ohh, it's my asm code that is the problem
https://www.xcore.com/forum/viewtopic.php?p=7082#p7082
I didn't care about setting up the interconnect/switches.
https://www.xcore.com/forum/viewtopic.php?p=7082#p7082
I didn't care about setting up the interconnect/switches.
Probably not the most confused programmer anymore on the XCORE forum.