feat: add lab-rv32i-freertos-sw-timer card
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# K14 — Software timer and the timer daemon task
|
||||
|
||||
## Position
|
||||
|
||||
- Series: FreeRTOS C++
|
||||
- Lesson: L13, card K14
|
||||
- Duration: 30 minutes
|
||||
- Policies: one-shot and periodic
|
||||
- Static timer/task storage; heap delta zero
|
||||
|
||||
## Outcome
|
||||
|
||||
The student separates command queue acceptance from callback execution,
|
||||
observes timer-daemon context, measures one-shot and periodic timelines, and
|
||||
states the lifetime contract for a typed callback context.
|
||||
|
||||
## Lesson plan
|
||||
|
||||
| Time | Mode | Evidence |
|
||||
| --- | --- | --- |
|
||||
| 0–5 | wrapper contract | non-copy, explicit start, typed context |
|
||||
| 5–10 | command queue | two starts accepted before scheduler, callbacks zero |
|
||||
| 10–15 | initial timeline | periodic ticks 2 and 4 |
|
||||
| 15–20 | reset/change | one-shot reset at 1 expires at 6; period 2→3 at 4 |
|
||||
| 20–25 | daemon proof | current handle/name and separate callback stack |
|
||||
| 25–30 | stop/lifetime | periodic tick 7, then inactive; no fourth callback |
|
||||
|
||||
## Acceptance
|
||||
|
||||
- OneShotTimer and PeriodicTimer encode reload policy in the type;
|
||||
- wrapper is neither copyable nor movable and start is explicit;
|
||||
- xTimerCreateStatic uses caller-owned control blocks in .bss;
|
||||
- both start commands return accepted while callback snapshot is still zero;
|
||||
- reset/change/stop acceptance is recorded separately from execution;
|
||||
- periodic callback ticks are exactly 2, 4 and 7;
|
||||
- reset at tick 1 moves one-shot expiry to tick 6 and it becomes inactive;
|
||||
- callback runs on timer daemon handle/name and a separate stack;
|
||||
- stopping the periodic timer prevents a fourth callback;
|
||||
- heap before/after timer creation is identical and target exits with PASS.
|
||||
|
||||
## Main traps
|
||||
|
||||
1. A callback runs in the timer service task, not in an ISR.
|
||||
2. pdPASS means the daemon queue accepted a command, not that it executed.
|
||||
3. Blocking or long work in one callback delays every software timer.
|
||||
4. Timer ID/context and StaticTimer_t storage must outlive pending work.
|
||||
5. Destroying a wrapper cannot synchronously prove queued deletion completed.
|
||||
@@ -0,0 +1,344 @@
|
||||
% Generated from json/card_source.json by tools/render_card.py.
|
||||
% Do not edit manually; update the JSON and regenerate.
|
||||
|
||||
\documentclass[12pt,a4paper]{article}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{lmodern}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[polish]{babel}
|
||||
\usepackage{csquotes}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[a4paper,left=2.15cm,right=2.15cm,top=0.5cm,bottom=0.5cm,headheight=24mm,headsep=3mm,includehead]{geometry}
|
||||
\usepackage{eso-pic}
|
||||
\usepackage{marginnote}
|
||||
\usepackage{array}
|
||||
\usepackage{tabularx}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{pdflscape}
|
||||
\usepackage{float}
|
||||
\usepackage{silence}
|
||||
\WarningFilter{soulutf8}{This package is obsolete}
|
||||
\usepackage{pdfcomment}
|
||||
\usepackage{enumitem}
|
||||
\usepackage{needspace}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{lastpage}
|
||||
\usepackage{microtype}
|
||||
\usepackage[most]{tcolorbox}
|
||||
\usepackage{qrcode}
|
||||
\IfFileExists{references.bib}{%
|
||||
\usepackage[backend=biber,style=numeric,sorting=none]{biblatex}%
|
||||
\addbibresource{references.bib}%
|
||||
}{}
|
||||
|
||||
\hypersetup{hidelinks}
|
||||
|
||||
\IfFileExists{build-meta.tex}{%
|
||||
\input{build-meta.tex}%
|
||||
}{%
|
||||
\newcommand{\BuildCommit}{lokalna}%
|
||||
}
|
||||
|
||||
\newcommand{\DocumentAuthor}{M. Pabiszczak}
|
||||
\newcommand{\DocumentYear}{2026}
|
||||
\newcommand{\CardSeries}{freertos-cpp}
|
||||
\newcommand{\CardNumber}{14}
|
||||
\newcommand{\CardCount}{16}
|
||||
\newcommand{\CardSlug}{sw-timer}
|
||||
\newcommand{\CardVersion}{v00.01}
|
||||
\newcommand{\DocumentUUID}{78db37df-63e5-4c5b-80ce-f73a411f0b50}
|
||||
|
||||
\newcommand{\EmptyCheck}{\(\square\)}
|
||||
\newcommand{\EscAnswerLines}[1][3]{\par\noindent\dotfill\par\noindent\dotfill\par\noindent\dotfill}
|
||||
\newcommand{\EscWriteRow}[1][2.8em]{\rule{0pt}{#1}}
|
||||
\setlength{\parindent}{0pt}
|
||||
\setlength{\parskip}{0.45em}
|
||||
\setlength{\headheight}{24mm}
|
||||
\setlength{\headsep}{3mm}
|
||||
\setlength{\footskip}{8mm}
|
||||
\setlength{\marginparwidth}{1.5cm}
|
||||
\setlength{\marginparsep}{0.25cm}
|
||||
\renewcommand{\arraystretch}{1.22}
|
||||
% Margin separator lines disabled for layout trial.
|
||||
|
||||
\newcommand{\ESCPageResourceHeader}{%
|
||||
\begingroup%
|
||||
\setlength{\parskip}{0pt}%
|
||||
\setlength{\fboxsep}{0pt}%
|
||||
\setlength{\fboxrule}{0.35pt}%
|
||||
\setlength{\arrayrulewidth}{0.35pt}%
|
||||
\noindent\fbox{%
|
||||
\begin{minipage}[c][23.5mm][c]{\dimexpr\textwidth-2\fboxrule\relax}%
|
||||
\begin{minipage}[c][23mm][c]{\dimexpr\linewidth-24mm-0.35pt\relax}%
|
||||
\setlength{\tabcolsep}{0pt}%
|
||||
\renewcommand{\arraystretch}{0}%
|
||||
\begin{tabularx}{\linewidth}{@{}p{\dimexpr0.50000000\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.15126050\linewidth-\arrayrulewidth\relax}|X@{}}%
|
||||
\parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries TITLE}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{7.7}{7.9}\selectfont\ttfamily\bfseries Software Timer and the Timer Daemon Task}\hspace{0.45mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries VER.}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{6.6}{6.8}\selectfont\ttfamily\bfseries v00.01}\hspace{0.45mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries DATETIME}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{6.4}{6.6}\selectfont\ttfamily\bfseries 2026-07-19T00:00:00+02:00}\hspace{0.45mm}}\par} \\%
|
||||
\end{tabularx}%
|
||||
\par\nointerlineskip%
|
||||
\hrule height0.35pt%
|
||||
\nointerlineskip%
|
||||
\begin{tabularx}{\linewidth}{@{}p{\dimexpr0.50000000\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.25210084\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.14285714\linewidth-\arrayrulewidth\relax}|X@{}}%
|
||||
\parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries PROJECT}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{7.7}{7.9}\selectfont\ttfamily\bfseries Freestanding C++ nad FreeRTOS}\hspace{0.45mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries SERIES}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{6.4}{6.6}\selectfont\ttfamily\bfseries FreeRTOS C++}\hspace{0.45mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries CARD}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{6.4}{6.6}\selectfont\ttfamily\bfseries 14/16}\hspace{0.45mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{3.2}{3.4}\selectfont\ttfamily\bfseries SHEET}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{6.4}{6.6}\selectfont\ttfamily\bfseries \thepage/\pageref{LastPage}}\hspace{0.45mm}}\par} \\%
|
||||
\end{tabularx}%
|
||||
\par\nointerlineskip%
|
||||
\hrule height0.35pt%
|
||||
\nointerlineskip%
|
||||
\begin{tabularx}{\linewidth}{@{}p{\dimexpr0.05882353\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.05042017\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.14705882\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.09243697\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.07563025\linewidth-\arrayrulewidth\relax}|p{\dimexpr0.07563025\linewidth-\arrayrulewidth\relax}|X@{}}%
|
||||
\parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries SUBJ.}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries Inf.}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries PROG.}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries —}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries CORE}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries —}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries SCOPE}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries —}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries LEVEL}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries —}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hspace{0.15mm}{\fontsize{2.85}{3}\selectfont\ttfamily\bfseries POS.}\par\nointerlineskip\vspace{0.12mm}\noindent\makebox[\linewidth][r]{{\fontsize{4.45}{4.65}\selectfont\ttfamily\bfseries —}\hspace{0.15mm}}\par} & \parbox[c][5.19414mm][c]{\linewidth}{\hbox to\linewidth{\hspace{0.35mm}{\fontsize{3.4}{3.75}\selectfont\ttfamily\bfseries GITEA UUID}\hfill{\fontsize{3.4}{3.75}\selectfont\ttfamily 78db37df-63e5-4c5b-80ce-f73a411f0b50}\hspace{0.35mm}}\par\nointerlineskip\hbox to\linewidth{\hspace{0.35mm}{\fontsize{3.4}{3.75}\selectfont\ttfamily\bfseries CARD UUID} {\fontsize{3.4}{3.75}\selectfont\ttfamily 78db37df-63e5-4c5b-80ce-f73a411f0b50}\hfill{\fontsize{3.4}{3.75}\selectfont\ttfamily\bfseries AUTHOR M. Pabiszczak}\hspace{0.35mm}}} \\%
|
||||
\end{tabularx}%
|
||||
\par\nointerlineskip%
|
||||
\hrule height0.35pt%
|
||||
\nointerlineskip%
|
||||
\begin{tabularx}{\linewidth}{@{}X@{}}%
|
||||
\parbox[c][3.46276mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{4.5}{4.85}\selectfont\ttfamily\bfseries GITEA} {\fontsize{4.5}{4.85}\selectfont\ttfamily\href{https://zsl-gitea.mpabi.pl/edu-freertos-cpp/lab-rv32i-freertos-sw-timer}{\nolinkurl{https://zsl-gitea.mpabi.pl/edu-freertos-cpp/lab-rv32i-freertos-sw-timer}}}} \\%
|
||||
\end{tabularx}%
|
||||
\par\nointerlineskip%
|
||||
\hrule height0.35pt%
|
||||
\nointerlineskip%
|
||||
\begin{tabularx}{\linewidth}{@{}X@{}}%
|
||||
\parbox[c][3.46276mm][c]{\linewidth}{\hspace{0.45mm}{\fontsize{4.5}{4.85}\selectfont\ttfamily\bfseries HTML} {\fontsize{4.5}{4.85}\selectfont\ttfamily\href{}{\nolinkurl{}}}} \\%
|
||||
\end{tabularx}%
|
||||
\end{minipage}%
|
||||
\vrule width0.35pt%
|
||||
\begin{minipage}[c][23mm][c]{24mm}\centering%
|
||||
{\tiny QR wyłączony}%
|
||||
\end{minipage}%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\endgroup%
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
\fancyhf{}
|
||||
\fancyhead[C]{\ESCPageResourceHeader}
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\renewcommand{\footrulewidth}{0pt}
|
||||
|
||||
\newcommand{\ESCMarginTag}[4]{%
|
||||
\hspace*{#1}\textcolor{#2}{#3~#4}%
|
||||
}
|
||||
\newcommand{\ESCSectionBlockStart}{%
|
||||
\Needspace{8\baselineskip}%
|
||||
\par\vspace{0.35em}%
|
||||
\noindent\textcolor{black!28}{\rule{\textwidth}{0.35pt}}%
|
||||
\par\vspace{0.15em}%
|
||||
}
|
||||
\newcommand{\ESCSectionBlockEnd}{%
|
||||
\par\vspace{0.25em}%
|
||||
\noindent\textcolor{black!18}{\rule{\textwidth}{0.25pt}}%
|
||||
\par\vspace{0.45em}%
|
||||
}
|
||||
\newcommand{\ESCTinyStepSeparator}{%
|
||||
\par\vspace{0.10em}%
|
||||
\noindent{\color{black!18}\leaders\hbox{\rule{0.60em}{0.22pt}\hspace{0.38em}}\hfill\kern0pt}%
|
||||
\par\vspace{0.10em}%
|
||||
}
|
||||
\newtcolorbox{ESCTaskFrame}[1]{enhanced,breakable,arc=0pt,boxrule=0.35pt,colback=white,colframe=black,boxsep=0pt,left=1.4mm,right=1.4mm,top=0.8mm,bottom=0.8mm,colbacktitle=black!7,coltitle=black,title={\ttfamily\bfseries TASK\quad #1}}
|
||||
\newtcolorbox{ESCBlockFrame}[1]{enhanced,breakable,arc=0pt,boxrule=0.35pt,colback=white,colframe=black!55,boxsep=0pt,left=1.0mm,right=1.0mm,top=0.6mm,bottom=0.6mm,colbacktitle=black!4,coltitle=black,title={\ttfamily\bfseries BLOCK\quad #1}}
|
||||
\newtcolorbox{ESCStepFrame}[1]{enhanced,breakable,arc=0pt,boxrule=0.35pt,colback=white,colframe=black!28,boxsep=0pt,left=0.8mm,right=0.8mm,top=0.45mm,bottom=0.45mm,colbacktitle=black!2,coltitle=black,title={\ttfamily STEP\quad #1}}
|
||||
\newtcolorbox{ESCConclusionFrame}{enhanced,breakable,arc=0pt,boxrule=0.45pt,colback=blue!2,colframe=blue!45!black,boxsep=0pt,left=1.2mm,right=1.2mm,top=0.7mm,bottom=0.7mm,colbacktitle=blue!7,coltitle=black,title={\ttfamily\bfseries WNIOSEK}}
|
||||
|
||||
\newcommand{\ESCLearningTreeWidget}{%
|
||||
\reversemarginpar
|
||||
\marginnote[%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\begin{minipage}[t]{\marginparwidth}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{TECH}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\hspace*{0.28em}\textcolor{orange!85!black}{EK~LOCAL~DBG.TIMER}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Mierzy expiry ticks, activity, daemon handle/name, stack i heap.}}\par%
|
||||
\hspace*{0.54em}\textcolor{blue!70!black}{KW~LOCAL~DBG.TIMER}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Pokazuje ticks 2/4/6/7, inactive after expiry/stop, Tmr Svc i PASS.}}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
]{}
|
||||
\normalmarginpar
|
||||
|
||||
\marginnote{%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\hspace*{0.06cm}%
|
||||
\begin{minipage}[t]{\dimexpr\marginparwidth-0.06cm\relax}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{OG}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\hspace*{0.28em}\textcolor{green!50!black}{EN~LOCAL~EN~RTOS.TIMER}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Analizuje kolejkę, daemon, blocking callback i lifetime contextu.}}\par%
|
||||
\hspace*{0.54em}\textcolor{blue!70!black}{KW~LOCAL~KW~RTOS.TIMER}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Nie utożsamia pdPASS z callback completion i chroni storage/context przed premature\textCR destruction.}}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\sloppy
|
||||
|
||||
\vspace{1.0em}
|
||||
\noindent{\Large\bfseries Cel karty}\par
|
||||
\vspace{0.35em}
|
||||
Uczeń rozdziela przyjęcie polecenia do timer queue od wykonania callbacku, mierzy one-shot/periodic timeline i dowodzi kontekstu timer daemon task.
|
||||
|
||||
\vspace{0.8em}
|
||||
\noindent\textcolor{black!25}{\rule{\textwidth}{0.35pt}}
|
||||
\vspace{0.7em}
|
||||
\noindent{\Large\bfseries Zakres karty}\par
|
||||
\vspace{0.35em}
|
||||
Software timer nie jest ISR. Callback współdzieli daemon task z innymi timerami; storage i typed context muszą przeżyć wszystkie pending commands i callbacks.
|
||||
|
||||
\vspace{0.8em}
|
||||
\noindent\textcolor{black!25}{\rule{\textwidth}{0.35pt}}
|
||||
|
||||
\clearpage
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Typed policy i command queue}
|
||||
\reversemarginpar
|
||||
\marginnote[%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\begin{minipage}[t]{\marginparwidth}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{TECH}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
]{}[-3.1em]
|
||||
\normalmarginpar
|
||||
|
||||
\marginnote{%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\hspace*{0.06cm}%
|
||||
\begin{minipage}[t]{\dimexpr\marginparwidth-0.06cm\relax}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{OG}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
}[-3.1em]
|
||||
|
||||
|
||||
\begingroup
|
||||
\scriptsize\ttfamily\color{black!60}\sloppy
|
||||
\noindent drzewka: \pdftooltip[width=\textwidth]{D1}{K14.WE01.TECH.LOCAL.DBG.TIMER.01 | WE 01: Software timer i daemon. Implementacja i dowód\textCR typed software timers na współdzielonym timer daemon tasku. | EK LOCAL DBG.TIMER.01: Mierzy\textCR expiry ticks, activity, daemon handle/name, stack i heap. | KW LOCAL DBG.TIMER.01: Pokazuje\textCR ticks 2/4/6/7, inactive after expiry/stop, Tmr Svc i PASS.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Potwierdź dwa accepted commands i zero callbacków przy return.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Zmierz initial periodic expiries 2 i 4.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Utwórz static OneShotTimer i PeriodicTimer, wyłącz copy/move, wykonaj explicit start przed schedulerem i zapisz callback snapshot.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Reset, change-period i stop}
|
||||
\reversemarginpar
|
||||
\marginnote[%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\begin{minipage}[t]{\marginparwidth}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{TECH}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
]{}[-3.1em]
|
||||
\normalmarginpar
|
||||
|
||||
\marginnote{%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\hspace*{0.06cm}%
|
||||
\begin{minipage}[t]{\dimexpr\marginparwidth-0.06cm\relax}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{OG}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
}[-3.1em]
|
||||
|
||||
|
||||
\begingroup
|
||||
\scriptsize\ttfamily\color{black!60}\sloppy
|
||||
\noindent drzewka: \pdftooltip[width=\textwidth]{D1}{K14.WE01.TECH.LOCAL.DBG.TIMER.01 | WE 01: Software timer i daemon. Implementacja i dowód\textCR typed software timers na współdzielonym timer daemon tasku. | EK LOCAL DBG.TIMER.01: Mierzy\textCR expiry ticks, activity, daemon handle/name, stack i heap. | KW LOCAL DBG.TIMER.01: Pokazuje\textCR ticks 2/4/6/7, inactive after expiry/stop, Tmr Svc i PASS.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Pokaż one-shot expiry 6 i periodic expiry 7.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Pokaż brak czwartego callbacku po stop.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Resetuj one-shot w ticku 1, zmień periodic z 2 na 3 w ticku 4, a po trzecim callbacku wyślij stop i potwierdź inactive.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Daemon context, storage i lifetime}
|
||||
\reversemarginpar
|
||||
\marginnote[%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\begin{minipage}[t]{\marginparwidth}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{TECH}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
]{}[-3.1em]
|
||||
\normalmarginpar
|
||||
|
||||
\marginnote{%
|
||||
\begin{minipage}{\marginparwidth}%
|
||||
\raggedright
|
||||
{\fontsize{3.55}{3.95}\selectfont\ttfamily
|
||||
\hspace*{0.06cm}%
|
||||
\begin{minipage}[t]{\dimexpr\marginparwidth-0.06cm\relax}%
|
||||
\raggedright
|
||||
{\bfseries\textcolor{black!65}{OG}\par}%
|
||||
\vspace{0.08em}%
|
||||
\hspace*{0.00em}\textcolor{red}{WE~01}\textcolor{black!48}{}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
}[-3.1em]
|
||||
|
||||
|
||||
\begingroup
|
||||
\scriptsize\ttfamily\color{black!60}\sloppy
|
||||
\noindent drzewka: \pdftooltip[width=\textwidth]{D1}{K14.WE01.OG.LOCAL.RTOS.TIMER.01 | WE 01: Software timer i daemon. Implementacja i dowód\textCR typed software timers na współdzielonym timer daemon tasku. | EN LOCAL RTOS.TIMER.01:\textCR Analizuje kolejkę, daemon, blocking callback i lifetime contextu. | KW LOCAL RTOS.TIMER.01:\textCR Nie utożsamia pdPASS z callback completion i chroni storage/context przed premature\textCR destruction.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Udowodnij Tmr Svc, osobny stack i heap delta 0.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Wyjaśnij zakaz blocking callback i premature destruction.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Porównaj current task z timer daemon handle/name, stos callbacku ze stosem verifiera oraz heap przed/po static create; sformułuj lifetime contract.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\end{document}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
\documentclass[10pt]{article}
|
||||
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage[polish]{babel}
|
||||
\usepackage[a4paper,margin=1.55cm]{geometry}
|
||||
\usepackage{array,tabularx,booktabs,amsmath,amssymb,xcolor,listings,hyperref,fancyhdr,lastpage,enumitem}
|
||||
\definecolor{accent}{HTML}{16324A}\definecolor{accentlight}{HTML}{EEF3F7}\definecolor{rulegray}{HTML}{D7DEE5}
|
||||
\hypersetup{colorlinks=true,linkcolor=accent,urlcolor=blue}
|
||||
\IfFileExists{build-meta.tex}{\input{build-meta.tex}}{\newcommand{\BuildCommit}{local}}
|
||||
\newcommand{\PublisherDomain}{mpabi}
|
||||
\newcommand{\CardArea}{inf}
|
||||
\newcommand{\CardSeries}{freertos-cpp}
|
||||
\newcommand{\CardNumber}{14}
|
||||
\newcommand{\CardCount}{16}
|
||||
\newcommand{\CardSlug}{sw-timer}
|
||||
\newcommand{\CardVersion}{v00.01}
|
||||
\newcommand{\DocumentUUID}{78db37df-63e5-4c5b-80ce-f73a411f0b50}
|
||||
\newcommand{\blank}[1]{\rule{#1}{.2pt}}
|
||||
\lstset{language=C++,basicstyle=\ttfamily\scriptsize,columns=fullflexible,keepspaces=true,frame=single,breaklines=true,showstringspaces=false,numbers=none,backgroundcolor=\color{accentlight},rulecolor=\color{rulegray}}
|
||||
\pagestyle{fancy}\fancyhf{}
|
||||
\lhead{\textbf{K14 · FreeRTOS C++ · SoftwareTimer}}\rhead{\small L13 · timer daemon task}
|
||||
\lfoot{\scriptsize commit \BuildCommit}\cfoot{\scriptsize \thepage/\pageref{LastPage}}\rfoot{\scriptsize V11.3.0 / \CardVersion}
|
||||
\setlength{\headheight}{14pt}\setlength{\footskip}{19pt}
|
||||
\setlist[itemize]{nosep,leftmargin=1.45em}\setlist[enumerate]{nosep,leftmargin=1.65em}
|
||||
\begin{document}\sloppy
|
||||
\begin{center}
|
||||
{\LARGE\bfseries Software timer i timer daemon task}\par
|
||||
\vspace{.25em}{\large one-shot, periodic, command queue i typed callback context}\par
|
||||
\end{center}
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{1.65cm}Xp{1.75cm}X@{}}
|
||||
\toprule
|
||||
Karta & K14 / \CardCount & Czas & 30 minut \\
|
||||
Platforma & Hazard3 / RV32I & Kernel & FreeRTOS V11.3.0 \\
|
||||
Timery & static one-shot + periodic & Heap delta & 0 B \\
|
||||
Wersja & \CardVersion & UUID karty & \texttt{78db37df-...} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Polityka jest częścią typu}
|
||||
\begin{lstlisting}
|
||||
OneShotTimer<Probe> one(storage1, "one", 5, probe1);
|
||||
PeriodicTimer<Probe> cycle(storage2, "cycle", 2, probe2);
|
||||
auto accepted = cycle.start(); // command queue
|
||||
// callback jeszcze nie musi byc wykonany
|
||||
\end{lstlisting}
|
||||
|
||||
\noindent\fcolorbox{accent}{accentlight}{\begin{minipage}{.94\textwidth}
|
||||
\textbf{Kontrakt K14.} Wrapper nie jest copy/move. \texttt{start/reset/change/stop}
|
||||
zwracają przyjęcie polecenia przez kolejkę daemona. Callback działa później na
|
||||
współdzielonym timer service tasku, a context i storage muszą nadal istnieć.
|
||||
\end{minipage}}
|
||||
|
||||
\section*{Plan 30 minut}
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{1.35cm}p{3.1cm}X@{}}
|
||||
\toprule Czas & Tryb & Dowód \\
|
||||
\midrule
|
||||
0--5 & contract & non-copy, typed policy, explicit start \\
|
||||
5--10 & queue & 2 start accepted; callback snapshot 0 \\
|
||||
10--15 & periodic & callback w tickach 2 i 4 \\
|
||||
15--20 & commands & reset@1, change 2--3@4 \\
|
||||
20--25 & daemon & handle/name, osobny stos \\
|
||||
25--30 & stop/lifetime & tick 7, inactive, bez 4. callbacku \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Predykcja}
|
||||
Czy \texttt{pdPASS} ze start oznacza wykonany callback? \blank{2cm}.
|
||||
Gdzie callback się wykona: ISR, caller czy daemon? \blank{4cm}.
|
||||
|
||||
\newpage
|
||||
\section{Kolejka poleceń a wykonanie}
|
||||
|
||||
\begin{center}
|
||||
\texttt{main: start(one), start(periodic) -- accepted, callbacks=0}\\
|
||||
$\downarrow$ \texttt{scheduler + Tmr Svc processes commands}\\
|
||||
$\downarrow$ \texttt{expiry -- daemon invokes typed trampoline}
|
||||
\end{center}
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{5.2cm}p{3.1cm}X@{}}
|
||||
\toprule Pomiar & Predykcja & Odczyt \\
|
||||
\midrule
|
||||
start commands accepted & 2 & \blank{2.5cm} \\
|
||||
callbacks przy return ze start & 0 & \blank{2.5cm} \\
|
||||
verifier entry tick & 0 & \blank{2.5cm} \\
|
||||
periodic first expiry & 2 & \blank{2.5cm} \\
|
||||
periodic second expiry & 4 & \blank{2.5cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section{Reset one-shot i zmiana okresu}
|
||||
\begin{lstlisting}
|
||||
// tick 1
|
||||
one.reset(); // new expiry: 1 + 5 = 6
|
||||
// tick 4, after periodic callbacks 2 and 4
|
||||
cycle.change_period(3); // next expiry: 4 + 3 = 7
|
||||
\end{lstlisting}
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{5.2cm}p{3.1cm}X@{}}
|
||||
\toprule Pomiar & Predykcja & Odczyt \\
|
||||
\midrule
|
||||
reset command tick / accepted & 1 / true & \blank{2.5cm} \\
|
||||
one-shot callback tick & 6 & \blank{2.5cm} \\
|
||||
one-shot active po expiry & false & \blank{2.5cm} \\
|
||||
change command tick / accepted & 4 / true & \blank{2.5cm} \\
|
||||
periodic next callback & 7 & \blank{2.5cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
Wyjaśnij różnicę między reset i change-period:\\[.4em]
|
||||
\blank{16cm}\\[.8em]\blank{16cm}
|
||||
|
||||
\newpage
|
||||
\section{Dowód kontekstu timer daemon}
|
||||
|
||||
Callback nie działa w przerwaniu ani na stosie taska, który wywołał
|
||||
\texttt{start}. Wszystkie software timers współdzielą jeden daemon.
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{5.4cm}p{3.1cm}X@{}}
|
||||
\toprule Pomiar & Predykcja & Odczyt \\
|
||||
\midrule
|
||||
current == timer daemon handle & true & \blank{2.5cm} \\
|
||||
task name zaczyna się od \texttt{Tmr S} & true & \blank{2.5cm} \\
|
||||
callback SP != verifier SP & true & \blank{2.5cm} \\
|
||||
callback może blokować & nie & \blank{2.5cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Dlaczego callback ma być krótki?}
|
||||
Jeden długi callback opóźnia obsługę poleceń i expiries wszystkich timerów.
|
||||
Ciężką pracę przekaż taskowi przez notification, semaphore albo queue.
|
||||
|
||||
Zaproponuj granicę callback/task dla sterowania LED:\\[.4em]
|
||||
\blank{16cm}\\[.8em]\blank{16cm}
|
||||
|
||||
\section{Storage i lifetime}
|
||||
\begin{lstlisting}
|
||||
StaticTimer_t storage; // control block, caller-owned
|
||||
Probe context; // timer ID points here
|
||||
PeriodicTimer<Probe> timer(storage, "led", 2, context);
|
||||
\end{lstlisting}
|
||||
|
||||
\begin{itemize}
|
||||
\item oba control blocks i verifier storage są w \texttt{.bss};
|
||||
\item heap przed/po \texttt{xTimerCreateStatic}: bez zmiany;
|
||||
\item context, storage i wrapper żyją dłużej niż pending command/callback;
|
||||
\item wrapper nie udaje, że destruktor synchronicznie opróżnił daemon queue.
|
||||
\end{itemize}
|
||||
|
||||
\section*{Stop}
|
||||
\texttt{stop()} accepted: \blank{2cm}. Active po przetworzeniu: \blank{2cm}.
|
||||
Callback count po dalszych 4 tickach: \blank{2cm}. Dlaczego samo accepted nie
|
||||
wystarcza jako dowód? \blank{5cm}.
|
||||
|
||||
\newpage
|
||||
\section{Hazard3/GDB i zaliczenie}
|
||||
\begin{lstlisting}[language=bash]
|
||||
make check
|
||||
riscv64-unknown-elf-gdb build/task01_sw_timer/prog.elf
|
||||
b software_timer_debug_checkpoint
|
||||
\end{lstlisting}
|
||||
\begin{lstlisting}
|
||||
p g_start_commands_accepted
|
||||
p g_callbacks_when_start_returned
|
||||
p g_verifier_entry_tick
|
||||
p g_reset_tick
|
||||
p g_change_tick
|
||||
p g_one_shot_tick
|
||||
p g_periodic_ticks
|
||||
p g_one_shot_active_after_expiry
|
||||
p g_periodic_active_after_stop
|
||||
p g_daemon_handle_match
|
||||
p g_daemon_name_match
|
||||
p g_heap_before_timer_create
|
||||
p g_heap_after_timer_create
|
||||
p g_timer_pass
|
||||
\end{lstlisting}
|
||||
|
||||
\section*{Zaliczenie}
|
||||
\begin{itemize}
|
||||
\item $\square$ rozróżniam accepted command od wykonanego callbacku;
|
||||
\item $\square$ pokazuję periodic ticks 2, 4, potem po zmianie 7;
|
||||
\item $\square$ reset@1 przesuwa one-shot na tick 6 i timer staje inactive;
|
||||
\item $\square$ callback działa na \texttt{Tmr Svc} i osobnym stosie;
|
||||
\item $\square$ stop pozostawia inactive i brak czwartego callbacku;
|
||||
\item $\square$ static storage daje heap delta 0 i wrapper bez runtime C++.
|
||||
\end{itemize}
|
||||
|
||||
\section*{Wyjście}
|
||||
Dlaczego nie wolno przechwycić wskaźnika do krótkotrwałego obiektu jako timer
|
||||
ID?\\[.5em]\blank{16cm}\\[1em]
|
||||
Co długi callback robi z innymi timerami?\\[.5em]\blank{16cm}
|
||||
|
||||
\vfill
|
||||
\noindent\textbf{Następna karta K15:} jawne API FromISR, kontrakt
|
||||
\texttt{higherPriorityTaskWoken}, UART RX i GPIO edge wrappers.
|
||||
\end{document}
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user