diff options
| author | Manuel Traut <manut@linutronix.de> | 2011-01-21 14:32:26 +0100 |
|---|---|---|
| committer | Manuel Traut <manut@linutronix.de> | 2011-01-21 14:32:26 +0100 |
| commit | 482c846744218fb4e6ae3a694c2ad1bea1642439 (patch) | |
| tree | 495f356c71536f7fbdd5c499eb56d72d785451b5 | |
| parent | 0e7dbb844f65e70d096ee12f223ed5b792f3b9ba (diff) | |
| parent | 880c637efcad385f18b9ef8d6c34e0f7e737ec03 (diff) | |
Merge branch 'jan'
| -rw-r--r-- | linux-basics/licenses/Makefile | 9 | ||||
| -rw-r--r-- | linux-basics/licenses/pres_licenses_en.tex | 154 | ||||
| -rw-r--r-- | linux-basics/linux-processes/pres_linux-processes_en.tex | 224 | ||||
| -rw-r--r-- | linux-basics/udev-basics/Makefile | 9 | ||||
| -rw-r--r-- | linux-basics/udev-basics/pres_udev_en.tex | 178 |
5 files changed, 574 insertions, 0 deletions
diff --git a/linux-basics/licenses/Makefile b/linux-basics/licenses/Makefile new file mode 100644 index 0000000..4663d52 --- /dev/null +++ b/linux-basics/licenses/Makefile @@ -0,0 +1,9 @@ +all: + for pdf in `ls -1 *.tex` ; do \ + pdflatex $$pdf; \ + pdflatex $$pdf; \ + done + +clean: + rm -f *.aux *.log *.pdf *.log *.snm *.toc *.vrb *.nav *.out + diff --git a/linux-basics/licenses/pres_licenses_en.tex b/linux-basics/licenses/pres_licenses_en.tex new file mode 100644 index 0000000..dfda2b2 --- /dev/null +++ b/linux-basics/licenses/pres_licenses_en.tex @@ -0,0 +1,154 @@ +\documentclass[11pt]{beamer} + +%\usepackage{ngerman} +\usepackage{times} +\usepackage{graphicx} +\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps} +\usepackage{amsmath,amssymb} +\usepackage[latin1]{inputenc} +\usepackage{listings,color} +\definecolor{lbcolor}{RGB}{255,210,150} +\lstset{ + language=C, + numbers=left, + stepnumber=1, + numbersep=5pt, + numberstyle=\tiny, + breaklines=true, + breakautoindent=true, + postbreak=\space, + tabsize=2, + basicstyle=\ttfamily\footnotesize, + showspaces=false, + showstringspaces=false, + extendedchars=true, + backgroundcolor=\color{lbcolor}, + keywordstyle=\bf , + commentstyle=\color{green}, + stringstyle=\color{red} +} + +\mode<presentation> +{ + \usetheme{linutronix} +} + +% on the following slides, include icon in the left sidebar +\def\lximg{/usr/share/lx/icons/fueller.png} + +\title{Opensource-Licenses} +\institute{Linutronix GmbH} + +\begin{document} + +\frame{ \titlepage } + +% stop displaying 'fueller.png' on the following slides +\def\lximg{none} + +\begin{frame} +\frametitle{GPL: GNU \textbf{G}eneral \textbf{P}ublic \textbf{L}icense} +You are allowed to: +\begin{itemize} +\item Use the source code +\item Change the source code +\item (Re-)Distribute the source code +\end{itemize} +You have to: +\begin{itemize} +\item Provide your code under the same license!! +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{GPLv2 vs. GPLv3} +\begin{alertblock}{What's different in GPLv3?} +\begin{itemize} +\item It covers DRM +\item Wants to prevent ''Tivoization'' +\item Wants to protect against patent treats +\item Clarifies license compatibility +\item System Libraries Exception has been adjusted +\end{itemize} +\end{alertblock} +\end{frame} + +\begin{frame} +\frametitle{Copyleft} +\begin{alertblock}{http://www.gnu.org/copyleft/} +''Copyleft is a general method for making a program (or other work) free, and +requiring all modified and extended versions of the program to be free as +well.'' +\end{alertblock} +\end{frame} + +\begin{frame} +\frametitle{LGPL: \textbf{L}esser \textbf{GPL}} +\begin{itemize} +\item Pretty much the same as GPL, but: +\item any software that is just linked against this code can be released under +its own license +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Apache License} +You are allowed to: +\begin{itemize} +\item Use the code +\item Modify the code +\end{itemize} +as long as you: +\begin{itemize} +\item Include an appropriate attribution in the documentation +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{BSD} +You are allowed to: +\begin{itemize} +\item Use the code +\item Modify the code +\item (Re-) Distribute the code +\item Keep it Closed-Source +\item Release it under you own license +\end{itemize} +You have to: +\begin{itemize} +\item Keep and distribute the original copyright statements! +\item Mention the ''University of California, Berkeley'' in the documentation +/ advertising (''advertising clause'') +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{BSD: Modified BSD license} +\begin{itemize} +\item AKA 3-clause BSD license +\item Identical to the ''original'' BSD license (4-clause BSD license), but +without the ''advertising clause'' +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{License compatibility} +\begin{itemize} +\item Be careful when mixing code which is released under different licenses! +\item Check if the licenses are compatible! +\end{itemize} +Example: +\begin{itemize} +\item BSD is incompatible with GPL, because: +\item of BSDs ''advertising clause'' +\item BSD doesn't contain any Copyleft +\end{itemize} +This means: +\begin{itemize} +\item You can only use 3-clause BSD code in GPL code! +\item You MUST NOT use GPL code in BSD code!!!! +\end{itemize} + +\end{frame} + +\end{document} diff --git a/linux-basics/linux-processes/pres_linux-processes_en.tex b/linux-basics/linux-processes/pres_linux-processes_en.tex new file mode 100644 index 0000000..73582d8 --- /dev/null +++ b/linux-basics/linux-processes/pres_linux-processes_en.tex @@ -0,0 +1,224 @@ +\documentclass[11pt]{beamer} + +%\usepackage{ngerman} +\usepackage{times} +\usepackage{graphicx} +\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps} +\usepackage{amsmath,amssymb} +\usepackage[latin1]{inputenc} +\usepackage{listings,color} +\definecolor{lbcolor}{RGB}{255,210,150} +\lstset{ + language=C, + numbers=left, + stepnumber=1, + numbersep=5pt, + numberstyle=\tiny, + breaklines=true, + breakautoindent=true, + postbreak=\space, + tabsize=2, + basicstyle=\ttfamily\footnotesize, + showspaces=false, + showstringspaces=false, + extendedchars=true, + backgroundcolor=\color{lbcolor}, + keywordstyle=\bf , + commentstyle=\color{green}, + stringstyle=\color{red} +} + +\mode<presentation> +{ + \usetheme{linutronix} +} + +% on the following slides, include icon in the left sidebar +\def\lximg{/usr/share/lx/icons/fueller.png} + +\title{Linux process mangagement / Scheduling / Daemons} +\institute{Linutronix GmbH} + +\begin{document} + +\frame{ \titlepage } + +% stop displaying 'fueller.png' on the following slides +\def\lximg{none} + +\section{Process Management} +\begin{frame} +\frametitle{Process creation} +From the operatings system's point of view, there are basically two steps, +which are performed when starting a process. +\begin{itemize} +\item A process is created using the fork() system call +\item The execve() system call loads a new program into the process memory +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Parent / Child} +\begin{itemize} +\item init is the first process, which is started (PID == 1), so +\item init is the parent of all processes on the system +\item A parent waits for its childs termination using the wait() system call +\item If the parent process terminates, before the child terminates, the child +is ''adopted'' by PID 1 +\item A child which terminates before its parent was able to do a wait() is +turned into a ''Zombie'' +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Task states} +Each task can have one of the following states: +\begin{itemize} +\item Interruptible sleep (waiting for an event) (S) +\item Uninterruptible sleep (waiting for I/O) (D) +\item Running (R) +\item Stopped (T) +\item Defunct / ''Zombie'' (Z) +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Task states} +''ps aux'' also shows the task state: +\begin{verbatim} +USER PID STAT COMMAND +postfix 5034 [...] S [...] pickup -l +jan 5303 [...] SN+ [...] man 8 init +jan 5313 [...] SN+ [...] pager -s +jan 5390 [...] SNl [...] evince +jan 5416 [...] SNs [...] bash +\end{verbatim} +The first column in the STAT field shows the process state. +\end{frame} + +\section{Scheduling} +\begin{frame} +\frametitle{The LINUX Scheduler} +\begin{itemize} +\item Responsiveness +\item Fairness +\item Throughput +\item O(log n) +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Scheduling classes} +Normal processes: +\begin{itemize} +\item SCHED\_OTHER +\item SCHED\_BATCH (Linux specific; since 2.6.16) +\item SCHED\_IDLE (Linux specific; since 2.6.23) +\end{itemize} +Realtime: +\begin{itemize} +\item SCHED\_FIFO +\item SCHED\_RR +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{The nice value} +\begin{itemize} +\item Non-Realtime processes don't have a static priority! +\item Their priority is calculated dynamically +\item The calculation can be influenced by the ''nice value'' +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{The nice value} +\begin{itemize} +\item The range for possible nice values is: -20 .. +19 +\item It tells the system how ''NICE'' the process should behave towards other +processes. So, -20 means ''high priority'' and +19 ''low priority'' +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{The nice value} +The nice value can be changed using the ''nice'' and the ''renice'' command: +\begin{verbatim} +Usage: nice [OPTION] [COMMAND [ARG]...] +-n, --adjustment=N + +renice [-n] prio [-p|--pid] pid [.. pid] +renice [-n] prio -g|--pgrp pgrp [.. pgrp] +renice [-n] prio -u|--user user [.. user] +\end{verbatim} +\end{frame} + +\begin{frame} +\frametitle{SCHED\_IDLE and SCHED\_BATCH} +\begin{itemize} +\item SCHED\_BATCH: The scheduler will always assume the process to be CPU +intensive and therefor will apply a penalty when calculating the dynamic +priority. +\item SCHED\_IDLE: For very low prio processes. Even the nice value is +ignored. The resulting priority will be \textbf{below} SCHED\_OTHER and SCHED\_BATCH +with nice +19 assigned to it! +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Realtime scheduling classes} +\begin{itemize} +\item SCHED\_FIFO: Static priority +\item SCHED\_RR: Priority based, Round Robin scheduling per priority +\end{itemize} +Both Realtime scheduling classes accept priorities from 1 to 99, where 99 is +the highest priority. +\end{frame} + +\begin{frame}[fragile] +\frametitle{Setting the Scheduling class} +The scheduling class can be set using the chrt command: +\begin{verbatim} +Set policy: + chrt [opts] <policy> <prio> <pid> + chrt [opts] <policy> <prio> <cmd> [<arg> ...] +Get policy: + chrt [opts] {<pid> | <cmd> [<arg> ...]} +Scheduling policies: +-b | --batch set policy to SCHED_BATCH +-f | --fifo set policy to SCHED_FIFO +-i | --idle set policy to SCHED_IDLE +-o | --other set policy to SCHED_OTHER +-r | --rr set policy to SCHED_RR (default) +\end{verbatim} +\end{frame} + +\section{Daemons} +\begin{frame} +\frametitle{Daemons} +\begin{alertblock}{What is a Daemon?} +A Daemon runs in background and is not attached to a terminal. Daemons are +used for specific tasks, such as a web-server, a printer server, ... +\end{alertblock} +\end{frame} + +\begin{frame} +\frametitle{How a Daemon gets created} +\begin{itemize} +\item Like any other process, a Daemon is created using fork() +\item after forking the parent exits, which causes the child to be ''adopted'' +by PID 1 +\item then the child calls setsid(), to create a new session for that process +\item afterwards several administrative tasks will be done (like changing the +working directory and so on...) +\end{itemize} +\end{frame} + +\section*{sources} +\begin{frame} +\begin{thebibliography}{1} +\bibitem{kerisk10} The Linux Programming Interface (Michael Kerisk), no starch +press, ISBN 978-1-59327-220-3 +\end{thebibliography} +\end{frame} +\end{document} diff --git a/linux-basics/udev-basics/Makefile b/linux-basics/udev-basics/Makefile new file mode 100644 index 0000000..4663d52 --- /dev/null +++ b/linux-basics/udev-basics/Makefile @@ -0,0 +1,9 @@ +all: + for pdf in `ls -1 *.tex` ; do \ + pdflatex $$pdf; \ + pdflatex $$pdf; \ + done + +clean: + rm -f *.aux *.log *.pdf *.log *.snm *.toc *.vrb *.nav *.out + diff --git a/linux-basics/udev-basics/pres_udev_en.tex b/linux-basics/udev-basics/pres_udev_en.tex new file mode 100644 index 0000000..5d8eacc --- /dev/null +++ b/linux-basics/udev-basics/pres_udev_en.tex @@ -0,0 +1,178 @@ +\documentclass[11pt]{beamer} + +%\usepackage{ngerman} +\usepackage{times} +\usepackage{graphicx} +\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps} +\usepackage{amsmath,amssymb} +\usepackage[latin1]{inputenc} +\usepackage{listings,color} +\definecolor{lbcolor}{RGB}{255,210,150} +\lstset{ + language=C, + numbers=left, + stepnumber=1, + numbersep=5pt, + numberstyle=\tiny, + breaklines=true, + breakautoindent=true, + postbreak=\space, + tabsize=2, + basicstyle=\ttfamily\footnotesize, + showspaces=false, + showstringspaces=false, + extendedchars=true, + backgroundcolor=\color{lbcolor}, + keywordstyle=\bf , + commentstyle=\color{green}, + stringstyle=\color{red} +} + +\mode<presentation> +{ + \usetheme{linutronix} +} + +% on the following slides, include icon in the left sidebar +\def\lximg{/usr/share/lx/icons/fueller.png} + +\title{The UDEV Daemon} +\institute{Linutronix GmbH} + +\begin{document} + +\frame{ \titlepage } + +% stop displaying 'fueller.png' on the following slides +\def\lximg{none} + +\begin{frame} +\frametitle{What is UDEV?} +\begin{itemize} +\item UDEV is responsible for dynamic device management +\item It receives so called uevents from the kernel via a netlink socket +\item Based on the rules defined in the UDEV configuration, specific tasks can +be performed (e.g. creating device nodes) +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{How to perform actions on ''missed'' uevents} +\begin{itemize} +\item Since udev is a userspace process, it is started when the system is already up +and running. To perform actions on the events, which have been generated +during the kernel boot-up, there's a trigger functionality +\item So, usually the first thing after starting udev is to trigger the missed events +\item This can be done by calling ''udevadm trigger'' +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Monitoring udev events} +\begin{verbatim} +jan@bender:~$ sudo udevadm monitor +monitor will print the received events for: +UDEV - the event which udev sends out + after rule processing +KERNEL - the kernel uevent +KERNEL[129.916] add [...]usb1/1-3/1-3.1 [...] +KERNEL[129.917] add [...]usb1/1-3/1-3.1 [...] +KERNEL[129.918] add [...]usb1/1-3/1-3.1 [...] +KERNEL[129.918] add [...]usb1/1-3/1-3.1 [...] +UDEV [129.922] add [...]usb1/1-3/1-3.1 [...] +UDEV [129.922] add [...]usb1/1-3/1-3.1 [...] +[...] +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{UDEV: important commands} +Starting the UDEV Daemon: +\begin{verbatim} +udevd --daemon +\end{verbatim} +Triggering UDEV events: +\begin{verbatim} +udevadm trigger +\end{verbatim} +Monitoring UDEV events: +\begin{verbatim} +udevadm monitor +\end{verbatim} +\end{frame} + +\begin{frame} +\frametitle{Writing UDEV rules} +\begin{itemize} +\item Rules are usually kept in /etc/udev/rules.d +\item Rules are constructed using series of KEY-VALUE pairs +\item The pairs are separated by commas +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Basic keywords} +\begin{itemize} +\item KERNEL\\ +The kernel name of a device +\item SUBSYSTEM\\ +The name of the subsystem which caused the event +\item DRIVER\\ +Name of the driver which caused the event +\item NAME\\ +Name of the device node +\item SYMLINK\\ +Name of a symlink pointing to the node +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Simple example for device node creation} +\begin{verbatim} +# Some basic rule +KERNEL=="ttyS0", NAME="my_serial_port" + +# A more complex rule using SysFS attributes +# and regular expressions +SUBSYSTEM=="net", ACTION=="add", \ +DRIVERS=="?*", \ +ATTR{address}=="00:19:d1:12:0d:d2", \ +KERNEL=="eth*", NAME="eth0" +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Operators} +\begin{verbatim} +Comparisons: +== equal +!= not equal + +Assignments: += Assign a value ++= Add a value +:= Finally assign a value + (disallow any later changes) +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Substitutions} +\begin{verbatim} +%k kernel name +%n number for this device +%d driver name +%M major number of this device +%m minor number of this device +[...] +\end{verbatim} +\end{frame} + +\section*{sources} +\begin{frame} +\begin{thebibliography}{1} +\bibitem{udev} http://reactivated.net/writing\_udev\_rules.html +\bibitem{manudev} man udev +\end{thebibliography} +\end{frame} +\end{document} |
