[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Working example of tasker.fs use

From: Jerry DeLisle
Subject: Re: [gforth] Working example of tasker.fs use
Date: Sat, 13 Dec 2014 19:01:12 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 12/13/2014 05:03 AM, Bernd Paysan wrote:
--- snip ---

: (task1)  begin counter1 @ 1+ counter1 ! pause again ;
: (task2)  begin counter2 @ 1+ counter2 ! pause again ;

1 counter1 +!

would be more idiomatic.  And try to write a stack effect even for definitions
where it is ( -- ).

This is a fun little example for folks to learn with. Set cal to zero and execute calibration. This will show the average of 100 one second wait calls in microseconds. Subtract 1000000 from the displayed result and set cal accordingly. On my machine here I am getting within +- 50 usec for a 1000 wait. (not too shabby really and can be adjusted as the application grows.)

The 1 ms in front of pause in 'wait' releases the round robin execution of the tasker to the underlying OS so the infinite loops don't burn CPU cycles uselessly.

Keep in mind I am just playing with this to see what I can do and it is much less complicated than using pthread. It just depends on what you are trying to do and how sophisticated you think you need to be.

For my purposes I am going to be monitoring the status of an incoming signal on an RS-232 port status line and taking some action with that in the background while in the foreground interacting with the user in a terminal window. (Its related to amateur radio)

When I show people this code they are usually pretty amazed at how simple it "looks". No surprise.

Enjoy and Merry Christmas to All!


Attachment: smalltask.fs
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]