sel4-capdl-initializer: lazy SC rebind for passive#352
Conversation
Add `fn bind_ntfn` for `SchedContext`. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
7dbba7a to
561c46e
Compare
| if obj.bound_notification().is_none() { | ||
| panic!("A passive task must have its own Notification."); | ||
| } | ||
| let bound_notification_cap = | ||
| self.orig_cap::<cap_type::Notification>(obj.bound_notification().unwrap().object); |
There was a problem hiding this comment.
Use the let/Some destrucuturing (or match) here rather than is_none() and unwrap.
Also, if we do sc.bind_ntfn(), where is that SC from, if not obj.sc() and does that not imply that it is not none?
There was a problem hiding this comment.
sc in this context could be the initialiser's SC or the TCB's SC as created from the spec. Binding the Notification to the initialiser's SC wouldn't make sense so that's why I had the if obj.bound_notification().is_none() check.
There was a problem hiding this comment.
But I'm confused, you then do sc.bind_ntfn(bound_notification_cap)?; next?
There was a problem hiding this comment.
Wait my bad, in the original comment, sc would be either a Null cap or the TCB's SC as created from the spec.
Regardless, the if obj.sc().is_none() { check will make sure that sc is the TCB's SC.
Then bound_notification_cap is the TCB's Notification cap.
There was a problem hiding this comment.
Then I think we should be explicit and use let/Some for that as well instead of using the previous sc.
There was a problem hiding this comment.
Ok sounds good
There was a problem hiding this comment.
I meant bound_sc here on the next line, not still sc. No point unwrapping to an unused var.
Also, I'd suggest using this variant:
let Some(bound_sc) = obj.sc() else {
panic!("blah blah");
}
This removes the nested as you add more checks.
(Also, is panic!() the normal way that you do errors in rust-sel4?)
Implements lazy Scheduling Context rebind for passive tasks inside the capDL initialiser. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
561c46e to
d20b04c
Compare
Implements lazy Scheduling Context rebind for passive tasks inside the capDL initialiser.
Solves problems such as seL4/microkit#91