Your IP : 216.73.216.40


Current Path : /var/www/html/bibhas.ghoshal/lecture_slides/lect1/
Upload File :
Current File : /var/www/html/bibhas.ghoshal/lecture_slides/lect1/lect1.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{blue}{yellow}
%\usepackage{}
\title[OPS-332: OS] % (optional, use only with long paper titles)
{ Lecture 1 - Operating System Overview}

%\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 Defining an Operating System
   \item Computer System Structure 
   \item Illustration of the role of Operating System
   \item Hardware control aspect of Operating System
   \item Goals of Operating System
   \item Multitasking and Multiuser Operating System
    \item Operating System structure
   
  \end{itemize}
\textcolor{red}{Some slides have been taken from:}
 \begin{itemize}
  \item lecture slides of the book - Operating System Concepts by Silberschatz, Galvin and Gagne, 2005 
  \item lecture slides of CS140 –  (Instructors: Adam Belay et al.), Stanford University
  \item lecture slides of CSE 30341: Operating Systems (Instructor : Surendar Chandra), 
 \end{itemize}

  
\end{frame}



\begin{frame}{What is an Operating system?}
 \underline{Abstract View}\\
 \vspace{5pt}
 College Student - something that allows me to \textcolor{green}{browse the internet} on my smart phone \\ \vspace{5pt}
 Salesman  - allows me to \textcolor{green}{use the sales package} on the computer  \\\vspace{5pt}
 Programmer - allows me to develop programs efficiently (\textcolor{green}{utilizing the compiler's ability}) \\\vspace{5pt}
 Technician at chemical plant - component of the computer system that controls the plant (\textcolor{green}{ control}) \\\vspace{5pt}
 
\end{frame}

\begin{frame}{What is an Operating system?}
\underline{Deductions from the four views of the OS}
\vspace{5pt}
\begin{itemize}
 \item All views are correct, but none complete
 \item Each view considers use of computer system for intended purpose but ignores other elements
 \item Commonality in the views : Utilization of computer system for specific purpose
\end{itemize}

\vspace{10pt}

\textcolor {green}  {OS : Something that allows the user to achieve the intended purpose of using the computer system in a fast and efficient manner}
 
\end{frame}

\begin{frame}{Computer System Components}

  \begin{itemize}
      \item Computer system can be divided into :
	  \begin{itemize}
	    \item Hardware – provides basic computing resources
		\begin{itemize}
		    \item Processing (CPU, graphics controller), storage(disk,memory), I/O devices (keyboard, mouse, CD/Tape, printer)
		\end{itemize}

	    \item Application programs – define the ways in which the system resources are used to solve the computing problems of the users
		\begin{itemize}
		    \item Word processors, compilers, web browsers, database systems, video games
		 \end{itemize}

	    \end{itemize}


	\item Users (people, machines) want to run applications on hardware

   \end{itemize}
        
\textcolor{green} {Operating system controls and coordinates use of hardware among various applications and users}\\
%\textcolor{green} {Two views for OS}
\begin{itemize}
 \item User view : Concerned with ease of use
 \item System view : Resource utilization / controlling user programs and I/O
\end{itemize}


\end{frame}

\begin{frame}{Abstract View of System Components}
 \begin{figure}
 \centering
    \includegraphics[width=0.80\textwidth]{computer_system_structure.pdf}
 % \caption{Network-on-Chip based system }
  \label{sytem_components}
\end{figure}
\end{frame}

\begin{frame}{A C program to illustrate the use of OS - \textcolor{red}{it has bugs !!!!}}
 1) int main(int argc, char *argv[], char *envp[]) \{\\
 2) char buf[100];\\
 3) char *ptr = malloc(100);\\
 4) printf("Hello world$\backslash n $");\\
 5) int fd = open("/dir1/file", O\_WRONLY, 0666);\\
 6) *(ptr + 1000) = $'\backslash0'$;\\
 7) write(fd, ptr, 100);\\
 8) fsync(fd);\\
 9) close(fd);\\
10) exit(0);\\
11) \}
\end{frame}

\begin{frame}
 \begin{itemize}
  \item Compile the program (\$gcc file.c) - OS makes sure the file (residing in HDD) is provided and takes care of the H/W on which it runs
  \item array call (line 2) - OS allocates a space for array in the memory according to the required format and it ensures that when your friend runs the same program, it does not overwrite contents of your program.
  \item dynamic memory allocation (line 3) - provides more memory than alloted.
  \item library call (e.g printf in line 4)- OS makes sure to write the result on the screen when the library call is made.
  \item system call (e.g. open in line 5) - the OS interprets the string as a file/directory residing in hard disk and transfers it from hard disk to main memory
  
  
  \end{itemize}
  
  \end{frame}
  
  
  

  
  
  \begin{frame}
  \begin{itemize}
  \item segmentation fault (line 6) - you write 1000 bytes to the alloted 100 bytes. OS informs that some condition of the code has been violated. \\
   \underline{Two ways you mess up the code}
    \begin{itemize}
     \item you harm yourself - OS informs you
     \item you harm others - OS ensures you do not do that; prevents writing to memory code alloted to others (open file in read only mode)
    \end{itemize}
  \item write call (line 7) - OS system call transfering something from memory to disk
  \item exit code (line 10) - return to some other program (say console)
 \end{itemize}

 
\end{frame}


\begin{frame}{Key concerns of Operating System}
  \begin{itemize}
   \item Programs - Initiation and termination
   \item Resources - Ensuring availability of resources and allocating them to programs
   \item Scheduling - Deciding when and how long to devote the CPU to a program
   \item Protection - Protect data and programs against interference from other users and their programs
  \end{itemize}

   
  \end{frame}


  \begin{frame}{Hardware Control Aspect of Operating System}
\textbf{\underline{Computer Hardware}}
\begin{itemize}
 \item Components
    \begin{itemize}
     \item Processing - (CPU) performs all computations
     \item Input/Output - Mouse, Keyboard, printer
     \item Storage - Memory, Hard disk, CD
    \end{itemize}

    
 \item Hardware cost forces use of limited resources
        \begin{itemize}
         \item Need to share resources - One or more CPUs, device controllers connect through common bus providing access to shared memory
         
         \item Concurrent execution of CPUs and devices competing for memory cycles
        \end{itemize}   
        
    
 \end{itemize}
\begin{figure}
 %\centering
    \includegraphics[width=0.40\textwidth]{computer_system.jpg}
 % \caption{Network-on-Chip based system }
  \label{primitive os}
\end{figure}
 
 \end{frame}
  
 \begin{frame}{Hardware Control Aspect of Operating System}
 \begin{itemize} 
 \item Technology limitations and costs leads to hierrchy of components
      \begin{itemize}
       \item Storage
            \begin{itemize}
             \item Hard disks are cheap, provide persistence and are slowdown
             \item Main memory is expensive, not persistent but faster
             \item Cache/Registers very expensive, not persistent but fastest
             \item CD is persistent, very slow, cheap and removable
            \end{itemize}

       \item Processing
          \begin{itemize}
           \item CPU is expensive and general purpose
           \item Dedicated controllers (graphics processors, SCSI controllers)
          \end{itemize}

      \end{itemize}

 

\end{itemize}

 
\end{frame}




\begin{frame}{Hardware Control Aspect of the Operating System}
\begin{itemize}
 \item OS acts as an intermediary between a user of a computer and the computer hardware
    \begin{itemize}
     \item Challenge is to manage resources for competing users: simultaneously playing interactive games and sending a
           print out to an laser printer 
    \end{itemize}

\item OS is a resource allocator
    \begin{itemize}
     \item Manages all resources (CPU, memory, disks etc.)
     \item Decides between conflicting requests for efficient and fair resource use
    \end{itemize}

\item OS is a control program
   \begin{itemize}
    \item Controls execution of programs to prevent errors and improper use of the computer
   \end{itemize}
\item ``The one program running at all times on the computer” is the kernel.  Everything else is either a system program (ships with the operating system) or an application program
\end{itemize}
\end{frame}
% \begin{frame}{Computer System I/O Operation}
% \begin{itemize}
%  \item I/O devices and the CPU can execute concurrently
%  \item Offload work to the device controllers
%      \begin{itemize}
%       \item Each device controller is in charge of a particular device type
%        \item Each device controller has a local buffer to store pending data
%        \item CPU moves data from/to main memory to/from local buffers
%        \item I/O is from the device to local buffer of controller
%        \item Device controller informs CPU that it has finished its operation by causing an interrupt
%      \end{itemize}
% 
% \end{itemize}
% 
% 
%  
% \end{frame}








\begin{frame}{Goals of an Operating System}
\begin{figure}
 %\centering
    \includegraphics[width=0.30\textwidth]{os_abstract_view.pdf}
  \caption{Abstract view of Operating System }
  \label{primitive os}
\end{figure}
 \begin{itemize}
  \item Layer between application and hardware
  \item Makes hardware useful to programmer
  \item Provides abstractions for applications
   \begin{itemize}
    \item Manages and hides details of hardware
    \item Accesses hardware through low level applications unavailable to applications
   \end{itemize}
   \item Provides protection
    \begin{itemize}
       \item Prevents one user from clobbering another
    \end{itemize}

 \end{itemize}

\end{frame}



\begin{frame}{Operating System Structure}{Primitive OS} 
 \begin{figure}
 %\centering
    \includegraphics[width=0.30\textwidth]{primitive_os.pdf}
  \caption{Abstract view of primitive OS  }
  \label{primitive os}
\end{figure}
\begin{itemize} 
 \item Just a library of standard services [no protection]
 \item Standard interface above hardware-specific drivers, etc.
 \item System runs one program at a times
 \item Simplifying assumptions - No bad users or programs (often bad assumption)
 \item Poor utilization of hardware (e.g., CPU idle while waiting for disk) 
 \item Poor uitilization of human user (must wait for each program to finish)
\end{itemize}

\end{frame}

\begin{frame}{Operating System Structure}{Features of Modern OS}
\begin{itemize}
 \item Multi-programming
 \item Multi-user OS
 \item Time sharing (multi-tasking)
 \item Protection mechanism
\end{itemize}

 
\end{frame}



\begin{frame}{Multiprogramming}

 \begin{figure}
 %\centering
    \includegraphics[width=0.30\textwidth]{multitasking.pdf}
  \caption{Multiprogramming}
  \label{primitive os}
\end{figure}
\begin{itemize} 
\item Idea: Run more than one process at once; When one process blocks (waiting for disk, network, user input,
etc.) run another process

\item Problem: What can ill-behaved process do?
    \begin{itemize}
	\item Go into infinite loop and never relinquish CPU
	\item Scribble over other processes’ memory to make them fail
     \end{itemize}
\item OS provides mechanisms to address these problems
     \begin{itemize}
      \item Pre-emption – take CPU away from looping processed
      \item Memory protection – protect process’s memory from one another
     \end{itemize}



\end{itemize}

\end{frame}



\begin{frame}{Multiprogramming - needed for efficiency}
 
     \begin{itemize}
      \item Single user cannot keep CPU and I/O devices busy at all times
      \item Multiprogramming organizes jobs (code and data) so CPU always has one to execute
      \item A subset of total jobs in system is kept in memory
      \item One job selected and run via job scheduling
      \item When it has to wait (e.g, for I/O), OS switches to another job
       \item Need to be careful for IO. For example, printer cannot be directly shared between two jobs
     \end{itemize}

 
 \vspace{-30pt}
 
\begin{figure}
 \includegraphics[width=0.55\textwidth]{multi_programming.pdf}
\caption{Memory Layout for Multi-programmed System}
\end{figure} 
 
 \end{frame}

 
 \begin{frame}{Multi-user OS}
 \begin{figure}
 %\centering
    \includegraphics[width=0.35\textwidth]{multiuser.pdf}
  \caption{Multi-user OS}
  \label{primitive os}
\end{figure}
\begin{itemize} 
\item Many OSes use protection to serve distrustful users/apps
\item With N users, system not N times slower

    \begin{itemize}
	\item Users’ demands for CPU, memory, etc. are bursty
	\item Win by giving resources to users who actually need them
     \end{itemize}
\item What can go wrong?
     \begin{itemize}
      \item Users are gluttons, use too much CPU, etc. (need policies)
      \item Total memory usage greater than in machine (must virtualize)
      \item Super-linear slowdown with increasing demand (thrashing)
     \end{itemize}



\end{itemize}

\end{frame}

 
 
 
 
 \begin{frame}{Multi-tasking}
  \begin{itemize}
   \item Time sharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing
      \begin{itemize}
	  \item Response time should be small ($<$ 1 second)
	  \item Each user has programs executing in memory $\implies$process abstraction 
     \item If several jobs ready to run at the same time $\implies$ process management
      \item If processes don’t fit in memory, swapping moves them in and out to run $\implies$ memory and storage management
      \item Virtual memory allows execution of processes not completely in memory
     \end{itemize}

 
\end{itemize}
 \end{frame}


 
 
\begin{frame}{Protection Structure}
 \begin{itemize}
  \item OS should protect the users/processes from each other as well as protect itself from users
  \item Dual-mode operation allows OS to protect itself and other system components
     \begin{itemize}
      \item \textbf{User mode} and \textbf{kernel mode}
      \item \textbf{Mode bit} provided by hardware
         \begin{itemize}
          \item Provides ability to distinguish when system is running user code or kernel code
          \item Some instructions designated as privileged, only executable in kernel mode
          \item System call changes mode to kernel, return from call resets it to user
         \end{itemize}

     \end{itemize}

 \end{itemize}

 
 
\end{frame}

\begin{frame}{Transition from User to Kernel Mode}
\begin{itemize}
 \item Timer to prevent infinite loop / process hogging resources
 \begin{itemize}
  \item Set interrupt after specific period
  \item Operating system decrements counter
   \item When counter zero generate an interrupt
    \item Set up before scheduling process to regain control or terminate program that exceeds allotted time
 \end{itemize}
\vspace{-60pt}

\end{itemize}
\begin{figure}
 \includegraphics[width=1.0\textwidth]{user_to_kernel.pdf}
\caption{}
\end{figure} 
 
\end{frame}

\begin{frame}{Process Management}
\begin{itemize}
 \item A \textcolor{red}{process} is a program in execution. It is a unit of work within the system. \\\textcolor{red}{Program} is a passive entity, process is an active entity.
\item Process needs resources to accomplish its task- CPU, memory, I/O, files and Initialization data
\item Process termination requires reclaim of any reusable resources
\item Single-threaded process has one program counter specifying location of next instruction to execute
\item Process executes instructions sequentially, one at a time, until completion
\item Multi-threaded process has one program counter per thread
\item Typically system has many processes, some user, some operating system running concurrently on one or more CPUs
\item Concurrency by multiplexing the CPUs among the processes / threads
\end{itemize}
\end{frame}

\begin{frame}{Process Management}
The operating system is responsible for the following activities in  connection with process management:
 \begin{itemize}
  
\item Creating and deleting both user and system processes
\item Suspending and resuming processes
\item Providing mechanisms for process synchronization
\item Providing mechanisms for process communication
\item Providing mechanisms for deadlock handling
 \end{itemize}

\end{frame}

\begin{frame}{Memory Management}
 \begin{itemize}
  \item All data in memory before and after processing
\item All instructions in memory in order to execute
 \item Memory management determines what is in memory when
\item Optimizing CPU utilization and computer response to users
\item Memory management activities
\item Keeping track of which parts of memory are currently being used and by whom
\item Deciding which processes (or parts thereof) and data to move into and out of memory
\item Allocating and deallocating memory space as needed
 \end{itemize}
\end{frame}

\begin{frame}{Storage Management}
 \begin{itemize}
  \item OS provides uniform, logical view of information storage
      \begin{itemize}
       \item Abstracts physical properties to logical storage unit  - file
       \item Each medium is controlled by device (i.e., disk drive, tape drive)
        \begin{itemize}
         \item Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)
        \end{itemize}
     \end{itemize}

  \item File-System management
       \begin{itemize}
        \item Files usually organized into directories
         \item Access control on most systems to determine who can access what
         \item OS activities include
             \begin{itemize}
              \item Creating and deleting files and directories
	      \item Primitives to manipulate files and dirs
	      \item Mapping files onto secondary storage
	      \item Backup files onto stable (non-volatile) storage media
             \end{itemize}

       \end{itemize}

     
 \end{itemize}
\end{frame}

\begin{frame}{I/O Subsystem}
 \begin{itemize}
  \item One purpose of OS is to hide peculiarities of hardware devices from the user
  \item I/O subsystem responsible for
    \begin{itemize}
     \item Memory management of I/O including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs)
\item General device-driver interface
\item Drivers for specific hardware devices
    \end{itemize}



 \end{itemize}
\end{frame}

\begin{frame}{Protection and Security}
 \begin{itemize}
  \item Protection – any mechanism for controlling access of processes or users to resources defined by the OS
\item Security – defense of the system against internal and external attacks
    \begin{itemize}
     \item Huge range, including denial-of-service, worms, viruses, identity theft, theft of service
    \end{itemize}
\item Systems generally first distinguish among users, to determine who can do whatever
     \begin{itemize}
      \item User identities (user IDs, security IDs) include name and associated number, one per user
\item User ID then associated with all files, processes of that user to determine access control
\item Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file 
\item Privilege escalation allows user to change to effective ID with more rights
     \end{itemize}

 \end{itemize}
\end{frame}


\begin{frame}{Examples of Operating Systems}
\begin{itemize}
 \item Desktop and server OS: Microsoft Windows, UNIX and variants (Linux, Solaris, FreeBSD, Mac OSX)
      \begin{itemize}
       \item Resource utilization is important
      \end{itemize}
  \item Embedded and \textbf{Realtime} systems: smart phones, runs your cars, TV, washing machines, nuclear plants etc. (e.g.
QNX, Vxworks, Embedded linux (Android))
 \begin{itemize}
  \item Meeting timing constraints is a major concern
 \end{itemize}
\item \textbf{Distributed Systems} : Distribute the computation among several physical processors
    \begin{itemize}
     \item Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines
     \item Advantages of distributed systems - Resources Sharing, Reliability, Load sharing, Communication
    \end{itemize}

\end{itemize}

 
\end{frame}


\begin{frame}{Wrap Up}
\begin{itemize}
 \item Operating System is a program that acts as an intermediary between a user of a computer and the computer hardware, allowing users to conveniently and efficiently use the computer system so as to execute user programs and make problem easier.
 \item Operating Systems cannot make hardware go faster. However, OS can make h/w appear faster.
 \item Trade-off depends on specific operating scenario - distributed/centralized
\end{itemize}

 
\end{frame}









































\end{document}