diff --git a/LaTeX/Homework_Lesson_10.tex b/LaTeX/Homework_Lesson_10.tex index fe30162..f9c5987 100644 --- a/LaTeX/Homework_Lesson_10.tex +++ b/LaTeX/Homework_Lesson_10.tex @@ -32,6 +32,71 @@ Submit the source code and the screen shots of the standard output and the kerne \section{Code}% \label{sec:Code} +\subsection{Custom Python Code}% +\label{sub:Custom Python Code} +The following code was written by me with the intend to measure the jitter in a python code. +It uses the \textit{schedtool} program provided with the PREEMPT\_RT patches to schedule itself. +\definecolor{mGreen}{rgb}{0,0.6,0} +\definecolor{mGray}{rgb}{0.5,0.5,0.5} +\definecolor{mPurple}{rgb}{0.58,0,0.82} +\definecolor{backgroundColour}{rgb}{0.95,0.95,0.92} +\lstset{ + language=python, + backgroundcolor=\color{backgroundColour}, + commentstyle=\color{mGreen}, + keywordstyle=\color{magenta}, + numberstyle=\tiny\color{mGray}, + stringstyle=\color{mPurple}, + basicstyle=\ttfamily\scriptsize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + keepspaces=true, + numbers=left, + firstnumber=0, + stepnumber=1, + numbersep=5pt, + showspaces=false, + showstringspaces=false, + showtabs=false, + tabsize=2, + literate={~}{{$\mathtt{\sim}$}}1 +} +\lstset{literate=% + {Ö}{{\"O}}1 + {Ä}{{\"A}}1 + {Ü}{{\"U}}1 + {ß}{{\ss}}2 + {ü}{{\"u}}1 + {ä}{{\"a}}1 + {ö}{{\"o}}1 +} +\lstinputlisting{../test.py} +\clearpage + +\subsubsection{Output}% +\label{ssub:Python:Output} +Unfortunately, as can be seen by the following output, +the jitter isn't really affected by the activation or deactivation of the PREEMPT\_RT patches. + +\paragraph{with PREEMPT\_RT}% +\label{par:Python:with PREEMPT RT} +\begin{center} + \includegraphics[width = .75\textwidth]{with_preempt_rt.png} +\end{center} + +\paragraph{without PREEMPT\_RT}% +\label{par:Python:without PREEMPT RT} +\begin{center} + \includegraphics[width = .75\textwidth]{no_preempt_rt.png} +\end{center} +\clearpage + +\subsection{Using Existing Programs}% +\label{sub:Using Existing Programs} +The following code is just a shell script that makes use of two programs provided by the \texttt{rt-tests} package (Arch Linux). +It uses the \texttt{hackbench} program to put stress on the system and then evaluates the maximum latency with the \texttt{cyclictest} program. +This provides a much more reliable method of testing the real-time capabilites of the system than any self-developed code I was able to come up with. \definecolor{mGreen}{rgb}{0,0.6,0} \definecolor{mGray}{rgb}{0.5,0.5,0.5} \definecolor{mPurple}{rgb}{0.58,0,0.82} @@ -67,24 +132,23 @@ Submit the source code and the screen shots of the standard output and the kerne {ä}{{\"a}}1 {ö}{{\"o}}1 } - -The following code is just a shell script that makes use of two programs provided by the \texttt{rt-tests} package (Arch Linux). -It uses the \texttt{hackbench} program to put stress on the system and then evaluates the maximum latency with the \texttt{cyclictest} program. -This provides a much more reliable method of testing the real-time capabilites of the system than any self-developed code I was able to come up with. \lstinputlisting{../test.sh} The code is based on the following two sources:\\ \url{https://wiki.archlinux.org/title/Realtime_kernel_patchset}\\ \url{https://shuhaowu.com/blog/2022/02-linux-rt-appdev-part2.html} -\section{Output}% -\label{sec:Output} +\subsubsection{Output}% +\label{ssub:BASH:Output} +The following output shows that while the PREEMPT\_RT patch doesn't really affect the average latency it drastically reduces the maximum latency. -\subsection{with PREEMPT\_RT}% -\label{sub:with PREEMPT RT} +\paragraph{with PREEMPT\_RT}% +\label{par:BASH:with PREEMPT RT} +\mbox{}\\ \includegraphics[width = \textwidth]{with_rt.png} -\subsection{without PREEMPT\_RT}% -\label{sub:without PREEMPT RT} +\paragraph{without PREEMPT\_RT}% +\label{par:BASH:without PREEMPT RT} +\mbox{}\\ \includegraphics[width = \textwidth]{without_rt.png} \end{document} diff --git a/LaTeX/no_preempt_rt.png b/LaTeX/no_preempt_rt.png new file mode 100644 index 0000000..daa9db5 Binary files /dev/null and b/LaTeX/no_preempt_rt.png differ diff --git a/no_preempt_rt.svg b/LaTeX/no_preempt_rt.svg similarity index 100% rename from no_preempt_rt.svg rename to LaTeX/no_preempt_rt.svg diff --git a/LaTeX/with_preempt_rt.png b/LaTeX/with_preempt_rt.png new file mode 100644 index 0000000..95882fc Binary files /dev/null and b/LaTeX/with_preempt_rt.png differ diff --git a/with_preempt_rt.svg b/LaTeX/with_preempt_rt.svg similarity index 100% rename from with_preempt_rt.svg rename to LaTeX/with_preempt_rt.svg diff --git a/test.py b/test.py index 67c53d6..583de3b 100644 --- a/test.py +++ b/test.py @@ -11,17 +11,27 @@ def set_rt_priority(): def rt_task(): new_time = time.time() jitter_record = [] + for i in range(ITERATIONS + 1): old_time = new_time new_time = time.time() + print("--------------------------------------------------") print(f"system time:\t{new_time} s") print(f"time diff:\t{new_time - old_time} s") + + # jitter jitter = new_time - old_time - ITERATION_DURATION jitter_record.append(jitter) print(f"jitter:\t{jitter} s") + + # sleep for the rest of one second time.sleep(new_time + ITERATION_DURATION - time.time()) - jitter_record.pop(0) + + #remove the first measurement + jitter_record.pop(0) + + #plot and store the jitter record plt.plot(jitter_record) plt.title(f"Jitter at {ITERATION_DURATION} s interval") plt.xlabel("Iteration")