Scheduler Question

DUELink’s scheduler periodically executes a function.

The SStart command, which schedules a function, has a count parameter that specifies how many times the function should be called before stopping.

Is there a value for the count parameter that instructs the scheduler to run the function indefinitely.

************************** Found it.. -1 is forever

I must be missing something when trying to schedule a function to run. Following is an annotated listing of how I tried to schedule something. The // comments were added post test…

>new // clear out the user region

>list() // make sure it is empty

>$ // go into recording mode

$fn HHH()

$println(“Hello!”)

$fend

$> // End recording mode

>list // list what was recorded

fn HHH()

println(“Hello!”)

fend

>hhh() // enter function in immediate mode to verify operation

Hello!

>sstart(“HHH”, 1000, 5) // schedule to run every second for five times

// ***** NOTHING HAPPENS SStat returns nothing

I tried this on several different modules with identical results?

Schedulers only run if there is a running program. Terminating the main program will automatically stop schedulers, and interrupts.

That makes sense. Your response should be added to documentation.

The scheduler is running, but not as I expected:

>list // display the recorded code

fn SayHello()

println(“Hello”)

fend

asio(1)

sstart(“SayHello”, 1000, _a) // getting count from global

while 1

c = sstat(“SayHello”)

if c=0 // stop when remaining count goes to zero

break

end

wait(200)

wend

println(“Stopped!”)

>_a = 3 // set global for 3 scheduled executions

>run

Hello

Hello

Hello

Stopped!

// That worked as expected

>_a = -1 // this should cause scheduled execution forever

>run

Hello

Stopped!

// ONLY RAN ONCE. SStat returned zero? Even without SStat check does not run forever

>_a = 0 // I wonder what would happen with zero?

>run

Hello

Hello

Hello

Hello

Hello

Hello

// Running forever… hit escape which stops execution

>

>

>

>

It seems that forever execution requires a zero count in the SStart call, and then SStat returns something other than 0 as the remaining count.

1 Like

I am assuming that multiple functions can be scheduled for execution. Is there a hard limit to the number?

We will check but any reason why you are not using the console?

It does not match with the way I do things. Have to look in too many places to see what happened.

I have been using a terminal program.

I guessed you are using terminal, just wondering why

As I have said before… this is a question my wife asks a lot.

3 Likes

Docs updated to better explain

I posted earlier that I could not get -1 to work for forever scheduling. I found zero worked?

Yes sir, you are correct. The docs have been fixed.

It’s the SStat(“func”) that returns how many times the scheduler still needs to run and in this case a value of -1 means forever with 0 being completed.

Thanks again for the catch!