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: Move PROCS
array to Kernel
struct
#1111
Conversation
04ca10e
to
048c183
Compare
Is there a rough estimate on when this will be merged? Danilo and I are looking into parameterizing Also Brad, Amit mentioned that you're working on making Thanks! |
Check out #1113 |
If you can try #1046 on an imix that would help. |
As a part of rebasing this I was able to remove quite a few I also changed grant.rs to use |
This removes the need for the static PROCS array.
These were derived before but since the AppId struct had to be expanded they have to be explicitely defined before.
There is no longer a static reference to it in the kernel crate.
Ok! Please have a look at this PR. |
One idea that has been floated is changing how grants are created for capsules from: let grant = kernel::Grant::create(board_kernel); to let grant = board_kernel.create_grant(); That would have three benefits:
Thoughts? |
@bradjc I'm convinced |
This is beneficial because: 1. It makes the API a little more consistent, and makes it clear that board_kernel (the &kernel::Kernel) is the main access to the kernel API. .kernel_loop() is also called from the Kernel struct. 2. It simplifies where the kernel API is defined. What operations does the kernel provide? Look at the pub functions in the impl Kernel block. Note: this is different than the interfaces and tools the kernel provides (like StaticRef, Component, etc., and the HIL interfaces). 3. It would be straightforward to move the static variable CONTAINER_COUNTER to the Kernel struct. Doing this would allow the kernel to verify that no grants are created after processes are created (which would be invalid if any code tried to do that because no space would be reserved for them in the process).
If you want to see it in code form it is here: 70f53ca |
Doc updates are in #1113, this pr is really more of a refactor. |
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.
I thought it was a little weird for app slices to hold references to the kernel which then does a lookup for the process, rather than just directly holding a reference to the process. I started trying to implement the latter on top of this and it proved a more substantial change (can/will follow-on as a subsequent improvement). This is a good step in a good direction and looks good to me.
This last change, from holding a reference to the As is, there is nothing checking that this In general, it could be possible to just explicitly check that the process being referred to is the same version: replacing the idx field with a random/monotonically increasing value for each new instance of a process and comparing that with a field in the process struct. However, indirecting through a |
kernel/src/callback.rs
Outdated
pub struct AppId { | ||
crate process: &'static Process<'static>, |
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.
I think this is a dangerous change, and that it should be reverted to storing a reference to the Kernel
Removed the commit. It will probably make sense to move to a more opaque "idx" in AppId/Process soon. |
@bradjc agreed! |
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.
I would like us to update the CHANGELOG in this PR, but if @bradjc wants to do that in bullk with one or two more PRs, that's OK with me.
I added updating the changelog as a todo item in the tracking PR. Otherwise I think it will get rewritten multiple times with the series of PRs and any potential changes. |
Looks good! |
1113: Move architecture-dependent syscall code to arch/cortex-m r=bradjc a=bradjc ### Pull Request Overview This pull request moves all of the code that is cortex-m syscall specific out of process.rs and into the cortex-m crate. This is part of #985. It does this by: - Making a new `SyscallInterface` trait that is implemented in the cortex-m crate. Each process has a reference to the implementing struct. - Making a new `ProcessType` trait that all process types implement (right now we only have one, `Process` in process.rs). This allows the `Process` struct to be templated over the `SyscallInterface` type while the `processes` array in the `Kernel` struct keeps an array of `ProcessType` implementations: ```rust Kernel { processes: &'static [Option<&'static process::ProcessType>] } ``` which means the template parameter stays only in the process.rs file and does not spread to all of Tock. The panic! prints in process.rs are partially commented out because they relied on many architecture-specific fields. Also the `SCB_REGISTERS` global static variable still exists. Moving those to the cortex-m crate is forthcoming in a different PR. This is blocked on #1111. ### Testing Strategy Hail on Hail, but needs more. ### TODO or Help Wanted n/a ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make formatall`. Co-authored-by: Brad Campbell <bradjc5@gmail.com> Co-authored-by: Pat Pannuto <pat.pannuto@gmail.com>
Pull Request Overview
As a part of #1043, this moves the PROCS array to no longer be a static global variable but instead be a member of the
Kernel
struct. This is needed for at least three reasons:Process
type needs to be templated across architectures, and that doesn't seem possible with the static array (because the kernel crate doesn't know what type it will actually be).unsafe
to access.After #1109, this is relatively straightforward, with a couple things of note:
Kernel
struct, many data structures need to keep a reference to the kernel struct, and these have been added.PROCS
array, so it must be passed in during a panic.This is blocked on #1046Testing Strategy
Running hail on hail.
TODO or Help Wanted
Update CHANGELOG
Test
Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.