Liberty BASIC Community Forum
« lbpro.exe using cpu time while not running? »

Welcome Guest. Please Login or Register.
Nov 20th, 2017, 06:00am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: lbpro.exe using cpu time while not running?  (Read 3670 times)
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1118
xx Re: lbpro.exe using cpu time while not running?
« Reply #15 on: Nov 12th, 2013, 5:36pm »

Ok, so here's how I understand and have observed how it works.

All user events are captured at Wait or Scan statements as everyone expects. Timer events are fired and placed in the queue unless the program flow is at a Wait or Scan statement. When the program is busy the Timer events build up in the queue and are executed in rapid succession immediately upon program flow reaching a Wait or Scan statement.

The problem I have seen people, including myself, get into is that they will have a really large processing loop within a sub/ function. Now we know that LB doesn't process user events unless again Wait or Scan statement. This includes Windows movements; so the user would attempt to move the window or something like that (normal window interaction) and the window wouldn't respond until it reached a Wait or Scan statement. We also know NEVER to put a wait statement inside a sub/ function. This causes people to use the Scan statement since this is exactly what it is for. So now the user can interact with the window perfectly fine, but if a Timer event is waiting in the queue LB will execute it without hesitation and the associated branch label will not be found inside the sub thus causing the error.

I suspect this is what may be happening here.

This is why I do not use the Timer statement and use code to start a timed event and detect its firing. It's now flawless in that it could be off by a ms here or there, but it works and I never get this error. My system is complicated in that the main loop calls a function which houses all of the other sub/ function calls so that I can call that main function from anywhere (ie. inside a long lasting loop). I send a parameter to that function to tell it whether to call the normal sleep command. This allows all of the normal stuff to happen and a Scan to take place, but can prevent the sleep from occurring when I want it not to. Like I said it's complicated, but it works 100% of the time and I do not have to worry about the Timer and whether or not I turned it off.

I think the OP's issue is simply a Scan statement within a long lasting Sub/ Function allowing a Timer event in the queue to be executed. Turning the Timer off after entering any sub/ function and then back on prior to exiting is the best thing to do if the OP wants to use the Timer.


{:0)

Brandon
User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
GaRPMorE
Senior Member
ImageImageImageImage


member is offline

Avatar

"Not everything that counts can be counted, and not everything that can be counted counts." - Albert Einstein


PM


Posts: 289
xx Re: lbpro.exe using cpu time while not running?
« Reply #16 on: Nov 12th, 2013, 7:30pm »

If there is a "glitch," or an "error," or a "bug" in my program, how then, does it occur only very, very occasionally if the program is run in the very same manner many, many times? Could it be "Windows?", or is it "LB?"
« Last Edit: Nov 12th, 2013, 7:32pm by GaRPMorE » User IP Logged

from the world according to GaRPMorE
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: lbpro.exe using cpu time while not running?
« Reply #17 on: Nov 12th, 2013, 10:13pm »

It's most likely something similar to what Brandon is describing, also known as a race condition. A race condition is a problem that depends on an exact sequence of events to actually show; in the case Brandon's describing, having a timer event queued while processing a large amount of data, and allowing the timer event to be executed. The interruption causes problems.

It shows up rarely because the exact sequence of events leading to a crash doesn't always happen. In this case, likely the exact timing between the subroutine being executed and the timer event being executed.


Very, very rarely are you actually being sabotaged from above(i.e. on the OS level)
« Last Edit: Nov 12th, 2013, 10:15pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1118
xx Re: lbpro.exe using cpu time while not running?
« Reply #18 on: Nov 12th, 2013, 10:15pm »

If it is an "invalid branch label" error I'll guarantee it's something in the code. There's nothing wrong with that.....

It only happens occasionally because you or whoever else is running it are only doing the sequence of events that cause the issue sporadically at the perfect time.

Are you using the Timer command?

This is not about who's right and who's wrong; it's about helping you find the problem in your program.

{:0)

Brandon
User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
cundo
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 626
xx Re: lbpro.exe using cpu time while not running?
« Reply #19 on: Nov 13th, 2013, 04:37am »

on Nov 12th, 2013, 7:30pm, GaRPMorE wrote:
If there is a "glitch," or an "error," or a "bug" in my program, how then, does it occur only very, very occasionally if the program is run in the very same manner many, many times? Could it be "Windows?", or is it "LB?"

Sorry but is not clear to me, do you actually have a Timer being in use in your code ? Or are you mixing Branch labels and Subs/Functions ?
« Last Edit: Nov 13th, 2013, 04:38am by cundo » User IP Logged

cundo
Rod
Global Moderator
ImageImageImageImageImage


member is online

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5562
xx Re: lbpro.exe using cpu time while not running?
« Reply #20 on: Nov 13th, 2013, 05:31am »

We have digressed a little bit. The original reported problem is that LB is using cpu cycles but nothing is "running" i.e. there is no program window in view.

This would imply that the program has not crashed, it is running and consuming cpu cycles. So we can dispense with the error codes and error logs because there will be none.

When LB is using 50% cpu cycles it implies you are locked in a very tight computational loop. Since it isn't running out of resources and crashing properly it must simply be following the coded loop. A timer statement won't create such a loop as by its very nature it is paced. Only a goto bomb or jump can use up so many cycles.

Since the program windows don't exist they must have been closed, either that or minimized? Probably not.

I would say the windows have been closed by the program code and then the program flow has moved of somewhere unexpected.

Can we at least see the quit code, the code where the windows are closed and resources tidied?
User IP Logged

GaRPMorE
Senior Member
ImageImageImageImage


member is offline

Avatar

"Not everything that counts can be counted, and not everything that can be counted counts." - Albert Einstein


PM


Posts: 289
xx Re: lbpro.exe using cpu time while not running?
« Reply #21 on: Nov 14th, 2013, 7:37pm »

I'm afraid I can't be certain exactly which LB program was last run and shut down (as far as I know). I have a bunch of programs that I run every day, and in the same manner, as far as I know. Like the "invalid branch label" error, the problem is not reproducible at will. The branch label thing has not come up in months, and was from a tokenized program that is run daily. The excessive CPU use was a surprise, else I would not have mentioned it. I have wasted your time. undecided
User IP Logged

from the world according to GaRPMorE
GaRPMorE
Senior Member
ImageImageImageImage


member is offline

Avatar

"Not everything that counts can be counted, and not everything that can be counted counts." - Albert Einstein


PM


Posts: 289
xx Re: lbpro.exe using cpu time while not running?
« Reply #22 on: Jan 22nd, 2014, 7:10pm »

Happened again today. Had to restart to stop it. Task Manager confirmed that no applications were running, but lbpro was "hogging" 50% of the CPU time. Not a big problem, but mysterious.
User IP Logged

from the world according to GaRPMorE
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1118
xx Re: lbpro.exe using cpu time while not running?
« Reply #23 on: Jan 22nd, 2014, 8:34pm »

Gary,

Can you post the code that you ran immediately prior to this happening? If you do not have it just post it the next time it happens.

{:0)

Brandon
User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
Rod
Global Moderator
ImageImageImageImageImage


member is online

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5562
xx Re: lbpro.exe using cpu time while not running?
« Reply #24 on: Jan 23rd, 2014, 03:42am »

When you say you had to restart to stop it, next time find lbpro.exe using task manager. It will be listed under the background tasks not the applications. Click to highlight then click on end task to cancel. No need to reboot.

User IP Logged

GaRPMorE
Senior Member
ImageImageImageImage


member is offline

Avatar

"Not everything that counts can be counted, and not everything that can be counted counts." - Albert Einstein


PM


Posts: 289
xx Re: lbpro.exe using cpu time while not running?
« Reply #25 on: Jan 23rd, 2014, 7:39pm »

Do not find a "background tasks" tab in Task Manager. In the Processes window it showed lbpro.exe as using the 50% CPU time. Hard to say what lb prog. I last ran, but I'll try to pay more attention next time. "Stuff Happens" with Windows sometimes, I think. You do things the same way time after time, and once in a while some sort of a glitch seems to turn up of its own accord. I have a tokenized program that I use several times a day in the same manner, every time. For a while, about one percent of the time, it would fail with an "invalid branch label." Obviously, the label was present for the other 99% runs. I did not revise the program, and it has not failed for perhaps a year or more. smiley
User IP Logged

from the world according to GaRPMorE
Rod
Global Moderator
ImageImageImageImageImage


member is online

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5562
xx Re: lbpro.exe using cpu time while not running?
« Reply #26 on: Jan 24th, 2014, 01:52am »

Why not make .exe versions of your program's? That way you will know what program is causing the bug. You still speak of windows and glitches, it isn't, its a coding/program flow bug, 100% guaranteed.
User IP Logged

hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: lbpro.exe using cpu time while not running?
« Reply #27 on: Mar 10th, 2014, 10:08am »

I know this is a bit off-topic but...

I tend to agree with Richard. There is some strange business with the "branch label not found" bug. I spent a week trying to trim down code so I could post it on the bug tracker but it would only happen completely randomly with no timer statements and a minimum change in unrelated code. For me it happens with making too many checkboxes so I avoid them like the plaque. I think that was like a year ago, now that I've eliminated the checkboxes and replaced them with radio buttons and listboxes and life is better.

I fear the "checkbox bug" greatly. I think of "branch label not found" as a kind of catch-all for undocumented random bug weirdness.

I maintain a ~15,000 line financial program as my full time job.
« Last Edit: Mar 12th, 2014, 08:36am by hooshnik » User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1118
xx Re: lbpro.exe using cpu time while not running?
« Reply #28 on: Mar 10th, 2014, 5:36pm »

on Mar 10th, 2014, 10:08am, hooshnik wrote:
I know this is a bit off-topic but...

I tend to agree with Richard. There is some strange business with the "branch label not found" bug. I spent a week trying to trim down code so I could post it on the bug tracker but it would only happen completely randomly with no timer statements and a minimum change in unrelated code. For me it happens with making too many checkboxes so I avoid them like the plaque. I think that was like a year ago, now that I've eliminated the checkboxes and replaced them with radio buttons and listboxes and life is better.

I fear the "checkbox bug" greatly. I think of "branch label not found" as a kind of catch-all for undocumented random bug weirdness.

I maintain a ~15,000 line financial program as my full time job.


Saying this is completely unwarranted. There has still been no code produced to demonstrate the bug(s). This would be akin to me telling you that I have a washing machine that can fly, but never showing you said washing machine actually flying.

Give us some code and we'll either confirm a real bug or show you where your coding issue is.


{:0)

Brandon
« Last Edit: Mar 11th, 2014, 10:19pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
hooshnik
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 105
xx Re: lbpro.exe using cpu time while not running?
« Reply #29 on: Mar 12th, 2014, 08:35am »

on Mar 10th, 2014, 5:36pm, Brandon Parker wrote:
Saying this is completely unwarranted. There has still been no code produced to demonstrate the bug(s). This would be akin to me telling you that I have a washing machine that can fly, but never showing you said washing machine actually flying.

Give us some code and we'll either confirm a real bug or show you where your coding issue is.


{:0)

Brandon


It was a spelling mistake in the destination branch label name. I was making so many checkboxes I was getting scrollblindness. Why doesn't the compiler notice this?
User IP Logged

looking for file "include" support? Check out Aplomb Scribe http://libertybasic.conforums.com/index.cgi?action=display&board=open&num=1434746448
Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls