Compare commits
No commits in common. "master" and "V1.0" have entirely different histories.
@ -32,71 +32,6 @@ 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}
|
||||||
@ -132,23 +67,24 @@ This provides a much more reliable method of testing the real-time capabilites o
|
|||||||
{ä}{{\"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}
|
||||||
|
|
||||||
\subsubsection{Output}%
|
\section{Output}%
|
||||||
\label{ssub:BASH:Output}
|
\label{sec:Output}
|
||||||
The following output shows that while the PREEMPT\_RT patch doesn't really affect the average latency it drastically reduces the maximum latency.
|
|
||||||
|
|
||||||
\paragraph{with PREEMPT\_RT}%
|
\subsection{with PREEMPT\_RT}%
|
||||||
\label{par:BASH:with PREEMPT RT}
|
\label{sub:with PREEMPT RT}
|
||||||
\mbox{}\\
|
|
||||||
\includegraphics[width = \textwidth]{with_rt.png}
|
\includegraphics[width = \textwidth]{with_rt.png}
|
||||||
|
|
||||||
\paragraph{without PREEMPT\_RT}%
|
\subsection{without PREEMPT\_RT}%
|
||||||
\label{par:BASH:without PREEMPT RT}
|
\label{sub:without PREEMPT RT}
|
||||||
\mbox{}\\
|
|
||||||
\includegraphics[width = \textwidth]{without_rt.png}
|
\includegraphics[width = \textwidth]{without_rt.png}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 206 KiB |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 28 KiB |
Binary file not shown.
Before Width: | Height: | Size: 203 KiB |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 28 KiB |
44
test.py
44
test.py
@ -1,44 +0,0 @@
|
|||||||
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()
|
|
Loading…
x
Reference in New Issue
Block a user