How to design a independent/asynchronous function? Topic is solved

If you have a simple question and just want an answer.
Arlenchen
Junior Member
Posts: 5
Joined: Tue Jan 26, 2016 8:54 am

How to design a independent/asynchronous function?

Post by Arlenchen »

Hi,

I am using explorerKIT.
I have write a function_A(client interface i) to transfer data to function_B(server interface i) by interface call like i.data(a). ("a" is "int a[];", a sine wave array.)

currently, the function_A and function_B is in different tile with par{}.
I use the "if" and "printf" in function_B to check the result.
( if (result>threshold) then do printf.)

I found that in the first loop, function_A to call function_B, the "printf" result will be right/reasonable value.
the function_B get a correct sine wave.
but the function_A next loop the function_B will get a noise. so the result is wrong.


because the function_A need to active in a very high speed.
so I want function_A just trigger the function_B to start working, and then function_A will just move on to the next command line or next loop.
And the function_B is too slow so I want the function_A will skip trigger function_B when the function_B is not ready/done yet.

is there any key words/commands for this?


View Solution
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Something like this? Uses a guard on the select case to trigger the event after an interface method call. Means the client doesn't get blocked.

Code: Select all

        while(1){
            select{
                case my_interface.trigger():
                    do_proc = 1;
                break;

                do_proc_flag => default:
                    process();
                    do_proc = 0; 
                break;
            }
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

I re-read your question... My solution will work but it will block the client if it tries to call the server before it has finished processing (which is CSP like and the way Xmos chips were designed).

You can make it truly asynch - there is a feature in the language called notifications. They work a little bit like interrupts except they are serviced when a select is called.

CHeck "1.5.2.2 Asynchronous communication" of the XMOS programming guide