Skip to content

Commit 3237aba

Browse files
authored
Merge pull request #8 from mlp6/copilot/add-sequence-diagrams
Add sequence diagrams to Zephyr Threads & Kernel Events lecture and lab
2 parents 3037b17 + 66921f4 commit 3237aba

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

labs/zephyr-threads-events-lab.qmd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ to verify that your refactored code still works as expected.
7777
working with regard to what data to collect, how to analyze it, and how to
7878
present it in your notebook.
7979

80+
## Create a Sequence Diagram
81+
82+
- Create a [PlantUML](https://plantuml.com/sequence-diagram) sequence diagram
83+
that documents the interaction between your button ISR callback(s), the kernel
84+
event bit array, and your state machine thread when a button press event is
85+
detected and processed.
86+
87+
- Your sequence diagram should show all relevant participants and the
88+
chronological order of messages between them (refer to the sequence diagram
89+
covered in the Threads & Kernel Events lecture).
90+
91+
- Commit both the PlantUML source file (`.puml`) and the rendered image to your
92+
repository under a `docs/` directory.
93+
8094
### Merge-n-Tag this Refactored Kernel Events Code and Analysis
8195

8296
- Create a Merge Request to merge `kernel_events_refactor` into your `main`

slides/zephyr-threads-events.qmd

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,49 @@ extern void temp_too_high_thread(void *, void *, void *) {
162162
}
163163
```
164164

165+
## Sequence Diagrams for Thread Communication
166+
167+
- Sequence diagrams visualize how components **interact over time**.
168+
169+
- Useful for documenting the flow of messages between threads, ISR callbacks,
170+
and kernel services.
171+
172+
- Participants in a Zephyr firmware application may include:
173+
174+
- Threads (e.g., `main`, worker threads)
175+
176+
- ISR Callbacks
177+
178+
- Kernel Event Bit Arrays
179+
180+
- Kernel Timers
181+
182+
## PlantUML Sequence Diagram Example
183+
184+
```plantuml
185+
@startuml
186+
187+
participant "Button ISR\nCallback" as ISR
188+
participant "Kernel Event\nBit Array" as KEvents
189+
participant "Worker Thread" as Worker
190+
191+
Worker -> KEvents : k_event_wait()\n[blocking]
192+
activate Worker #LightBlue
193+
194+
note over ISR : Button Pressed
195+
ISR -> KEvents : k_event_post(BUTTON_EVENT)
196+
KEvents --> Worker : BUTTON_EVENT received
197+
deactivate Worker
198+
199+
Worker -> Worker : process event\n(e.g., change state)
200+
201+
@enduml
202+
```
203+
165204
## Resources
166205

167206
- [Nordic DevAcademy: Zephyr RTOS Advanced](https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-1-zephyr-rtos-advanced/)
168207

169-
- [Zephyr Documentation: Events](https://docs.zephyrproject.org/latest/kernel/services/synchronization/events.html#events)
208+
- [Zephyr Documentation: Events](https://docs.zephyrproject.org/latest/kernel/services/synchronization/events.html#events)
209+
210+
- [PlantUML: Sequence Diagrams](https://plantuml.com/sequence-diagram)

0 commit comments

Comments
 (0)