-
Notifications
You must be signed in to change notification settings - Fork 182
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
Enable a panic-free Jefe for the first time #1938
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,9 +310,19 @@ impl idol_runtime::NotificationHandler for ServerImpl<'_> { | |
let mut next_task = 1; | ||
while let Some(fault_index) = kipc::find_faulted_task(next_task) { | ||
let fault_index = usize::from(fault_index); | ||
next_task = fault_index + 1; | ||
|
||
let status = &mut self.task_states[fault_index]; | ||
// This addition cannot overflow in practice, because the number | ||
// of tasks in the system is very much smaller than 2**32. So we | ||
// use wrapping add, because currently the compiler doesn't | ||
// understand this property. | ||
next_task = fault_index.wrapping_add(1); | ||
|
||
// Safety: `fault_index` is from the kernel, and the kernel will | ||
// not give us an out-of-range task index. | ||
// | ||
// TODO: it might be nice to fold this into a utility function | ||
// in kipc or something | ||
Comment on lines
+322
to
+323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, what are you imagining here? A newtype representing a validated task index that's in range? IIUC that would also mean having a newtype around a task states array in Or, am I misunderstanding the idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking maybe a wrapper for fn find_faulted_task_plusplus<T>(start: usize, array: &mut [T; NUM_TASKS]) -> Option<(NonZeroUsize, &mut T)>
You're not wrong about that, but since kipc is mostly intended for the use of the supervisor... if we find a genuinely repeating pattern, moving it into the crate isn't necessarily bad. This one might be too special purpose though, which is why I left a TODO instead of attempting to design it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh, that's much simpler than the API I had envisioned, that seems like a good idea!
Yeah, I think it's entirely reasonable for |
||
let status = | ||
unsafe { self.task_states.get_unchecked_mut(fault_index) }; | ||
|
||
// If we're aware that this task is in a fault state, don't | ||
// bother making a syscall to enquire. | ||
|
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.
take it or leave it: perhaps we ought to add something like:
at the top of
main.rs
?i realize that enabling them both will get a linker error anyway when humpty tries to link with the panic impl, but it might be nicer to actually tell the person who enabled both features the specific reason Jefe is trying to panic, rather than making them go and figure it out? not a huge deal though.