Commit 01576280 authored by jkvis's avatar jkvis

First draft of processes

parent 125ccfce
......@@ -160,6 +160,138 @@ Sometimes it is useful to terminate a running process.
0.0 0.0 ps -o %cpu,%mem,cmd
0.0 0.0 bash
\end{verbatim}
\end{frame}
\begin{frame}[fragile]{Live monitoring}
\texttt{top} (table of processes) command
\bigskip
{
\tiny
\begin{verbatim}
Tasks: 297 total, 1 running, 296 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0,8 us, 0,4 sy, 0,1 ni, 97,0 id, 1,7 wa, 0,0 hi, 0,0 si, 0,0 st
KiB Mem: 8082284 total, 7136656 used, 945628 free, 467828 buffers
KiB Swap: 8293372 total, 148028 used, 8145344 free. 2568880 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2308 jkvis 20 0 2160736 408668 58188 S 2,0 5,1 72:12.73 gnome-shell
2727 jkvis 20 0 740416 45448 20436 S 2,0 0,6 8:57.47 gnome-terminal
1142 root 20 0 490452 151152 108720 S 1,3 1,9 74:20.12 Xorg
8992 jkvis 20 0 4669916 1,622g 159472 S 1,3 21,0 1412:26 firefox
16250 jkvis 20 0 2381724 1,040g 1,002g S 0,7 13,5 752:53.78 VBoxHeadless
1751 redis 20 0 37016 5200 1060 S 0,3 0,1 8:48.82 redis-server
2145 jkvis 20 0 391608 48904 4552 S 0,3 0,6 7:19.45 ibus-daemon
24816 jkvis 20 0 1034684 51128 26860 S 0,3 0,6 86:11.84 VirtualBox
...
\end{verbatim}
}
\bigskip
Use \texttt{<} and \texttt{>} to navigate \\
Use \texttt{u} and a username to show processes for that user \\
\texttt{q} quits
\end{frame}
\section{Timing a process}
\begin{frame}[fragile]{\texttt{time} command}
\texttt{time du .}
\bigskip
\begin{verbatim}
real 0m8.373s
user 0m0.256s
sys 0m1.744s
\end{verbatim}
\bigskip
\begin{itemize}
\item \texttt{real} --- wall clock time;
\item \texttt{user} --- only actual CPU time used in executing the process;
\item \texttt{sys} --- CPU time spent in system calls within the \emph{kernel}.
\end{itemize}
\end{frame}
\section{Job control}
\begin{frame}
A process in UNIX --- that is something doing a particular job --- can run either in \emph{foreground} or \emph{background}.
\bigskip
So far we have been running jobs in foreground:
\begin{itemize}
\item jobs start per default in foreground;
\item the job has control over the terminal;
\item we cannot enter new commands while the job is running;
\item until the job is finished or interrupted (e.g. \texttt{kill}).
\end{itemize}
\bigskip
Running a job in the background:
\begin{itemize}
\item use \texttt{\&} to start a job in background;
\item we remain in control of the terminal;
\item the background job can \emph{write} to the terminal;
\item convenient for starting graphical programs: \texttt{firefox \&}.
\end{itemize}
\end{frame}
\begin{frame}{Moving a running job to the background}
We start an editor: \\
\texttt{\$ nano}
\bigskip
Press \texttt{Ctrl+Z} \\
\texttt{Use "fg" to return to nano.} \\
\texttt{[2]+ Stopped nano}
\bigskip
Move \texttt{nano} to the background: \\
\texttt{\$ bg}
\bigskip
Now \texttt{nano} is running in the background and we can use the terminal.
\bigskip
To return to \texttt{nano}: \\
\texttt{\$ fg}
\end{frame}
\begin{frame}[fragile]{Job list}
We can get a job list using: \\
\texttt{\$ jobs}
\bigskip
\begin{verbatim}
[1]- Running evince processes.pdf &
[2]+ Stopped nano
\end{verbatim}
\bigskip
Alternatively, jobs can be found using \texttt{ps} or \texttt{top}.
\bigskip
We can use the job number to select which job we want to bring to foreground: \\
\texttt{\$ fg 2}
\bigskip
We can also terminate a job using its job number: \\
\texttt{\$ kill -9 \%2}
\end{frame}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment