Open wboeke opened 1 year ago
Hi,
Sure. You should check out the updated example in tt.f
Regards, pahihu
On 2023. Sep 21., at 11:44, W.Boeke @.***> wrote:
Could you please give an example of how sender and receiver (from tasking.f) can operate?
— Reply to this email directly, view it on GitHub https://github.com/pahihu/vfc/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTEB22BMCPPQOASRMEW44TX3QD6LANCNFSM6AAAAAA5BH46PA. You are receiving this because you are subscribed to this thread.
There's a problem: the program stumbles over the very first word in tt.f: |1|. It does not know the meaning of this, and I don't either.
Yes there is a problem, because the last version of tt.f does not contain the word |1|. It runs fine on macOS 10.13 32/64bit and CentOS 7 32bit/64bit.
On 2023. Sep 22., at 7:18, W.Boeke @.***> wrote:
There's a problem: the program stumbles over the very first word in tt.f: |1|. It does not know the meaning of this, and I don't either.
— Reply to this email directly, view it on GitHub https://github.com/pahihu/vfc/issues/5#issuecomment-1730814905, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTEB24ZZNAUBH6KAJJC6D3X3UNSBANCNFSM6AAAAAA5BH46PA. You are receiving this because you commented.
I tried the latest version of vfc. In my naivity I tried the following:
./vfc run.f tasking.f s( hello) receive send
Result: nothing Please neglect my ignorance, and tell me what to do.
Hi,
You should define the tasks with TASK, then BUILD them and finally ACTIVATE. Then start the round-robin scheduler with RR.
Ok, I will dissect the example tt.f here.
Define the tasks with TASK and BUILD them. TASK allocates the necessary data structure, BUILD links the task into the round-robin scheduler, but the default action is PASS, ie. do nothing.
|s| |r| task t1 t1 build
|s| |r| task t2 t2 build
Helper word, just to clear a variable:
: off ( a) 0 swap ! ;
Clear the 1st tasks SENDER variable, that signals, it is able to receive any message. Then activate the task with T1 ACTIVATE. This sets the task to WAKE and execute the words behind ACTIVATE. The tasks still not runs, just it setup in the round-robin task chain.
: run1
t1 sender 's off t1 activate
Begin the loop, print the current iteration number, then print “hello”:
0
begin
cr dup . ." hello”
Send the current iteration number to task T2 and receive the result, it drops the ‘from’ (ie. T2):
t2 send receive drop
It is done in an infinite loop:
0 until ;
Clear the 2nd tasks SENDER variable to receive messages, and activate the task. It is the same as in the case of the 1st task:
: run2
t2 sender 's off t2 activate
Then in an infinite loop receive a message, and print “world”, then PAUSE:
begin
receive ( msg from) >R
." world” pause
Increment the iteration count by 1 and send back to the sender task (ie. T1):
1+ R> send
Do it in an infinite loop:
0 until ;
The word RUN is just a helper, it calls RUN1 and RUN2 to ACTIVATE the tasks, and starts the round-robin scheduler with RR:
: run run1 run2 rr ;
So, how to send the word “hello” to myself in an ifinite loop?
|s| |r| task t1 t1 build
: run1 0 t1 sender 's ! t1 activate c" hello" tid send begin receive >R dup count cr type R> send 0 until ;
: run run1 rr ;
On 2023. Sep 26., at 15:44, W.Boeke @.***> wrote:
I tried the latest version of vfc. In my naivity I tried the following:
./vfc run.f tasking.f s( hello) receive send
Result: nothing Please neglect my ignorance, and tell me what to do.
— Reply to this email directly, view it on GitHub https://github.com/pahihu/vfc/issues/5#issuecomment-1735573954, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTEB2277D42E5WV3PAFZF3X4LL4RANCNFSM6AAAAAA5BH46PA. You are receiving this because you commented.
It works! I modified it such that only 10 "hello world" messages are sent. But after all: for me this is black magic!
Great!
The black magic is in the words WAKE and STOP. WAKE restores the stack pointers of a task and begins execution where it left. STOP saves the stack pointers of the task and calls the scheduler to execute the next task in the circular task list.
Regards, pahihu
On 2023. Sep 26., at 19:20, W.Boeke @.***> wrote:
It works! I modified it such that only 10 "hello world" messages are sent. But after all: for me this is black magic!
— Reply to this email directly, view it on GitHub https://github.com/pahihu/vfc/issues/5#issuecomment-1735969767, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTEB22WACS7RQGOSSMK6VDX4MFHJANCNFSM6AAAAAA5BH46PA. You are receiving this because you commented.
Could you please give an example of how sender and receiver (from tasking.f) can operate?