I am trying to come up with a concept of a top application, controlling the execution of other threads. These "other threads" are while loops with different timing constraints, I was wondering if channels can be used to switch those threads on and off but without blocking eachother. In fact I want to use reading/writing to channels as interrupts to break while loops.
Initially i was thinking something like the pseudocode below but this will block processes while trying to read/write on the channels. Streaming channels won't help either since their size is much smaller than the one needed considering the difference in the timing requirements (eg: control takes 1s while loop1 completes loop every 1 ms.
I really hope I have made myself clear. Thank you in advance.
Regards,
Dimitris
Code: Select all
void control(){
while(1){
do{...}
ch1 <: 1;
ch2 <: 1;
do{...} // 1 s
}
}
void loop1(channend ch1){
while(1){
ch1:>k;
do{} // 1 ms
}
}
void loop2(channend ch2){
while(1){
ch2:>k;
do{} // 10 ms
}
}