feat: add lab-rv32i-freertos-queue card
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# K10 — Queue<T> and StaticQueue<T, N>
|
||||
|
||||
## Position
|
||||
|
||||
- Series: FreeRTOS C++
|
||||
- Lesson: L09, card K10
|
||||
- Duration: 30 minutes
|
||||
- Platform: Hazard3 / RV32I, FreeRTOS V11.3.0
|
||||
- Message: 12-byte trivial `Sample`, capacity 2
|
||||
|
||||
## Outcome
|
||||
|
||||
The student explains byte-copy semantics, designs a trivial message, proves a
|
||||
copy survives source mutation, compares dynamic and caller-owned static queue
|
||||
storage, and handles full/empty states with explicit bounded timeouts.
|
||||
|
||||
## Lesson plan
|
||||
|
||||
| Time | Mode | Evidence |
|
||||
| --- | --- | --- |
|
||||
| 0–5 | type contract | `Sample` passes; owning `VectorV1` fails |
|
||||
| 5–10 | create | dynamic cost 128 B; static delta 0 B |
|
||||
| 10–15 | copy | send, mutate source, receive unchanged copy |
|
||||
| 15–20 | storage | inspect first 12 static storage bytes |
|
||||
| 20–25 | full/timeout | capacity 2; third send fails after 2 ticks |
|
||||
| 25–30 | FIFO/drain | values 0x2222 then 0x3333; empty receive fails |
|
||||
|
||||
## Acceptance
|
||||
|
||||
- `sizeof(Sample)==12` reaches both create APIs;
|
||||
- dynamic cost is positive and recovered by RAII destruction;
|
||||
- static create has zero heap delta and its buffers are in `.bss`;
|
||||
- received value remains 0x1111 after source becomes 0xDEAD;
|
||||
- storage snapshot equals the first sent `Sample` byte-for-byte;
|
||||
- full count is 2, third send returns false after at least 2 ticks;
|
||||
- FIFO and non-blocking empty receive are correct;
|
||||
- non-trivial owning message fails for the pinned static-assert reason;
|
||||
- target exits with PASS.
|
||||
|
||||
## Main traps
|
||||
|
||||
1. Queue storage is a byte copy, not a C++ object owner.
|
||||
2. `sizeof(pointer)` plus an object address is a different and invalid contract.
|
||||
3. A trivially-copyable pointer still needs an external lifetime policy.
|
||||
4. `portMAX_DELAY` must not be hidden as a convenient default.
|
||||
5. Static queue control and byte storage must both outlive the queue.
|
||||
@@ -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}{10}
|
||||
\newcommand{\CardCount}{16}
|
||||
\newcommand{\CardSlug}{queue}
|
||||
\newcommand{\CardVersion}{v00.01}
|
||||
\newcommand{\DocumentUUID}{66967c2d-bb34-4344-8064-f54d06cce47a}
|
||||
|
||||
\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 Queue<T> and StaticQueue<T, N>}\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 10/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 66967c2d-bb34-4344-8064-f54d06cce47a}\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 66967c2d-bb34-4344-8064-f54d06cce47a}\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-queue}{\nolinkurl{https://zsl-gitea.mpabi.pl/edu-freertos-cpp/lab-rv32i-freertos-queue}}}} \\%
|
||||
\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~RTOS.QUEUE}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Mierzy queue storage, copy, full timeout i FIFO.}}\par%
|
||||
\hspace*{0.54em}\textcolor{blue!70!black}{KW~LOCAL~RTOS.QUEUE}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.01}{Pokazuje wszystkie relacje liczbowe oraz końcowy 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~OOP.OWN}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.04}{Analizuje byte representation, ownership i lifetime wiadomości.}}\par%
|
||||
\hspace*{0.54em}\textcolor{blue!70!black}{KW~LOCAL~KW~OOP.OWN}\textcolor{black!48}{\pdftooltip[width=\textwidth]{.04}{Uzasadnia gate i poprawną semantykę wartości lub wskaźnika.}}\par%
|
||||
\end{minipage}%
|
||||
}%
|
||||
\end{minipage}%
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\sloppy
|
||||
|
||||
\vspace{1.0em}
|
||||
\noindent{\Large\bfseries Cel karty}\par
|
||||
\vspace{0.35em}
|
||||
Uczeń projektuje trivial message, dowodzi snapshotowej semantyki byte copy, porównuje dynamiczne i caller-owned static storage oraz obsługuje full, timeout, FIFO i empty.
|
||||
|
||||
\vspace{0.8em}
|
||||
\noindent\textcolor{black!25}{\rule{\textwidth}{0.35pt}}
|
||||
\vspace{0.7em}
|
||||
\noindent{\Large\bfseries Zakres karty}\par
|
||||
\vspace{0.35em}
|
||||
Queue nie zarządza lifetime obiektu C++. Owning typ by value jest odrzucony; wskaźnik wymaga osobnego kontraktu ownership. Timeout pozostaje jawny.
|
||||
|
||||
\vspace{0.8em}
|
||||
\noindent\textcolor{black!25}{\rule{\textwidth}{0.35pt}}
|
||||
|
||||
\clearpage
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Type gate i byte copy}
|
||||
\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}{K10.WE01.OG.LOCAL.OOP.OWN.04 | WE 01: Typed queues. Bezpieczna typowana granica nad\textCR byte-copy kolejką FreeRTOS z jawnym storage i timeoutem. | EN LOCAL OOP.OWN.04: Analizuje\textCR byte representation, ownership i lifetime wiadomości. | KW LOCAL OOP.OWN.04: Uzasadnia gate\textCR i poprawną semantykę wartości lub wskaźnika.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Powiąż sizeof(T) z item size i reprezentacją 12 B.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Wyjaśnij granicę ownership dla owning type i pointera.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Wykaż, że Sample jest trivially copyable, a owning VectorV1 kończy negatywny test właściwym static assert.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Dynamic i static storage}
|
||||
\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}{K10.WE01.TECH.LOCAL.RTOS.QUEUE.01 | WE 01: Typed queues. Bezpieczna typowana granica nad\textCR byte-copy kolejką FreeRTOS z jawnym storage i timeoutem. | EK LOCAL RTOS.QUEUE.01: Mierzy\textCR queue storage, copy, full timeout i FIFO. | KW LOCAL RTOS.QUEUE.01: Pokazuje wszystkie\textCR relacje liczbowe oraz końcowy PASS.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Porównaj control i item bytes obu polityk.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Zrób byte snapshot pierwszego elementu.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Zmierz 128 B dynamic cost, zerowy static delta, caller addresses w .bss i pełne odzyskanie baseline przez destruktor.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\ESCSectionBlockStart
|
||||
\section{Copy, full, timeout i FIFO}
|
||||
\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}{K10.WE01.TECH.LOCAL.RTOS.QUEUE.01 | WE 01: Typed queues. Bezpieczna typowana granica nad\textCR byte-copy kolejką FreeRTOS z jawnym storage i timeoutem. | EK LOCAL RTOS.QUEUE.01: Mierzy\textCR queue storage, copy, full timeout i FIFO. | KW LOCAL RTOS.QUEUE.01: Pokazuje wszystkie\textCR relacje liczbowe oraz końcowy PASS.}\par
|
||||
\vspace{0.10em}%
|
||||
\noindent K1: Udowodnij 0x1111 mimo mutate do 0xDEAD.\quad D1\par
|
||||
\ESCTinyStepSeparator
|
||||
\noindent K2: Potwierdź timeout, FIFO i empty non-blocking.\quad D1\par
|
||||
\par\vspace{0.18em}%
|
||||
\endgroup
|
||||
|
||||
Wyślij, zmień źródło i odbierz snapshot; następnie wypełnij capacity 2, odmów trzeciego send po 2 tickach i opróżnij FIFO.
|
||||
\ESCSectionBlockEnd
|
||||
|
||||
\end{document}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
\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}{10}
|
||||
\newcommand{\CardCount}{16}
|
||||
\newcommand{\CardSlug}{queue}
|
||||
\newcommand{\CardVersion}{v00.01}
|
||||
\newcommand{\DocumentUUID}{66967c2d-bb34-4344-8064-f54d06cce47a}
|
||||
\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{K10 · FreeRTOS C++ · typed queue}}\rhead{\small L09 · byte-copy contract}
|
||||
\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 \texttt{Queue<T>} i \texttt{StaticQueue<T,N>}}\par
|
||||
\vspace{.25em}{\large typowana granica nad kopiowaniem bajtów FreeRTOS}\par
|
||||
\end{center}
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{1.65cm}Xp{1.9cm}X@{}}
|
||||
\toprule
|
||||
Karta & K10 / \CardCount & Czas & 30 minut \\
|
||||
Platforma & Hazard3 / RV32I & Wiadomość & \texttt{Sample}, 12 B \\
|
||||
Capacity & 2 elementy & Timeout & jawny, 0 lub 2 ticki \\
|
||||
Wersja & \CardVersion & UUID karty & \texttt{66967c2d-...} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Kontrakt typu przed uruchomieniem}
|
||||
\begin{lstlisting}
|
||||
static_assert(std::is_trivially_copyable<T>::value,
|
||||
"Queue<T> requires T to be trivially copyable");
|
||||
\end{lstlisting}
|
||||
|
||||
Kernel zapamiętuje \texttt{sizeof(T)} bajtów. Nie wywołuje konstruktora,
|
||||
destruktora ani operacji kopiowania C++. Dlatego owning \texttt{VectorV1} nie
|
||||
może być wiadomością by value.
|
||||
|
||||
\noindent\fcolorbox{accent}{accentlight}{\begin{minipage}{.94\textwidth}
|
||||
\textbf{Kontrakt K10.} \texttt{send} kopiuje bajty w chwili wywołania. Późniejsza
|
||||
zmiana źródła nie może zmienić elementu w kolejce. Timeout jest jawny; wrapper
|
||||
nie ukrywa \texttt{portMAX\_DELAY}.
|
||||
\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 & gate & trivial Sample przechodzi; VectorV1 nie \\
|
||||
5--10 & create & dynamic heap cost kontra static delta 0 \\
|
||||
10--15 & copy & send, mutate, receive oryginalnej wartości \\
|
||||
15--20 & bytes & snapshot 12 B caller storage \\
|
||||
20--25 & full & trzeci send odmawia po 2 tickach \\
|
||||
25--30 & FIFO & drain 0x2222, 0x3333; empty receive=false \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Predykcja}
|
||||
\texttt{sizeof(Sample)} = \blank{2cm} B. Po wysłaniu wartości \texttt{0x1111}
|
||||
i zmianie źródła na \texttt{0xDEAD} odbiorę: \blank{3cm}.
|
||||
|
||||
\newpage
|
||||
\section{Dynamiczna i statyczna własność}
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{4.1cm}p{4.5cm}X@{}}
|
||||
\toprule
|
||||
Właściwość & \texttt{Queue<Sample>} & \texttt{StaticQueue<Sample,2>} \\
|
||||
\midrule
|
||||
create API & \texttt{xQueueCreate} & \texttt{xQueueCreateStatic} \\
|
||||
control & heap & caller \texttt{StaticQueue\_t} \\
|
||||
item bytes & heap & caller \texttt{uint8\_t[24]} \\
|
||||
item size & \texttt{sizeof(Sample)} & \texttt{sizeof(Sample)} \\
|
||||
destructor & delete + heap free & delete, bez free caller bytes \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Pomiar heap i adresów}
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{5.5cm}p{3.5cm}X@{}}
|
||||
\toprule
|
||||
Pomiar & Predykcja & Odczyt \\
|
||||
\midrule
|
||||
dynamic cost & $>0$ & \blank{3cm} B \\
|
||||
static create delta & 0 & \blank{3cm} B \\
|
||||
heap po obu destruktorach & baseline & \blank{3cm} \\
|
||||
static handle & control address & \blank{3cm} \\
|
||||
control/storage domain & .bss, poza heap & \blank{3cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section{Kopia jest snapshotem}
|
||||
\begin{lstlisting}
|
||||
Sample source{1, 0x1111, 3, 0x55};
|
||||
dynamic.send(source, 0);
|
||||
source.value = 0xDEAD;
|
||||
dynamic.receive(received, 0);
|
||||
\end{lstlisting}
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{4.5cm}p{3.5cm}X@{}}
|
||||
\toprule
|
||||
Wartość & Źródło po mutate & Odebrana kopia \\
|
||||
\midrule
|
||||
\texttt{value} & \texttt{0xDEAD} & \blank{3cm} \\
|
||||
\texttt{flags} & \texttt{0xAA} & \blank{3cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
Co byłoby błędem przy \texttt{xQueueCreate(2,sizeof(Sample*))}, gdy send dostaje
|
||||
\texttt{\&sample} zamiast \texttt{\&samplePointer}?\\[.5em]\blank{16cm}
|
||||
|
||||
\newpage
|
||||
\section{Full, timeout, FIFO i empty}
|
||||
|
||||
\begin{center}
|
||||
\texttt{send(first,0)} $\rightarrow$ count 1\\
|
||||
\texttt{send(second,0)} $\rightarrow$ count 2 / FULL\\
|
||||
\texttt{send(third,2)} $\rightarrow$ task blokuje maks. 2 ticki / false\\
|
||||
\texttt{receive} $\rightarrow$ first, potem second\\
|
||||
\texttt{receive(empty,0)} $\rightarrow$ false
|
||||
\end{center}
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{4.8cm}p{3.6cm}X@{}}
|
||||
\toprule
|
||||
Dowód & Predykcja & Odczyt \\
|
||||
\midrule
|
||||
count przed trzecim send & 2 & \blank{2.5cm} \\
|
||||
third send result & false & \blank{2.5cm} \\
|
||||
tick delta & $\geq2$ & \blank{2.5cm} \\
|
||||
FIFO first value & \texttt{0x2222} & \blank{2.5cm} \\
|
||||
FIFO second value & \texttt{0x3333} & \blank{2.5cm} \\
|
||||
empty receive, timeout 0 & false & \blank{2.5cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section{Zajrzyj do caller storage}
|
||||
Po pierwszym static send porównaj pierwsze 12 bajtów
|
||||
\texttt{g\_static\_queue\_storage.bytes} z reprezentacją \texttt{first}.
|
||||
|
||||
\noindent\begin{tabularx}{\textwidth}{@{}p{3cm}p{4cm}X@{}}
|
||||
\toprule
|
||||
Pole & Wartość & Little-endian bytes \\
|
||||
\midrule
|
||||
sequence & 2 & \blank{5cm} \\
|
||||
value & \texttt{0x2222} & \blank{5cm} \\
|
||||
channel/flags & 4 / \texttt{0x10} & \blank{5cm} \\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
|
||||
\section*{Ćwiczenie typu}
|
||||
Zaprojektuj trivial UART message: kierunek, długość, maks. 8 bajtów payload i
|
||||
sequence. Zapisz definicję oraz policz \texttt{sizeof}:\\[.5em]
|
||||
\blank{16cm}\\[1em]\blank{16cm}
|
||||
|
||||
Dlaczego sam fakt, że wskaźnik jest trivially copyable, nie rozwiązuje lifetime
|
||||
wskazywanego obiektu?\\[.5em]\blank{16cm}
|
||||
|
||||
\newpage
|
||||
\section{Hazard3/GDB i zaliczenie}
|
||||
\begin{lstlisting}[language=bash]
|
||||
make check
|
||||
riscv64-unknown-elf-gdb build/task01_queue/prog.elf
|
||||
b queue_debug_checkpoint
|
||||
\end{lstlisting}
|
||||
\begin{lstlisting}
|
||||
p g_dynamic_queue_cost
|
||||
p g_static_control_address
|
||||
p g_static_bytes_address
|
||||
p g_static_first_item_bytes
|
||||
p g_copy_source_after_mutation
|
||||
p g_copy_received_value
|
||||
p g_full_count
|
||||
p g_timeout_ticks
|
||||
p g_fifo_values
|
||||
p g_queue_pass
|
||||
\end{lstlisting}
|
||||
|
||||
\section*{Negatywny test jest częścią kontraktu}
|
||||
\begin{lstlisting}
|
||||
struct VectorV1 {
|
||||
unsigned* data;
|
||||
~VectorV1() { data = nullptr; }
|
||||
};
|
||||
freertos::Queue<VectorV1> forbidden{2}; // must not compile
|
||||
\end{lstlisting}
|
||||
|
||||
Oczekiwana przyczyna, nie przypadkowy błąd linkera:
|
||||
\texttt{Queue<T> requires T to be trivially copyable}.
|
||||
|
||||
\section*{Zaliczenie}
|
||||
\begin{itemize}
|
||||
\item $\square$ wyjaśniam byte copy i gate trivially-copyable;
|
||||
\item $\square$ pokazuję 128 B dynamic cost i 0 B static delta;
|
||||
\item $\square$ dowodzę snapshot 0x1111 po mutate do 0xDEAD;
|
||||
\item $\square$ wiążę 12 B item size z typed API i storage;
|
||||
\item $\square$ pokazuję full, timeout 2, FIFO i empty=false;
|
||||
\item $\square$ negatywny test VectorV1 kończy się właściwym static assert.
|
||||
\end{itemize}
|
||||
|
||||
\section*{Wyjście}
|
||||
Kiedy przesyłać wartość, a kiedy wskaźnik? Jak udokumentować ownership?\\[.5em]
|
||||
\blank{16cm}\\[1em]\blank{16cm}
|
||||
|
||||
\vfill
|
||||
\noindent\textbf{Następna karta K11:} \texttt{Mutex}, własny
|
||||
\texttt{LockGuard} i obserwowalne dziedziczenie priorytetu.
|
||||
\end{document}
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user