philburk / pforth

Portable Forth in C
BSD Zero Clause License
598 stars 99 forks source link

MSEC waits tenths of milliseconds #112

Closed lolbinarycat closed 1 year ago

lolbinarycat commented 2 years ago

this can be verified by running echo "1000 msec bye" | time pforth

pforth version: PForth V28-LE/64, built May 26 2022 12:08:16 (static)

commit: fa8de1fa6ddd9d3c394b851ba87db15a22505bea

also, why is MSEC not named MS, as the standard would say?

philburk commented 2 years ago

Nice trick with the "|". You're right. And when I use 100000 msec it takes 1.87 seconds on my Macbook. It should take 100 seconds.

MSEC is implemented using a busy wait loop. It was calibrated on an 25 MHz CPU in the 90's. Computers have gotten faster. I should move MSEC to the pForth kernel and implement it using usleep(1000*n).

MSEC not named MS, as the standard would say?

MSEC was written in the 80's before the standard. I will add ": MS msec ;" as part of a FACILITY word set.

philburk commented 1 year ago

Also see old bug report at: https://code.google.com/archive/p/pforth/issues/16

philburk commented 1 year ago

I implemented it so that if (SLEEP) is unimplemented on embedded systems then it will use the old busy loop code.