Gothmag wrote:The case in the second block, the one you say doesnt work, isn't how you should be doing that. And the first code blocks select isn't how that's done either. I'm assuming these aren't the actual code. Either way there is no way for either of those guards to be evaluated true with this code, is that data changed somewhere?
Could you post your main, both thread definitions, and the interface definition at least? Someone more knowledgeable might be able to say with what you've posted but I'm not sure what you're actually running. When calling a case, the syntax is the same as any function in c, you don't call it using case f(); Typically if you need something to be called before a thread is running you do it before the while, select bit. Otherwise since it's event driven you need something to call that code from elsewhere.
Can you give more detail than "that's now how you're supposed to do that"?
Here is a complete working example. If the producer.foo1(); call is uncommented, execution never progresses past it. Your suggestion of using "my_select_function(consumer, x);" instead of "case my_select_function(consumer, x);" simply produces a parse error. Commenting the call to the select function and copying the case directly into the select{} block produces the results I expect.
Code: Select all
typedef interface my_interface_if {
[[guarded]] void foo1();
[[guarded]] void foo2();
} my_interface_if;
select my_select_function(server interface my_interface_if consumer, int & x)
{
case (x > 4) =>
consumer.foo1():
debug_printf("foo1() hit, x = %d\n", x);
--x;
break;
}
void server_task(server interface my_interface_if consumer)
{
int x = 0;
while(1)
{
select {
case my_select_function(consumer, x);
case (x > 0) =>
consumer.foo2():
debug_printf("foo2() hit, x = %d\n", x);
--x;
break;
(x < 8) => default:
debug_printf("++x\n");
++x;
break;
}
}
}
void client_task(client interface my_interface_if producer)
{
debug_printf("start\n");
producer.foo1();
while(1)
{
producer.foo2();
delay_milliseconds(1000);
}
}
int main()
{
my_interface_if my_interface;
par {
on tile[0]: server_task(my_interface);
on tile[0]: client_task(my_interface);
}
return 0;
}