@Hannah: Is this Lukand's
sleep() function, then? I wasn't able to locate it or anything else regarding scheduling in the
Nutoak Github repo, but that doesn't appear to have been updated in the past two months, so I don't know if he's moved the repo somewhere else, or hasn't used it for some other reason.
Before I comment further, let me say that I don't have enough information to say if this actually might having anything to do with the problem at hand - I am following gerryg400's lead in this, and at this point only Lukand could say whether this is a relevant topic or not.
Now, to continue: if this is the
sleep() function in question, it presents a significant problem, as it seems to be designed to busy-wait on the timer ticks. The comment seems to indicate that the process is meant to cede the CPU to the scheduler inside the loop at the point which is currently commented out, but in the absence of anything else, it will simply spin in place, modulo the timer interrupts, until the
ticks variable (which is presumably a global variable in the kernel which is being updated by the timer interrupt handler) exceeds the computed amount of time (saved in a local variable in the function).
I don't want to say too much about this, given that we don't know about the implementation of the scheduler or the interrupt handlers. However, I will refine gerryg400's question by asking: a) will one tick (which seems to be equated to one millisecond) be sufficient time for the wait on this operation, b) what are the time resolutions of the scheduler and the timer interrupt handler, c) approximately how many clock cycles does the timer interrupt handler use in computing each tick, and d) how do you reconcile any RTC drift this might cause in the
ticks variable?
Admittedly, I don't even know if these questions make sense in your current design, but they seem to be relevant from what I have seen so far.