Page 1 of 1

PAUSE Command

Posted: Tue Jan 29, 2019 10:28 pm
by rbytes
To Mr. Kibernetik:

How fast does the processor work during a PAUSE command? Does the processor slow down during the pause to the same speed as it does with a SLOWDOWN command?

Re: PAUSE Command

Posted: Wed Jan 30, 2019 5:34 am
by Mr. Kibernetik
PAUSE command does not affect CPU load and does not slow it down.

Re: PAUSE Command

Posted: Wed Jan 30, 2019 7:54 am
by GeorgeMcGinn
So if I put a PAUSE in a loop, it doesn't affect CPU load?

Wouldn't it stop the loop, thus relieving the CPU From executing all those clock cycles?

I guess it would depend on where the PAUSE was placed. I would agree all memory used will not be released.



Mr. Kibernetik wrote:
Wed Jan 30, 2019 5:34 am
PAUSE command does not affect CPU load and does not slow it down.

Re: PAUSE Command

Posted: Wed Jan 30, 2019 9:42 am
by Henko
GeorgeMcGinn wrote:
Wed Jan 30, 2019 7:54 am
So if I put a PAUSE in a loop, it doesn't affect CPU load?

Wouldn't it stop the loop, thus relieving the CPU From executing all those clock cycles?

I guess it would depend on where the PAUSE was placed. I would agree all memory used will not be released.



Mr. Kibernetik wrote:
Wed Jan 30, 2019 5:34 am
PAUSE command does not affect CPU load and does not slow it down.
Like mr.K. says, the PAUSE statement does not render the processor inactive, but the SLOWDOWN statement does for a short periot of time. On my iPad 2018, each execution of SLOWDOWN halts the cpu for about 54 millisec. Hence, in a loop waiting for an user response, the SLOWDOWN staement must be placed inside the loop (where the battery saving effect is needed).

Re: PAUSE Command

Posted: Wed Jan 30, 2019 3:00 pm
by rbytes
If a PAUSE does not slow or stop the processor, it seems that Mr. K did not see the need for it. We all use PAUSE commands whenever we need them, with no concern over the processor being overworked. Why then is there so much concern among my fellow users about stressing the processor? I don't recall one of mine ever failing from overwork (unlike humans!) 😱

Unless I hear otherwise from Mr. K, I will continue to fearlessly use PAUSE in my various routines. ⏱

Re: PAUSE Command

Posted: Wed Jan 30, 2019 3:38 pm
by Henko
It's the battery savings. I once had a SB program that made contract calculations. When i left it kind of active in the background, the battery would deplete very quickly. After inserting SLOWDOWNS in some placed, this was repaired.

Re: PAUSE Command

Posted: Wed Jan 30, 2019 3:59 pm
by rbytes
Yes, I have the same experience.

But I have many programs that use PAUSEs to create delays of a few seconds in such programs as slide shows, quizzes, speech, music, etc. I have not noticed any increase in battery consumption compared to other programs.

If battery consumption during PAUSEs was an issue, I believe that Mr. K would have incorporated the slowdown effect within them.

Re: PAUSE Command

Posted: Wed Jan 30, 2019 8:44 pm
by GeorgeMcGinn
When a processor runs at max for extended period of times, heat builds up and can melt components on the motherboard. That happened with my last PC. The repair shop said the circuitry inside the processor melted. I've had memory cards also melt when running production at Verizon as well as motherboards.

It happens. That is why I turn all my equipment off every night.



rbytes wrote:
Wed Jan 30, 2019 3:00 pm
If a PAUSE does not slow or stop the processor, it seems that Mr. K did not see the need for it. We all use PAUSE commands whenever we need them, with no concern over the processor being overworked. Why then is there so much concern among my fellow users about stressing the processor? I don't recall one of mine ever failing from overwork (unlike humans!) 😱

Unless I hear otherwise from Mr. K, I will continue to fearlessly use PAUSE in my various routines. ⏱

Re: PAUSE Command

Posted: Wed Jan 30, 2019 9:03 pm
by GeorgeMcGinn
Like I said. A pause will free up the CPU cycles the loop was using, but I never said the CPU stops completely. Items stored in memory the CPU needs to protect the addresses so no other process overwrites them.

I never said the CPU stops or is rendered inactive – just frees up the resources used by the loop. This is Computer 101, and applies to every computer, including mainframes.

PAUSE and SLOWDOWN only applies to the SmartBASIC task. It has no effect on other tasks running.

Henko wrote:
Wed Jan 30, 2019 9:42 am
GeorgeMcGinn wrote:
Wed Jan 30, 2019 7:54 am
So if I put a PAUSE in a loop, it doesn't affect CPU load?

Wouldn't it stop the loop, thus relieving the CPU From executing all those clock cycles?

I guess it would depend on where the PAUSE was placed. I would agree all memory used will not be released.



Mr. Kibernetik wrote:
Wed Jan 30, 2019 5:34 am
PAUSE command does not affect CPU load and does not slow it down.
Like mr.K. says, the PAUSE statement does not render the processor inactive, but the SLOWDOWN statement does for a short periot of time. On my iPad 2018, each execution of SLOWDOWN halts the cpu for about 54 millisec. Hence, in a loop waiting for an user response, the SLOWDOWN staement must be placed inside the loop (where the battery saving effect is needed).

Re: PAUSE Command

Posted: Wed Jan 30, 2019 9:46 pm
by rbytes
I just modified my pause routine and renamed the function as "sleep". I posted it in Libraries, but want to show it here too to explain the results I get. I have marked the lines that are only needed to demonstrate the function with '***

There is now a SLOWDOWN inside the loop within the function. It has a large effect on the loop. To compensate, I had to multiply line 6 of the function by .45 to shorten the PAUSE length so that the sleep time would be accurate. Try commenting out *.45 from that line and compare the actual sleep time with the number of seconds you called for.

My two screen shots show the actual sleep time (compared to the specified time of 10 seconds) with the error correction and then without it. The SLOWDOWN in my loop causes it to sleep over 1.5 times the specified length!

time reset '***
get screen size sw,sh '*** (if screen size is read at the start of the program)
sleep(10)
print time() '***
end '***

def sleep(dur)
set buttons font size 50
button "wake" text "⏰" at .sw/2-50,200
zzz=dur*10
do slowdown ! z+=1
pause (dur/zzz)*.45
until z>zzz or button_pressed("wake")
button "wake" delete
end def