Compare commits

...

2 Commits
V1.0 ... master

Author SHA1 Message Date
e0c0780748 improved the report pdf 2022-12-26 14:27:57 +09:00
ce02078a6c added custom test code 2022-12-26 14:07:19 +09:00
6 changed files with 2320 additions and 10 deletions

View File

@ -32,6 +32,71 @@ Submit the source code and the screen shots of the standard output and the kerne
\section{Code}% \section{Code}%
\label{sec: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{mGreen}{rgb}{0,0.6,0}
\definecolor{mGray}{rgb}{0.5,0.5,0.5} \definecolor{mGray}{rgb}{0.5,0.5,0.5}
\definecolor{mPurple}{rgb}{0.58,0,0.82} \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 {ä}{{\"a}}1
{ö}{{\"o}}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} \lstinputlisting{../test.sh}
The code is based on the following two sources:\\ The code is based on the following two sources:\\
\url{https://wiki.archlinux.org/title/Realtime_kernel_patchset}\\ \url{https://wiki.archlinux.org/title/Realtime_kernel_patchset}\\
\url{https://shuhaowu.com/blog/2022/02-linux-rt-appdev-part2.html} \url{https://shuhaowu.com/blog/2022/02-linux-rt-appdev-part2.html}
\section{Output}% \subsubsection{Output}%
\label{sec: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}% \paragraph{with PREEMPT\_RT}%
\label{sub:with PREEMPT RT} \label{par:BASH:with PREEMPT RT}
\mbox{}\\
\includegraphics[width = \textwidth]{with_rt.png} \includegraphics[width = \textwidth]{with_rt.png}
\subsection{without PREEMPT\_RT}% \paragraph{without PREEMPT\_RT}%
\label{sub:without PREEMPT RT} \label{par:BASH:without PREEMPT RT}
\mbox{}\\
\includegraphics[width = \textwidth]{without_rt.png} \includegraphics[width = \textwidth]{without_rt.png}
\end{document} \end{document}

BIN
LaTeX/no_preempt_rt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

1094
LaTeX/no_preempt_rt.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 28 KiB

BIN
LaTeX/with_preempt_rt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

1108
LaTeX/with_preempt_rt.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 28 KiB

44
test.py Normal file
View File

@ -0,0 +1,44 @@
import subprocess
import time
import matplotlib.pyplot as plt
ITERATIONS = 300
ITERATION_DURATION = 1 #second(s)
def set_rt_priority():
subprocess.run(["schedtool", "-F", "-p", "99"], check=True)
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())
#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")
plt.ylabel("Jitter (in s)")
plt.savefig("out.svg")
if __name__ == "__main__":
set_rt_priority()
rt_task()