-
Notifications
You must be signed in to change notification settings - Fork 218
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
Editorial review of the V1.0 book text. #618
Conversation
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.
Thank you for taking the time to go through this!
I've commented on some of the smaller things, need to further study the part you've added to internal docs.
A hint, for example in the case where you had duplicate "the", you can push more commits to this branch which will update the Pull Request accordingly 👍
book/en/src/by-example/app_init.md
Outdated
`bare_metal::CriticalSection` token is available as `cs`) while device specific peripherals are available through | ||
the `core` and `device` fields of `init::Context`. | ||
The `init` task executes after system reset (after an optionally defined `pre-init` task/code section(?) | ||
and always occurring internal RTIC |
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.
Maybe even linking to pre_init?
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.
Don't understand the suggestion.
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 interpreted the (?) after "task/code section(?)" as seeking clarification / sources, my thought was that the link could be useful here, the link in the comment.
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.
Clear, added suggestion to text. Please check, never used that syntax.
Any available interrupt vector should work, but different hardware might have | ||
added special properties to select interrupt priority levels, such as the | ||
Any available interrupt vector should work. Specific devices may | ||
allow selection of interrupt priority level, such as the |
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.
allow selection of interrupt priority level, such as the | |
assume internal use of some interrupt priority levels, such as the |
Other suggestions welcome, but the main idea is that the user can't take any level as it is already being used by some other hardware component of that specific hardware.
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.
It was not clear to me what the message of the original text was. "added properties to select ... priority" -> "to allow selection of" was intended to mean the same and break the original sentence in distinct statements. Reading your comment I would word this possibly as "Specific hardware may bind specific interrupt priorities to specific interrupt vectors outside user code control." Or something like that...
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.
It was not clear to me what the message of the original text was. "added properties to select ... priority" -> "to allow selection of" was intended to mean the same and break the original sentence in distinct statements. Reading your comment I would word this possibly as "Specific hardware may bind specific interrupt priorities to specific interrupt vectors outside user code control." Or something like that...
^ Sounds good 👍
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.
Amended text.
@@ -4,7 +4,7 @@ | |||
|
|||
The `priority` argument declares the static priority of each `task`. | |||
|
|||
For Cortex-M, tasks can have priorities in the range `1..=(1 << NVIC_PRIO_BITS)` | |||
For Cortex-M, tasks can have priorities in the range `1..(1 << NVIC_PRIO_BITS)` |
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.
In Rust, ..=
indicates it is an inclusive range
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.
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.
If I recall correctly that is intentional, we can provide one more priority level by disabling the interrupts globally.
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 was not aware of the rangeinclusive notation. Thx.
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.
Maybe you fixed it, but for me it still shows as modified and =
is missing.
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.
Fixed.
I'm struggling with magit---pushing commits to jvanderk/cortex-m-rtic, but I'm not sure they are visible in the pull request. |
Please let me know if there are still open items. I am working on getting vigilant mode working. Apologies for 'unverified' flags. |
until task A completes execution. Thus, when task A completes task B resumes execution. | ||
|
||
```text | ||
Task Priority |
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.
Duplicated lines?
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.
Corrected.
# Conceptual view | ||
|
||
![Conceptual execution model](./conceptual_execution_model.png) | ||
|
||
This tries to provide a high level view of how tasks are managed in | ||
the RTIC context. It focuses on the execution flow. | ||
|
||
At its core, RTIC leverages the NVIC subsystem of the machine to | ||
enable time-deterministic control of code execution. | ||
|
||
There are two queues to think about. | ||
|
||
One queue is a software queue, which is a a set of FIFOs written in | ||
code and managed by the RTIC framework. Individual FIFOs are | ||
associated with different execution priority levels. | ||
|
||
The other is a hardware-controlled queue maintained by the NVIC. If | ||
there are two hardware interrupts pending, the highest priority code | ||
will execute first: a "priority queue" at a hardware level. | ||
|
||
The NVIC operates essentially independently of the CPU, outside of | ||
the various masking and other registers that the CPU can use to ignore | ||
specific interrupt sources. | ||
|
||
(Are HW interrupts always of different priority? Does the HW maintain | ||
memory of lower or same priority level interrupts to process them once | ||
they become eligible?) | ||
|
||
So, a hardware task initiated by and bound to a hardware interrupt is | ||
controlled by the NVIC's queuing mechanism without direct involement | ||
of the processor; a software-spawned task just gets put into the task | ||
FIFO (at some priority level) for later execution whenever the current | ||
execution priority level is low enough. If a hardware or software task | ||
completes, RTIC checks the software queue for more tasks to run, | ||
eventually completing all until the queue exhausts and the IDLE task | ||
then takes over again. | ||
|
||
The CPU's ability to set a "minimum priority level" of hardware | ||
interrupts allows alignment of the software and hardware queues. This | ||
masks hardware-level interrupts coming in while equal or higher | ||
priority level software tasks are exectuting. It makes the NVIC keep | ||
the hardware tasks interrupt pending until the software task ends (and | ||
the CPU has lowered the minimum priority level of interrupt acceptance). | ||
|
||
## Hardware queue: NVIC | ||
|
||
There is a difference between a software-initiated context switch | ||
(which is a function call in code) and an interrupt (NVIC) initiated | ||
switch. When the NVIC generates an interrupt request, this physically | ||
breaks the execution flow of the processor. | ||
|
||
## Software queue: task dispatchers | ||
|
||
The software queues are maintained by task dispatchers. They can be | ||
thought of as "pre-wired" hardware tasks initiated by the NVIC. | ||
|
||
Each task dispatcher keeps a queue of tasks which are ready to | ||
execute; this queue is referred to as the ready queue. Spawning a | ||
software task consists of adding an entry to this queue and pending | ||
the interrupt that runs the corresponding task dispatcher. Each entry | ||
in this queue contains a tag (enum) that identifies the task to | ||
execute and a pointer to the message passed to the task. | ||
|
||
You can think of the dispatchers as just calling the SW tasks as | ||
functions. | ||
|
||
The ready queue is a SPSC (Single Producer Single Consumer) lock-free | ||
queue. The task dispatcher owns the consumer endpoint of the queue; | ||
the producer endpoint is treated as a resource contended by the tasks | ||
that can spawn other tasks. source: [Software tasks - Real-Time | ||
Interrupt-driven | ||
Concurrency](https://rtic.rs/0.5/book/en/internals/tasks.html). | ||
|
||
## spawning | ||
|
||
Any task may influence the execution context via the "spawn" API, | ||
adding tasks to the queues for later execution. | ||
|
||
The defined priority of the task spawned determines the queue it lands | ||
in. |
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 would be best split out into a separate PR, as this is not part of the editorial review but entirely new content.
Included in this would be all the files added under internals
It would also simplify your work with git and tooling.
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.
Makes sense. I will try to remove these changes from this branch (not sure if that is correct terminology), open a new branch against the root of this branch and open a new pull request on that. Big adventure :-)
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.
This pull request should now only contain editorial changes. The conceptual model related text and graphics will be put into another pull request.
I am not sure if the history in this pull request will survive, if so if that is desirable or if that can be squashed out.
![Conceptual execution model](./conceptual_execution_model.svg) |
Made change and moved files to other pull request. |
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.
Nice!
A few questions, but really nice in general :)
book/en/src/SUMMARY.md
Outdated
@@ -29,6 +29,7 @@ | |||
- [v0.4.x to v0.5.x](./migration/migration_v4.md) | |||
- [RTFM to RTIC](./migration/migration_rtic.md) | |||
- [Under the hood](./internals.md) | |||
- [Conceptual execution model](./internals/conceptual_view.md) |
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 should go with the other PR :)
book/en/src/SUMMARY.md
Outdated
|
||
(XXX would it be a good idea to add a section on code organization, | ||
i.e. how to break a larger application into a set of files? XXX) |
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.
Same here as above
At its core RTIC is using the hardware interrupt controller ([ARM NVIC on cortex-m][NVIC]) | ||
to perform scheduling and executing tasks, and all tasks except `#[init]` and `#[idle]` | ||
At its core RTIC is using a hardware interrupt controller ([ARM NVIC on cortex-m][NVIC]) | ||
to schedule and start execution of tasks. All tasks except `pre-init`, `#[init]` and `#[idle]` |
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.
Did we want some kind of link for the somewhat special pre-init
, not RTIC specific, but cortex-m-rt #[pre_init]
?
https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.pre_init.html
Forgot that GitHub doesn't like that kind of move, Gerrit influences from work I guess xD Will look into this during the day... |
686: Book: Editorial review r=korken89 a=AfoHT Continuation of #618 Better late than never... A big thanks to `@jvanderk` ! Co-authored-by: John van der Koijk <[email protected]>
Editorial change proposals for V1.0 book text, English version only.