Skip to content

Conversation

oseiler2
Copy link

In the context of the discussion here #640 I thought it's useful to get the time to the next critical job to help determine idle/sleep time on the node without having to guess using os_queryTimeCriticalJobs()

@cnmicha
Copy link

cnmicha commented Jun 16, 2021

Awesome idea!

I think it would make sense to also query OS.runnablejobs, making the function look like this:

ostime_t os_timeToNextTimeCriticalJob() {
    if(OS.runnablejobs) return 0;
    
    if (!OS.scheduledjobs) return 0x7FFFFFFFl; //ostime_t_max;
    return OS.scheduledjobs->deadline - os_getTime();
}

See the OS loop function, it checks OS.runnablejobs as well: https://github.com/mcci-catena/arduino-lmic/blob/master/src/lmic/oslmic.c#L146-L154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants