Skip to content
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

schedulers: store references to slots in processes array instead of AppIds #2068

Merged
merged 1 commit into from Aug 7, 2020

Conversation

hudson-ayers
Copy link
Contributor

@hudson-ayers hudson-ayers commented Aug 5, 2020

Pull Request Overview

This pull request fixes #2063 , by modifying each scheduler that stored a local copy of an AppId to instead store a pointer to a slot in the processes array. It also modifies initialization of these lists such that each scheduler has a list of all slots in the process array, and simply skips empty slots when scheduling. This makes restartable apps work again, and is also a first step towards supporting dynamically loaded apps (I imagine that will also involve replacing Option<&'static dyn ProcessType> with OptionalCell<&'static dyn ProcessType>).

This PR also changes the components for the mlfq and cooperative scheduler to include improvements I had made to the round robin component.

One downside of this approach is that if a process moves to a new slot in the app array, the scheduler state associated with that process is lost (i.e. position in the round robin queue is changed, and for mlfq the tracker of total CPU time used by the process during the current scheduling period will be inaccurate until the next resurrection). For the current schedulers I think this is fine, as it seems reasonable that moving processes around in the array might reset some state temporarily. If in the future schedulers are added that need to track state for all-time, we may want to reconsider this.

Testing Strategy

This pull request was tested by running two apps with each scheduler on Imix, and verifying that process restarts work using the process console.

TODO or Help Wanted

I ended up choosing this design over alternatives due to its simplicity. Eventually, we may want to move to the Kernel owning a generic ProcessCollection type, but doing this without adding additional trait-object indirection/overhead feels difficult.

Documentation Updated

  • No updates are required

Formatting

  • Ran make prepush.

Copy link
Contributor

@bradjc bradjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really glad to see that there is a reasonable fix which doesn't require changing the scheduler trait.

And from working on restartable apps before, I think building something that can handle every combination of dynamically added/removed/moved apps that we can dream up now is too complex, and instead we should implement based on the current usage of the PROCESSES array.

@bradjc bradjc added the last-call Final review period for a pull request. label Aug 6, 2020
@bradjc
Copy link
Contributor

bradjc commented Aug 6, 2020

Last call as I want to merge this quickly (it really is just a bug fix for the scheduler PR).

@bradjc
Copy link
Contributor

bradjc commented Aug 7, 2020

bors r+

@bors bors bot merged commit 2b2040e into tock:master Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
last-call Final review period for a pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheduler: AppIds can change
2 participants