\documentclass[10pt,a4paper]{article}

\usepackage[margin=2cm]{geometry}
\usepackage{pdfpages}

% textcomp package is not available everywhere, and we only need the Copyright symbol
% taken from http://tex.stackexchange.com/a/1677/23992
\DeclareTextCommandDefault{\textregistered}{\textcircled{\check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}}

\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead{}
\fancyfoot[C]{Copyright {\textcopyright} 2015 Camil Staps}
\pagestyle{fancy}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}

\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\usepackage{enumitem}
\setenumerate[1]{label=\alph*.}
\setenumerate[2]{label=(\roman*)}

\parindent0pt

\title{Operating Systems - assignment 7}
\author{Camil Staps\\\small{s4498062}}

\begin{document}

\maketitle
\thispagestyle{fancy}

\section*{9.1}
\begin{enumerate}
    \item See Table \ref{tab:91a}.
        \begin{table}[h]
            \centering
            \footnotesize
            \begin{tabular}{| r | *{21}{c|}} \hline
                ms      & 0  & 2  & 4  & 6  & 8  & 10 & 12 & 14 & 16 & 18 & 20 & 22 & 24 & 26 & 28 & 30 & 32 & 34 & 36 & 38 \\\hline
                SPN     & P1 & P1 & P2 & P2 & P2 & P2 & P2 & P2 & P4 & P4 & P4 & P3 & P3 & P3 & P3 & P5 & P5 & P5 & P5 & P5 \\\hline
                SRT     & P1 & P1 & P2 & P3 & P3 & P3 & P3 & P2 & P4 & P4 & P4 & P2 & P2 & P2 & P2 & P5 & P5 & P5 & P5 & P5 \\\hline
            \end{tabular}
            \caption{Applying the SPN and SRT algorithms to five processes}
            \label{tab:91a}
        \end{table}

    \item See Table \ref{tab:91b}.
        \begin{table}[h]
            \centering
            \footnotesize
            \begin{tabular}{| r | *{4}{>{$}C{10mm}<{$} |}} \hline
                        & \multicolumn{2}{c|}{SPN} & \multicolumn{2}{c|}{SRT} \\\hline
                Process & T_r   & T_r/T_s   & T_r   & T_r/T_s   \\\hline
                P1      & 4     & 1         & 4     & 1         \\
                P2      & 14    & 1.167     & 28    & 2.333     \\
                P3      & 24    & 3         & 8     & 1         \\
                P4      & 6     & 1         & 6     & 1         \\
                P5      & 20    & 2         & 20    & 2         \\\hline
                Mean    & 13.2  & 1.633     & 13.2  & 1.467     \\\hline
            \end{tabular}
            \caption{TAT and relative delay for the processes from Table \ref{tab:91a}}
            \label{tab:91b}
        \end{table}
\end{enumerate}

\section*{9.6}
The diagram shows the situation where processes only move down to a lower priority queue when preempted. The first two time units allocated to A are actually two dispatches, each with time unit $2^0=1$. Then the process is preempted because of B and moves down the priority queues.

However, if we move a process down the priority queues any time it finishes a time unit, A will continue running for three consecutive time units. First, one time unit in RQ0, and then two in RQ1.

\section*{9.7}
A steep line typically corresponds to a low service time, while a more gentle line corresponds to a high service time. The response ratio of a process with a low service time increases faster than that of a process with a high service time. Therefore, we should schedule the processes with a high service time last. If we schedule them earlier, the response times of other jobs increase rapidly and over a long time (that is, the service time of the running job). If we first schedule processes with a short service time however, the other response ratios don't increase that rapidly (because they belong to processes with a higher service time), and not for such a long time.

\end{document}

