Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The Street finds its own uses for technology." -- William Gibson


devel / comp.lang.forth / Re: Waiting till a specified time.

SubjectAuthor
* Waiting till a specified time.none
`* Re: Waiting till a specified time.Jos Ven
 `* Re: Waiting till a specified time.none
  +* Re: Waiting till a specified time.minf...@arcor.de
  |+- Re: Waiting till a specified time.Marcel Hendrix
  |`- Re: Waiting till a specified time.none
  `* Re: Waiting till a specified time.Jos Ven
   `- Re: Waiting till a specified time.none

1
Waiting till a specified time.

<nnd$7a321259$4072886c@0f72dcf5c707077c>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21731&group=comp.lang.forth#21731

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Waiting till a specified time.
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$7a321259$4072886c@0f72dcf5c707077c>
Organization: KPN B.V.
Date: Sat, 17 Dec 2022 14:09:25 +0100
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 62
Injection-Date: Sat, 17 Dec 2022 14:09:25 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2755
 by: none - Sat, 17 Dec 2022 13:09 UTC

There is often a real time wrapping counter available.
The ticks counter on the Pentium (RDTSC instruction), or micro second
counters on the Orange pi one plus (offset $9100 in the virtual io
space) Raspberry pi 1 (offset $3000) and most famously the timers on
The IBM pc available from the 80's to my AMD EUFI machine on I/O
addresses $40 ..$43.

If the counter wrap on e.g. 16 bits and you are on e.g. a 64 bit
system, you have to shift the count left 48 bits to get a proper
wrapping counter.

Such a counter makes it possible to wait until a certain wall
clock time by polling, but there is a pit-fall.

This is an example of old code.
On the pc the timer wraps each 1/16 seconds, e.g.
1.198180 divided by 16.

: INITIALISE-TIMER ( -- )
$34 $43 PC! \ set time mode 2, read/write channel 0
$00 $40 PC!
$00 $40 PC!
;

\ * WRONG *
\ old code. MICROTICKS gives a double on a 16 bit code.
\ Wait +n * 100 microseconds
\ /MS compares the time with the time of this call plus wait time.
: /MS ( +n -- )
TIMERFREQUENCY ROT 10000 M*/
MICROTICKS D+
BEGIN
2DUP MICROTICKS DU< \ D< change into DU<
UNTIL
2DROP
;

This code is *wrong*. Neither signed or unsigned comparison will
do the trick!

The correct code is this.
\ ***************************************************8
\ Compare TIME1 and TIME2 (ticks).
\ Return "time1 IS earlier".
\ This is tricky: the - is an unsigned subtracting actually.
\ The result is interpreted as signed!
: EARLIER? - 0< ;
\ ***************************************************8

This is maximally accurate. It gives a lee way of half the
wrapping period. On a 4 GHz pentium with a 32 Forth that
means half a second. tmanx (a musics program) encounters
notes that last longer, so it is not something to be
ignored.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Waiting till a specified time.

<4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21752&group=comp.lang.forth#21752

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:b2a:b0:4c7:4c07:8036 with SMTP id w10-20020a0562140b2a00b004c74c078036mr22983183qvj.36.1671455911222;
Mon, 19 Dec 2022 05:18:31 -0800 (PST)
X-Received: by 2002:a05:620a:3633:b0:6ff:c8a2:9784 with SMTP id
da51-20020a05620a363300b006ffc8a29784mr761792qkb.376.1671455911035; Mon, 19
Dec 2022 05:18:31 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 19 Dec 2022 05:18:30 -0800 (PST)
In-Reply-To: <nnd$7a321259$4072886c@0f72dcf5c707077c>
Injection-Info: google-groups.googlegroups.com; posting-host=213.10.199.198; posting-account=nkqetwkAAACepkf86cwWAMB6YF6pRh3F
NNTP-Posting-Host: 213.10.199.198
References: <nnd$7a321259$4072886c@0f72dcf5c707077c>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>
Subject: Re: Waiting till a specified time.
From: jos...@planet.nl (Jos Ven)
Injection-Date: Mon, 19 Dec 2022 13:18:31 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3813
 by: Jos Ven - Mon, 19 Dec 2022 13:18 UTC

Op zaterdag 17 december 2022 om 14:09:28 UTC+1 schreef none albert:
> There is often a real time wrapping counter available.
> The ticks counter on the Pentium (RDTSC instruction), or micro second
> counters on the Orange pi one plus (offset $9100 in the virtual io
> space) Raspberry pi 1 (offset $3000) and most famously the timers on
> The IBM pc available from the 80's to my AMD EUFI machine on I/O
> addresses $40 ..$43.
>
> If the counter wrap on e.g. 16 bits and you are on e.g. a 64 bit
> system, you have to shift the count left 48 bits to get a proper
> wrapping counter.
>
> Such a counter makes it possible to wait until a certain wall
> clock time by polling, but there is a pit-fall.
>
> This is an example of old code.
> On the pc the timer wraps each 1/16 seconds, e.g.
> 1.198180 divided by 16.
>
> : INITIALISE-TIMER ( -- )
> $34 $43 PC! \ set time mode 2, read/write channel 0
> $00 $40 PC!
> $00 $40 PC!
> ;
>
> \ * WRONG *
> \ old code. MICROTICKS gives a double on a 16 bit code.
> \ Wait +n * 100 microseconds
> \ /MS compares the time with the time of this call plus wait time.
> : /MS ( +n -- )
> TIMERFREQUENCY ROT 10000 M*/
> MICROTICKS D+
> BEGIN
> 2DUP MICROTICKS DU< \ D< change into DU<
> UNTIL
> 2DROP
> ;
>
> This code is *wrong*. Neither signed or unsigned comparison will
> do the trick!
>
> The correct code is this.
> \ ***************************************************8
> \ Compare TIME1 and TIME2 (ticks).
> \ Return "time1 IS earlier".
> \ This is tricky: the - is an unsigned subtracting actually.
> \ The result is interpreted as signed!
> : EARLIER? - 0< ;
> \ ***************************************************8
>
> This is maximally accurate. It gives a lee way of half the
> wrapping period. On a 4 GHz pentium with a 32 Forth that
> means half a second. tmanx (a musics program) encounters
> notes that last longer, so it is not something to be
> ignored.
>
> Groetjes Albert
> --
> "in our communism country Viet Nam, people are forced to be
> alive and in the western country like US, people are free to
> die from Covid 19 lol" duc ha
> albert &=n http://home.hccnet.nl/a.w.m.van.der.horst

That made me think about my tElapsed?
Now it has been changed as follows:

: u>d ( n1 -- d1 ) 0 ;

: tElapsed? ( ms-elapsed timer - flag )
2@
if + u>d ms@ u>d d- d>s 0< \ Time elapsed?
else 2drop false \ The timer is off
then ;
\ Test
2variable ttimer
: start-timer ( timer - ) ms@ true rot 2! ;

: test-1second ( - )
ttimer start-timer begin 1000 ttimer tElapsed? until ;

test-1second
\s Jos

Re: Waiting till a specified time.

<nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21754&group=comp.lang.forth#21754

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>
Subject: Re: Waiting till a specified time.
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>
Organization: KPN B.V.
Date: Mon, 19 Dec 2022 16:40:27 +0100
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.uzoreto.com!feeder.usenetexpress.com!tr2.eu1.usenetexpress.com!94.232.112.246.MISMATCH!feed.abavia.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 108
Injection-Date: Mon, 19 Dec 2022 16:40:27 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Mon, 19 Dec 2022 15:40 UTC

In article <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>,
Jos Ven <josv@planet.nl> wrote:
>Op zaterdag 17 december 2022 om 14:09:28 UTC+1 schreef none albert:
>> There is often a real time wrapping counter available.
>> The ticks counter on the Pentium (RDTSC instruction), or micro second
>> counters on the Orange pi one plus (offset $9100 in the virtual io
>> space) Raspberry pi 1 (offset $3000) and most famously the timers on
>> The IBM pc available from the 80's to my AMD EUFI machine on I/O
>> addresses $40 ..$43.
>>
>> If the counter wrap on e.g. 16 bits and you are on e.g. a 64 bit
>> system, you have to shift the count left 48 bits to get a proper
>> wrapping counter.
>>
>> Such a counter makes it possible to wait until a certain wall
>> clock time by polling, but there is a pit-fall.
>>
>> This is an example of old code.
>> On the pc the timer wraps each 1/16 seconds, e.g.
>> 1.198180 divided by 16.
>>
>> : INITIALISE-TIMER ( -- )
>> $34 $43 PC! \ set time mode 2, read/write channel 0
>> $00 $40 PC!
>> $00 $40 PC!
>> ;
>>
>> \ * WRONG *
>> \ old code. MICROTICKS gives a double on a 16 bit code.
>> \ Wait +n * 100 microseconds
>> \ /MS compares the time with the time of this call plus wait time.
>> : /MS ( +n -- )
>> TIMERFREQUENCY ROT 10000 M*/
>> MICROTICKS D+
>> BEGIN
>> 2DUP MICROTICKS DU< \ D< change into DU<
>> UNTIL
>> 2DROP
>> ;
>>
>> This code is *wrong*. Neither signed or unsigned comparison will
>> do the trick!
>>
>> The correct code is this.
>> \ ***************************************************8
>> \ Compare TIME1 and TIME2 (ticks).
>> \ Return "time1 IS earlier".
>> \ This is tricky: the - is an unsigned subtracting actually.
>> \ The result is interpreted as signed!
>> : EARLIER? - 0< ;
>> \ ***************************************************8
>>
>> This is maximally accurate. It gives a lee way of half the
>> wrapping period. On a 4 GHz pentium with a 32 Forth that
>> means half a second. tmanx (a musics program) encounters
>> notes that last longer, so it is not something to be
>> ignored.
>>
>> Groetjes Albert
>> --
>> "in our communism country Viet Nam, people are forced to be
>> alive and in the western country like US, people are free to
>> die from Covid 19 lol" duc ha
>> albert &=n http://home.hccnet.nl/a.w.m.van.der.horst
>
>That made me think about my tElapsed?
>Now it has been changed as follows:
>
>: u>d ( n1 -- d1 ) 0 ;
>
>: tElapsed? ( ms-elapsed timer - flag )
> 2@
> if + u>d ms@ u>d d- d>s 0< \ Time elapsed?
> else 2drop false \ The timer is off
> then ;
>\ Test
>2variable ttimer
>: start-timer ( timer - ) ms@ true rot 2! ;
>
>: test-1second ( - )
> ttimer start-timer begin 1000 ttimer tElapsed? until ;
>
>test-1second

Puzzled. The observation I gave works only with wrapping times, that
goes from 0x7FF... to 0x800...
u>d turns a wrapping timer to a non-wrapping timer.

If you're going to count milliseconds with a 64 bit counter,
you need not be worried about wrapping the first few million years
anyhow.
HEX
0 1 1000 FM/MOD \ period in your ticks i.e. MS
2 / \ wrap around time
60 / 24 / \ in hours
365 / \ in years
..
749784172 OK

>\s Jos

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Waiting till a specified time.

<b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21755&group=comp.lang.forth#21755

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a37:a957:0:b0:702:5666:43aa with SMTP id s84-20020a37a957000000b00702566643aamr99941qke.194.1671469766988;
Mon, 19 Dec 2022 09:09:26 -0800 (PST)
X-Received: by 2002:a37:512:0:b0:6fe:d1a0:ba88 with SMTP id
18-20020a370512000000b006fed1a0ba88mr12446154qkf.233.1671469766817; Mon, 19
Dec 2022 09:09:26 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 19 Dec 2022 09:09:26 -0800 (PST)
In-Reply-To: <nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f45:3826:5013:73cb:90f5:9acf;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f45:3826:5013:73cb:90f5:9acf
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>
<nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>
Subject: Re: Waiting till a specified time.
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Mon, 19 Dec 2022 17:09:26 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1872
 by: minf...@arcor.de - Mon, 19 Dec 2022 17:09 UTC

none albert schrieb am Montag, 19. Dezember 2022 um 16:40:30 UTC+1:
> If you're going to count milliseconds with a 64 bit counter,
> you need not be worried about wrapping the first few million years
> anyhow.

One would not want a million year running counter without sleep mode.
The costs for all those terawatthours times inflation rate....

If ever there were a Multitasking Wordset for standard Forth accorded,
words for counting microseconds and to control idle and deep sleep mode
would become lovely candidates for an extended wordset.

Just dawdling ... better go back to my hot spiced wine pot ... ;o)

Re: Waiting till a specified time.

<c49f6761-ed3d-4bd7-8d66-29f16edae4c3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21756&group=comp.lang.forth#21756

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:60d9:0:b0:3a7:e616:e091 with SMTP id i25-20020ac860d9000000b003a7e616e091mr13450083qtm.537.1671473235981;
Mon, 19 Dec 2022 10:07:15 -0800 (PST)
X-Received: by 2002:ae9:c116:0:b0:702:19c9:40eb with SMTP id
z22-20020ae9c116000000b0070219c940ebmr870673qki.404.1671473235837; Mon, 19
Dec 2022 10:07:15 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 19 Dec 2022 10:07:15 -0800 (PST)
In-Reply-To: <b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:45d1:f0c2:1b12:b3da;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:45d1:f0c2:1b12:b3da
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>
<nnd$6f43b7c1$5c4a0627@fd3d2990013d1572> <b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c49f6761-ed3d-4bd7-8d66-29f16edae4c3n@googlegroups.com>
Subject: Re: Waiting till a specified time.
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Mon, 19 Dec 2022 18:07:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1848
 by: Marcel Hendrix - Mon, 19 Dec 2022 18:07 UTC

On Monday, December 19, 2022 at 6:09:28 PM UTC+1, minf...@arcor.de wrote:
> If ever there were a Multitasking Wordset for standard Forth accorded,
> words for counting microseconds and to control idle and deep sleep mode
> would become lovely candidates for an extended wordset.

Indeed. The transputer could wait on TIME, and there we actually encountered
this problem (with 16-bit parts). IIRC, the transputer documentation warned
for this, possibly there was even a dedicated instruction (Or Occam keyword)
for it.

-marcel

Re: Waiting till a specified time.

<nnd$634aff92$53b64e21@a64a17540214e403>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21758&group=comp.lang.forth#21758

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: Waiting till a specified time.
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com> <nnd$6f43b7c1$5c4a0627@fd3d2990013d1572> <b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$634aff92$53b64e21@a64a17540214e403>
Organization: KPN B.V.
Date: Tue, 20 Dec 2022 10:36:56 +0100
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!npeer.as286.net!npeer-ng0.as286.net!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 34
Injection-Date: Tue, 20 Dec 2022 10:36:56 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2310
 by: none - Tue, 20 Dec 2022 09:36 UTC

In article <b9116f9d-be1d-4655-a47e-962d437463fbn@googlegroups.com>,
minf...@arcor.de <minforth@arcor.de> wrote:
>none albert schrieb am Montag, 19. Dezember 2022 um 16:40:30 UTC+1:
>> If you're going to count milliseconds with a 64 bit counter,
>> you need not be worried about wrapping the first few million years
>> anyhow.
>
>One would not want a million year running counter without sleep mode.
>The costs for all those terawatthours times inflation rate....
>
>If ever there were a Multitasking Wordset for standard Forth accorded,
>words for counting microseconds and to control idle and deep sleep mode
>would become lovely candidates for an extended wordset.
>
>Just dawdling ... better go back to my hot spiced wine pot ... ;o)

tmanx does a polling wait on a counter with 250 nSecond ticks.
That goes well, because if I see in the queue that the next event is
more than 15 millisecond away I execute `` 10 MS '' .
A properly implemented MS on a system like Linux or MS-Windows
does not do a busy wait.

Willem Ouwerkerk has deep seep mode under control with his
MSP noforth. Where it counts: battery operated uP's that go
on for years. As I understand it deep sleep modes are very specific.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Waiting till a specified time.

<ba6000c1-7cad-438d-9f40-0da3193e039an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21759&group=comp.lang.forth#21759

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:9d1:b0:6fe:d248:e25a with SMTP id y17-20020a05620a09d100b006fed248e25amr11518231qky.114.1671541065361;
Tue, 20 Dec 2022 04:57:45 -0800 (PST)
X-Received: by 2002:ac8:5988:0:b0:3a5:9370:ccf4 with SMTP id
e8-20020ac85988000000b003a59370ccf4mr78198707qte.376.1671541065161; Tue, 20
Dec 2022 04:57:45 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Tue, 20 Dec 2022 04:57:44 -0800 (PST)
In-Reply-To: <nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>
Injection-Info: google-groups.googlegroups.com; posting-host=213.10.199.198; posting-account=nkqetwkAAACepkf86cwWAMB6YF6pRh3F
NNTP-Posting-Host: 213.10.199.198
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com>
<nnd$6f43b7c1$5c4a0627@fd3d2990013d1572>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba6000c1-7cad-438d-9f40-0da3193e039an@googlegroups.com>
Subject: Re: Waiting till a specified time.
From: jos...@planet.nl (Jos Ven)
Injection-Date: Tue, 20 Dec 2022 12:57:45 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 120
 by: Jos Ven - Tue, 20 Dec 2022 12:57 UTC

Op maandag 19 december 2022 om 16:40:30 UTC+1 schreef none albert:
> In article <4ec931f9-1b70-4f3b..>,
> Jos Ven ~> wrote:
> >Op zaterdag 17 december 2022 om 14:09:28 UTC+1 schreef none albert:
> >> There is often a real time wrapping counter available.
> >> The ticks counter on the Pentium (RDTSC instruction), or micro second
> >> counters on the Orange pi one plus (offset $9100 in the virtual io
> >> space) Raspberry pi 1 (offset $3000) and most famously the timers on
> >> The IBM pc available from the 80's to my AMD EUFI machine on I/O
> >> addresses $40 ..$43.
> >>
> >> If the counter wrap on e.g. 16 bits and you are on e.g. a 64 bit
> >> system, you have to shift the count left 48 bits to get a proper
> >> wrapping counter.
> >>
> >> Such a counter makes it possible to wait until a certain wall
> >> clock time by polling, but there is a pit-fall.
> >>
> >> This is an example of old code.
> >> On the pc the timer wraps each 1/16 seconds, e.g.
> >> 1.198180 divided by 16.
> >>
> >> : INITIALISE-TIMER ( -- )
> >> $34 $43 PC! \ set time mode 2, read/write channel 0
> >> $00 $40 PC!
> >> $00 $40 PC!
> >> ;
> >>
> >> \ * WRONG *
> >> \ old code. MICROTICKS gives a double on a 16 bit code.
> >> \ Wait +n * 100 microseconds
> >> \ /MS compares the time with the time of this call plus wait time.
> >> : /MS ( +n -- )
> >> TIMERFREQUENCY ROT 10000 M*/
> >> MICROTICKS D+
> >> BEGIN
> >> 2DUP MICROTICKS DU< \ D< change into DU<
> >> UNTIL
> >> 2DROP
> >> ;
> >>
> >> This code is *wrong*. Neither signed or unsigned comparison will
> >> do the trick!
> >>
> >> The correct code is this.
> >> \ ***************************************************8
> >> \ Compare TIME1 and TIME2 (ticks).
> >> \ Return "time1 IS earlier".
> >> \ This is tricky: the - is an unsigned subtracting actually.
> >> \ The result is interpreted as signed!
> >> : EARLIER? - 0< ;
> >> \ ***************************************************8
> >>
> >> This is maximally accurate. It gives a lee way of half the
> >> wrapping period. On a 4 GHz pentium with a 32 Forth that
> >> means half a second. tmanx (a musics program) encounters
> >> notes that last longer, so it is not something to be
> >> ignored.
> >>
> >> Groetjes Albert
> >> --
> >> "in our communism country Viet Nam, people are forced to be
> >> alive and in the western country like US, people are free to
> >> die from Covid 19 lol" duc ha
> >> albert
> >
> >That made me think about my tElapsed?
> >Now it has been changed as follows:
> >
> >: u>d ( n1 -- d1 ) 0 ;
> >
> >: tElapsed? ( ms-elapsed timer - flag )
> > 2@
> > if + u>d ms@ u>d d- d>s 0< \ Time elapsed?
> > else 2drop false \ The timer is off
> > then ;
> >\ Test
> >2variable ttimer
> >: start-timer ( timer - ) ms@ true rot 2! ;
> >
> >: test-1second ( - )
> > ttimer start-timer begin 1000 ttimer tElapsed? until ;
> >
> >test-1second
> Puzzled. The observation I gave works only with wrapping times, that
> goes from 0x7FF... to 0x800...
> u>d turns a wrapping timer to a non-wrapping timer.
>
> If you're going to count milliseconds with a 64 bit counter,
> you need not be worried about wrapping the first few million years
> anyhow.
> HEX
> 0 1 1000 FM/MOD \ period in your ticks i.e. MS
> 2 / \ wrap around time
> 60 / 24 / \ in hours
> 365 / \ in years
> .
> 749784172 OK
>
> >\s Jos
> Groetjes Albert
> --
> "in our communism country Viet Nam, people are forced to be
> alive and in the western country like US, people are free to
> die from Covid 19 lol" duc ha
> albert~=n http://home.hccnet.nl/a.w.m.van.der.horst

> Puzzled. The observation I gave works only with wrapping times, that
> goes from 0x7FF... to 0x800...
Sorry I missed that condition.
So, I guess the following old version can still be used:

: tElapsed? ( ms-elapsed timer - flag )
2@
if + ms@ < \ Time elapsed?
else 2drop false \ The timer is off
then ;

Also note: tElapsed? is used to detect an action that must take place inside
a loop in a program. In my case the exact time is not very important.
test-1second is just a way to test tElapsed?

Re: Waiting till a specified time.

<nnd$03fc6a66$07fa01f6@a59a2e3175a480af>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21760&group=comp.lang.forth#21760

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <nnd$7a321259$4072886c@0f72dcf5c707077c> <4ec931f9-1b70-4f3b-bc18-8c3881d55e6fn@googlegroups.com> <nnd$6f43b7c1$5c4a0627@fd3d2990013d1572> <ba6000c1-7cad-438d-9f40-0da3193e039an@googlegroups.com>
Subject: Re: Waiting till a specified time.
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$03fc6a66$07fa01f6@a59a2e3175a480af>
Organization: KPN B.V.
Date: Tue, 20 Dec 2022 14:38:53 +0100
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 37
Injection-Date: Tue, 20 Dec 2022 14:38:53 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2287
 by: none - Tue, 20 Dec 2022 13:38 UTC

In article <ba6000c1-7cad-438d-9f40-0da3193e039an@googlegroups.com>,
Jos Ven <josv@planet.nl> wrote:
>Sorry I missed that condition.
>So, I guess the following old version can still be used:
>
>: tElapsed? ( ms-elapsed timer - flag )
> 2@
> if + ms@ < \ Time elapsed?
> else 2drop false \ The timer is off
> then ;
>
>Also note: tElapsed? is used to detect an action that must take place inside
>a loop in a program. In my case the exact time is not very important.
>test-1second is just a way to test tElapsed?

Correct. You have no problem. The problem is for 32 bits counter
on a 4 Ghz machine (if you're interested in delays in the order of
seconds) or for the 16 bits counter in the speaker pc timer that wraps
more that 10 times per second.

ms@ is a wrapping timer, I hope.
I solved the discontinuity going from
FF...FF to 0 (unsigned) or from 7F.. to 80.. (signed).
The point is that you cannot escape from the discontinuity as long as
you insist in comparing with < U< D< UD< .
: ms@-double ms@ 0 ;
is an unsigned double timer that wraps in the middle and is no good.

Postponing the trouble a couple million years is a valid Forth solution.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor