| Current Path : /var/www/html/bibhas.ghoshal/lecture_slides/lect5/ |
| Current File : /var/www/html/bibhas.ghoshal/lecture_slides/lect5/lect5.tex~ |
% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
% This file is a template using the "beamer" package to create slides for a talk or presentation
% - Talk at a conference/colloquium.
% - Talk length is about 20min.
% - Style is ornate.
% MODIFIED by Jonathan Kew, 2008-07-06
% The header comments and encoding in this file were modified for inclusion with TeXworks.
% The content is otherwise unchanged from the original distributed with the beamer package.
\documentclass{beamer}
% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% In principle, this file can be redistributed and/or modified under
% the terms of the GNU Public License, version 2.
%
% However, this file is supposed to be a template to be modified
% for your own needs. For this reason, if you use this file as a
% template and not specifically distribute it as part of a another
% package/program, I grant the extra permission to freely copy and
% modify this file as you see fit and even to delete this copyright
% notice.
% \mode<presentation>
% {
% \usetheme{Warsaw}
% % or ...
%
% \setbeamercovered{transparent}
% % or whatever (possibly just delete it)
% }
\usetheme{CambridgeUS}
\usecolortheme{beaver}
\usepackage[english]{babel}
% or whatever
\usepackage[utf8]{inputenc}
% or whatever
\usepackage{times}
%\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.
\usepackage{color}
\beamertemplateshadingbackground{red}{gray}
%\usepackage{}
\title[IOSY 332C \& IOPS 332C: OS] % (optional, use only with long paper titles)
{ Lecture 5- CPU Scheduling}
%\subtitle
%{Include Only If Paper Has a Subtitle}
\author [Bibhas Ghoshal]% (optional, use only with lots of authors)
{ Instructor : Bibhas Ghoshal (\textcolor{black}{bibhas.ghoshal@iiita.ac.in})}
% - Give the names in the same order as the appear in the paper.
% - Use the \inst{?} command only if the authors have different
% affiliation.
%\institute % (optional, but mostly needed)
%{
%\inst{1}%
% Department of Computer Science and Engineering\\
% Indian Institute of Technology, Kharagpur}
% \and
% \inst{2}%
%Department of Theoretical Philosophy\\
%University of Elsewhere}
% - Use the \inst command only if there are several affiliations.
% - Keep it simple, no one is interested in your street address.
\date% (optional, should be abbreviation of conference name)
{Autumn Semester, 2015}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
% yourself) who are reading the slides online
%\subject{Theoretical Computer Science}
% This is only inserted into the PDF information catalog. Can be left
% out.
% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:
\pgfdeclareimage[height=0.75cm]{university-logo}{IIIT_logo.jpg}
\logo{\pgfuseimage{university-logo}}
% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
% \AtBeginSubsection[]
% {
% \begin{frame}<beamer>{Outline}
% \tableofcontents[currentsection,currentsubsection]
% \end{frame}
% }
% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command:
%\beamerdefaultoverlayspecification{<+->}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{Lecture Outline}
\begin{itemize}
\item CPU Scheduling Basics
\item CPU Scheduler and Dispatcher
\item Scheduling Criteria
\item First Come First Serve (FCFS) Scheduling
\item First Shortest Job First (SJF) Scheduling
\end{itemize}
\textcolor{black}{References and Illustrations have been used from:}
\begin{itemize}
\item lecture slides of the book - Operating System Concepts by Silberschatz, Galvin and Gagne, 2005
\item Modern Operating System by Andrew S. Tanenbaum
\item lecture slides of CSE 30341: Operating Systems (Instructor : Surendar Chandra),
\end{itemize}
\end{frame}
\begin{frame}{CPU Scheduling: Basic Concepts}
\begin{itemize}
\item Maximum CPU utilization obtained with multiprogramming - several processes are kept in memory, while one is waiting for I/O, the OS gives the CPU to another process
\item CPU scheduling depends on the observation that processes cycle between CPU execution and I/O wait.
\end{itemize}
\end{frame}
\begin{frame}{Alternating Sequence of CPU And I/O Bursts}
\begin{figure}
\centering
\includegraphics[width=0.85\textwidth]{cpu_io.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{Histogram of CPU Burst Times}
\begin{figure}
\centering
\includegraphics[width=0.75\textwidth]{histogram.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{CPU Scheduler}
\begin{itemize}
\item Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them
\item CPU scheduling decisions may take place when a process:
\begin{enumerate}
\item Switches from running to waiting state (e.g. I/O request)
\item Switches from running to ready state (e.g. Interrupt)
\item Switches from waiting to ready (e.g. I/O completion)
\item Terminates
\end{enumerate}
\item Scheduling under 1 and 4 is \emph{non-preemptive} (cooperative)
\item All other scheduling is \emph{preemptive} - have to deal with possibility that operations (system calls) may be incomplete
\end{itemize}
\end{frame}
\begin{frame}{Dispatcher}
\begin{itemize}
\item Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:
\begin{enumerate}
\item switching context
\item switching to user mode
\item jumping to the proper location in the user program to restart that program
\end{enumerate}
\item Dispatch latency – time it takes for the dispatcher to stop one process and start another running
\begin{itemize}
\item Should be as low as possible
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{Scheduling Criteria}
\begin{itemize}
\item CPU utilization (max) – keep the CPU as busy as possible
\item Throughput (max) – \# of processes that complete their execution per time unit
\item Turnaround time (min) – amount of time to execute a particular process
\item Waiting time (min) – amount of time a process has been waiting in the ready queue
\item Response time (min) – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
\item In typical OS, we optimize each to various degrees depending on what we are optimizing the OS
\end{itemize}
\end{frame}
\begin{frame}{Optimization Criteria}
\begin{itemize}
\item Max CPU utilization
\item Max throughput
\item Min turnaround time
\item Min waiting time
\item Min response time
\item Analysis using Gantt chart (illustrates when processes complete)
\end{itemize}
\end{frame}
\begin{frame}{First Come First Serve (FCFS) Scheduling}
\begin{figure}
\centering
\includegraphics[width=0.65\textwidth]{fcfs.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{First Come First Serve Scheduling}
\begin{figure}
\centering
\includegraphics[width=0.65\textwidth]{fcfs1.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{Shortest Job First (SJF)}
\begin{itemize}
\item Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest times
\item Two schemes:
\begin{itemize}
\item \emph{nonpreemptive} – once CPU given to the process, it cannot be preempted until completes its CPU burst
\item \emph{preemptive} – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the \textbf{Shortest-Remaining-Time-First (SRTF)}
\end{itemize}
\item SJF is optimal – gives minimum average waiting time for a given set of processes
\end{itemize}
\end{frame}
\begin{frame}{Non-preemptive SJF}
\begin{figure}
\centering
\includegraphics[width=0.65\textwidth]{sjf.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{Preemptive SJF}
\begin{figure}
\centering
\includegraphics[width=0.65\textwidth]{sjf_premptive.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
\begin{frame}{Determining Length of Next CPU Burst}
\begin{itemize}
\item Can only estimate the length
\item Can be done by using the length of previous CPU bursts, using exponential averaging
\begin{enumerate}
\item $t_{n}$ = actual length of $n^{th}$ CPU burst
\item $\tau_{n+1}$ = predicted value of next CPU burst
\item $\alpha$ = $0 \leq \alpha \leq 1$
\item $\tau_{n+1} = \alpha \tau_{n} + (1-\alpha) \tau_{n}$
\end{enumerate}
\end{itemize}
\end{frame}
\begin{frame}{Prediction of the Length of the Next CPU Burst}
\begin{figure}
\centering
\includegraphics[width=0.65\textwidth]{next_burst.pdf}
%\caption{Process created during execution of a.out}
\end{figure}
\end{frame}
%
%
\begin{frame}{Examples of Exponential Averaging}
\begin{itemize}
\item if $\alpha = 0 \implies \tau_{n+1} = \tau_{n} $ : Recent history does not count
\item if $\alpha = 1 \implies \tau_{n+1} = t_{n}$ : Only the actual last CPU burst counts
\end{itemize}
\end{frame}
%
%
%
\end{document}