New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel work increment/decrement prevents MCU going to sleep #2098
Conversation
Good catch!
Another good catch! It also seems incorrect that the kernel work is incremented even in the case that |
I think I fixed this already by moving the increment_work function call. Am I missing something else here? |
Oh, I must have been looking at a single commit or something. You did fix it. |
bors r+ |
Pull Request Overview
This pull request (hopefully) fixes an issue that seems to prevent the kernel from putting the MCU to sleep. The issue seems to be from the kernel work counter.
While running the following user space app, it seems that the kernel does not sleep the MCU after the process's last yield system call.
I did some research and found out that the issue pops up only when there are several subscribes for the same callback (driver_id, subscribe_number). In the kernel:
I found that when a callback is overwritten:
a. the kernel work is incremented
b. the previous callback is removed, but the kernel work is not decremented accordingly
This prevents sends the scheduler into an infinite loop.
I also noticed that
enqueue_task
increments the kernel work regardless of whether a callback is scheduled or not. We also experienced an interesting issue when trying to implement a real-time external interrupt counter. It seems that if the kernel drops callbacks, it starts having a strange behavior, the apps jam. I think it might be related to the kernel work. We still need to do some more research.Testing Strategy
TODO or Help Wanted
N/A
Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.