-
Notifications
You must be signed in to change notification settings - Fork 691
TCB_SetSchedParams: Change to match API reference #1312
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
base: master
Are you sure you want to change the base?
Conversation
We'll need to check what the formal spec says and how much work it would be to change it if it is the same as the code and not the same as the manual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is good, commit message could be improved a bit. Just drop the last bit, it doesn't add anything you haven't said or implied yet:
This commit allows TCB_SetSchedParams allows the
invoked TCB's already bound scheduling context to
be passed in as described the API reference.
9bc940e
to
bf2581f
Compare
The spec does the same as the code at the moment, so this would need re-verification. @michaelmcinerney is currently on leave, but when he is back he might be able to say if this one is quick and easy or the opposite. |
This should be a very straightforward update to the proofs, maybe just a day or so. |
Turns out this is a bit more complex in the proofs. We specifically introduced this case 6 years ago in ba78e3b (and forgot to update the manual), because we were hitting lots of special casing when SC/TCB were already bound, even if it is just overwritten to be the same. Michael is looking into what would need to be done. Current thinking is that we should make use of the |
I agree that not passing |
8777afb
to
9436d18
Compare
Will squash the new commit with the first if it's okay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the code is correct, it's somewhat ugly. If it doesn't make verification harder, I'd prefer an outer if-check that checks if the SC is changed. If it is, it does the existing checks and also adds thread_control_sched_update_sc
to the flags (which need a new local var that can be passed at the end).
I have been able to get the abstract invariants working with something analogous to the C in this PR as it is currently, but removing the check on line 1874 performed just before But my initial thoughts on this were that the old error behaviour was much more clear, and that if the TCB is bound to a sched context and we do not want to unbind them, then it is strange that the user would need to provide a cap to this sc just to end up performing a no-op. I would prefer to have the user pass in a |
Adding a |
The old behaviour was to always fail the call if the thread already had an SC bound, is that what you are referring to? Sure it is clear, but it would make the syscall useless to call more than once during init. All the parameters can be configured with other system calls, so perhaps that's not a problem, but why have such a system call at all then?
Yes, very strange. I think the only purpose of
For passive tasks it is not reasonable to expect the user to know the current SC. My personal preference would be to get rid of But if we're doing such big breaking changes, the whole init functions could be cleared up. Currently there is way too much overlap between |
cbb4d7b
to
08cf7ee
Compare
Agreed, the only reason I stumbled on this at all is because I wanted to change the priority and fault_ep of a thread and set_sched_params seemed like the easiest of the three to use in my case. |
Yes, that's what I was referring to. I suppose that before, it was a much less useful call since it can't be called for TCBs that did have a bound SC, but my objection was really just to providing the cap to the SC and then getting a no-op.
I hadn't thought about that. That could be interesting. Given that CRefine is still in progress and that the |
In my opinion we should definitely not do bigger breaking changes without properly strong reasons -- we have no way to even estimate how much impact that would have on current users who'd all need to update their code. |
This doesn't seem quite right to me yet. The current code doesn't update the flags in the null_cap case, which means that the syscall can't be used to unbind an sc. I guess there's multiple ways to do this, but how about moving the flags update to after the
That should also make it a no-op when trying to unbind a thread that is already unbound, which to me feels like the appropriate generalisation of the change we're already making. All of this would also let us remove the second half of the if statements at Lines 1876 to 1879 in 08cf7ee
|
The implementation of TCB_SetSchedParams did not follow the API reference, as it would fail if: a. The TCB already had a scheduling context, even if this was the same as the one being passed in. b. The scheduling context was bound to a TCB, even if this was the TCB that was invoked. Signed-off-by: Alwin Joshy <[email protected]>
We no longer need to check this as the previous commit changed decodeSetSchedParams to only pass the thread_control_sched_update_sc flag if these conditions are true. Signed-off-by: Alwin Joshy <[email protected]>
08cf7ee
to
57a057e
Compare
Thanks for picking up on that, I think you're right. I've updated the flags update as you suggested and changed the checks in tcb.c in a separate commit. |
The implementation of TCB_SetSchedParams did not
follow the API reference, as it would fail if:
a. The TCB already had a scheduling context, even
if this was the same as the one being passed in.
b. The scheduling context was bound to a TCB, even
if this was the TCB that was invoked.
This commit allows TCB_SetSchedParams allows the
invoked TCB's already bound scheduling context to
be passed in as described the API reference.
Closes: #1311