(Latest Revision: 
Aug  25, 2010
)  
[08/25/2010: Did some edits of material in sections 1.9 to 1.13]
[08/23/2010: Did some edits of material in sections 1.6 to 1.8]
Chapter One -- Introduction -- Lecture Notes
An OS performs as an intermediary between the user and the hardware,
functioning as a virtual computer that makes the use of the hardware more
convenient and/or efficient.  
-  1.0 Chapter Goals 
     
     -  Tour of OS Components
     
 -  Describe Computer System Organization
     
 
 -  1.1 What Operating Systems Do 
     
     -  Provide An Interface above the Level of the Bare Machine
     
 -  Make the Computer More Efficient
     
 -  Make Computer Use More Convenient
     
 -  Controls and Coordinates Use of the Hardware - esp. I/O - prevents
	  error and misuse.
     
 -  The OS is a manager and allocator of resources: CPU time, storage,
          devices ... There is competition among processes for resources.
     
 -  Provide Functions Commonly Needed by Application Programs
     
 -  Ease of use is a major goal for a PC operating system.
     
 -  Optimizing resource utilization is more important
          for operating systems on Workstations and mainframes.
     
 -  OS features that help conserve battery life are important on
          hand-held computing devices.
     
 -  IMPORTANT: In this course, we will think of the OS as the Kernel -
	  the part of the system that is always on the list of ACTIVE
	  processes - READY to run anytime it can be allocated time on a CPU.
     
 
 -  1.2 Computer-System Organization 
     
     -  The typical system consists of one or more general-purpose CPU's and
	  special purpose controllers sharing a common bus, including a memory
	  controller.  These units are able to operate in parallel, though
	  they compete for the memory.  The memory controller arbitrates.
     
 -  A firmware-resident routine runs at boot time to perform
	  initializations and load & execute the OS.
     
 -  Hardware devices can interrupt the CPU - a signal sent along the
	  system bus
     
 -  A process can interrupt the CPU - by executing a special
	  instruction - also by making an error.
     
 -  The computer is designed in such a way that an interrupt
	  automatically causes suspension of the currently running process and
	  transfer of execution to some predetermined section of code -
	  typically a part of the operating system - an interrupt handler.
     
 -  When an interrupt occurs, everything that will be needed to restart
	  the currently running process must be saved.  The interrupt
	  automatically does some of the saving - for example the saving of
	  the address of the current instruction.  The interrupt handler code
	  may perform other "context-saving" actions.
     
 -  CPU's go through an automatic instruction fetch, decode and execute
          cycle.
     
 -  The CPU can access only programs and data that are in main memory.
	  Permanent copies reside in files on secondary storage.
     
 -  Memory hierarchies consist of many levels with differing speeds,
          costs, sizes and volatility.
     
 -  Typically methods for controlling peripheral devices are quite
	  diverse and complex.  Operating systems have "device driver" code -
	  drivers corresponding to each type of device controller.  The job of
	  the device driver is to receive simple high level commands from the
	  OS, translate the commands, and communicate with the device to
	  achieve the desired effects.
     
 -  Typically drivers have to load bit patterns into registers within
	  the devices in order to "command" the device to perform an action.
     
 -  Typically, when a device finishes performing a data transfer it
	  notifies the OS by sending an interrupt.
     
 -  With Direct Memory Access (DMA) a controller can transfer an entire
	  block of data between device and primary memory, and interrupt the
	  CPU only once, after the entire block has been transferred.
     
 
 -  1.3 Computer-System Architecture 
     
     -  OS's must rise to the challenge of operating various kinds of
	  multiprocessor systems efficiently: SMP's, multiple cores, blade
	  servers & clustered systems.
     
 -  A Multiprocessor System (tightly-coupled system) has two or more
	  general-purpose CPU's that share a bus, and often the clock, main
	  memory and peripherals. Typically a multiprocessor with N CPU's is
	  cheaper than N single-CPU computers and does almost as much work in
	  as little time.  If designed properly, a multiprocessor will exhibit
	  "graceful degradation" and "fault tolerance."
     
 -  A multiprocessor may be asymmetric, but most are symmetric nowadays.
     
 -  Multiple cores are essentially multiprocessors on a chip.  These
	  tend to have the advantages of quicker communication and lower power
	  requirements than multiprocessors constructed from multiple
	  single-core chips.
     
 -  Clustered Systems are like multiprocessors.  They exhibit graceful
	  degradation but are less tightly-coupled, consisting of computers
	  closely connected on some type of high-speed medium, often sharing
	  secondary storage, but not main memory or clock.
     
 -  There are asymmetric and symmetric clustered systems.
     
 -  The forms of parallel processing and sharing found on
          multiprocessors and clustered systems require sophisticated forms of
	  synchronization and data "locking" to prevent incorrect results from
	  "conflicting operations".
     
 
 -  1.4 Operating-System Structure 
     
     -  Multiprogramming was a development pushed into existence by the need
	 for better utilization - the need to keep the CPU and I/O channels of
	 an expensive computer busy, so the computer will do more work per
	 unit time.  A "QUANTUM LEAP" in sophistication of the OS was required
	 -- e.g. context switching, memory management, scheduling, concurrency
	 management, protection, and security.
     
 -  Time-sharing was a "natural" follow-on to multiprogramming that
	  allowed a return to "interactive" computing.  Processes associated
	  with different users are switched very quickly so that every user
	  gets rapid response to every command.
     
 -  Time-sharing tends to make greater demands for swapping and virtual
	  memory. 
     
 -  Traditional time-sharing requires implementing a file system -- not
	  the same as just the ability to write and read disk sectors.
     
 
 -  1.5 Operating-System Operations 
     
     -  A modern operating system is interrupt driven.  Interrupts and traps
	  are what cause the operating system to regain access to the CPU to
	  execute and do whatever it is they need to do.
     
     
     
-  Hardware Protection mechanisms: The hardware and OS should prevent
	  processes from harming the system and each other.  The OS must be
	  protected.  We must be concerned about illegal I/O, illegal memory
	  access, and "hogging" of the CPU.  Tools: traps -- dual mode
	  operation -- memory protection -- base and limit registers --
	  privileged instructions -- timers.  
     
 
      -  In your mental model of how an OS works, do you see the OS as a part
	  of the system that is always executing and always monitoring user
	  processes?  Typically "the OS" is NOT REALLY running all the time.
	  In fact this would make it impossible for user processes ever to
	  execute on a uniprocessor.  An OS can employ hardware protection
	  mechanisms to ensure that it will not lose control of the system,
	  even during periods when the OS is suspended.
     
 -  User processes make requests for services from the OS by making
	  system calls, typically implemented by executing an instruction that
	  triggers a trap.
     
 
 -  1.6 Process Management  
     
     -  A process is a program in execution.  An OS has to schedule, create,
	  delete, suspend, resume, and synchronize processes.
     
 -  Processes compete for resources.  They have to request them from the
	  OS and wait until the OS makes them available.
          
     
 -  An OS must provide a mechanisms by which processes can 
          communicate.
     
 
 -  1.7 Memory Management 
     
     -  Main memory consists of a sequence of a sequence of 'words' - each
	  of which has an address.  We use the term 'word' to refer to
	  whatever is the smallest addressable unit of memory.  On many
	  computers, the word is a byte, but it could be something else - e.g.
	  a 32- or 64-bit word.
     
 -  A computer cannot read directly from secondary memory like it can
	  from main memory. Because of the way computers are designed, in
	  order for a CPU to execute an instruction, the instruction has to be
	  in main memory.
     
 -  The OS has to allocate memory to processes and deallocate it.  It
	  has to keep track of which portions of memory belong to which
	  processes
     
 
 -  1.8 Storage Management 
     
     -  OS's are responsible for implementing file systems on secondary
	  storage: e.g. creating and deleting files & directories, and
	  allocating/deallocating storage space on disk.
     
 -  It is the operating system that creates, out of collections of
	  sectors scattered over secondary memory, what we perceive as a
	  highly organized system of directories and files.
     
 -  The OS has to create and delete files and directories, support
	  primitive operations for manipulating files (e.g. open, seek, read,
	  write and close), map files onto locations in secondary storage, and
	  provide a means for backing up files
     
 -  The OS has to manage free space on disks, allocate storage to files,
	  and may be responsible for scheduling disk operations.
     
 -  Various kinds of caches are important for performance. Hardware-only
	  caches are outside the control of the OS.
     
     
 -  The copying of data between primary and secondary memory is usually
	  under the control of the OS.
     
 -  The OS has to solve consistency and coherence problems, because
	  copies of the same data item may exist concurrently at different
	  levels of the memory hierarchy, and in the caches of more than one
	  CPU.  When one process changes one copy, how will the other copies
	  be updated so that every process looking at any copy of the data
	  will see the same thing?
     
 -  One of the jobs of the OS is to make all the various I/O devices
	  appear to have the same familiar types of controls, when in fact
	  there are many peculiarities in how different devices are designed
	  to be controlled.  OS's provide high-level commands to operate
	  devices, as well as device drivers that interpret the commands and
	  deal with the device-specific commands that are required.  So, for
	  example, an application can ask the OS to get the next character
	  from an input device, and the OS will tell the device driver to get
	  the next character, and then the device driver will issue all the
	  peculiar commands to the device that are needed to get the next
	  character.
     
     
 
 -  1.9 Protection and Security 
     
     -  Although the difference between computer protection and security has
	  become blurred, our text makes an effort to preserve a clear
	  distinction between the two.
     
 -  An OS must perform "gatekeeper" functions - making sure that users
	  provide proper credentials before being given access to system
	  resources.  This is "protection".  The doorman at an expensive hotel
	  and the sentry at a military facility are doing protection work.
     
 -  gatekeepers and sentries certainly cannot adequately prevent all
	  failures, damage or attacks that could hinder the correct operation
	  of the facility.  Besides protection, designer of an OS must be
	  concerned with "security" - insuring that resources are properly
	  used.  It is security work when casino owners watch customers
	  gamble.  The bouncer in a night club and the teacher on yard duty do
	  do security work.
          
     
 
 -  1.10 Distributed Systems 
     
     -  A distributed system is basically a set of computers in
	  communication via a network.
     
 -  A distributed operating system is operating system software that
	  makes a distributed system function as if it were a single computer.
     
 -  A major challenge of the current generation is to build reliable and
	  efficient distributed operating systems.
 
 -  1.11 Special Purpose Systems 
     
     -  Real-Time Embedded Systems typically have primitive OS and primarily
	  perform monitoring and management of devices.  A real-time system
	  has to deal with time constraints imposed by the external
	  environment.  (By the way, this involves more than just being quick.
	  As an example think about a robot whose job is to open a heavy door
	  for you, and then close it behind you.  If you take a run at the
	  door, you don't want the robot to be too late opening it or too
	  early closing it!)
     
 -  Multimedia Systems deal with audio and video files.  Support of
	  multimedia poses challenges for computing systems and at the same
	  time there is demand for multimedia on smaller and smaller devices.
     
 -  Handheld Systems are portable and convenient but suffer from many
	  limitations:  small memories, slow processors, small input and output
	  devices, and power requirements that are difficult to meet.  These
	  devices may be networked with wireless technology: Bluetooth, 802.11
	  and even infrared.
     
 
 
 -  1.12 Computing Environments 
     
     -  Traditional Computing - at the office, roughly chronologically:
	  terminals attached to mainframes, networked PC's, file- and
	  print-servers, laptops, portals providing web access to internal
	  servers, network terminals, handheld devices sync'd to PC's.  At
	  home slow modem connections evolved into small home networks with
	  broadband network connections.
     
 -  Client-Server Computing - client processes make requests for
	  services offered by server processes.
     
 -  Peer-to-Peer Computing - exploits potential of having both client
	  and server processes on a node, and schemes to avoid server
	  bottlenecks through better distribution of clients across the set of
	  available servers.  There may be some use of broadcasting or
	  centralized service.
     
 -  Web-Based Computing - the prevalence of web-enabled devices is
	  increasing rapidly.
     
 
 
 -  1.13 Open Source Operating Systems 
     
     -  Open source software is made available in source form, not just
	  binary code.  This enables programmers to modify it to increase its
	  usefulness to them.  They may find and fix bugs made by programmers
	  who worked on the code before them, and pass along the improved
	  software to other users.  Users of open-source software tend to form
	  associations and give each other help and support, as well as make
	  suggestions for improvement of the software.
     
 -  History - open-source software was in vogue in the early days of
	  computing, became less prevalent with the corporatization of
	  computing, but has come back into quite a lot of prominence, notably
	  under the influence of the Free Software Foundation, founded by
	  Richard Stallman.
     
 -  Linux - original kernel designed by Linus Torvalds (probably with
	  considerable influence from Andrew Tannenbaum's Minix).  It was
	  combined with compilers and utilities produced by Stallman's GNU
	  project.  Many distributions now exist.  Thousands of programmers
	  have worked on Linux (open) source code.
     
 -  BSD Unix - The flavor of unix developed at UC Berkeley - was tied to
	  AT&T unix for some time & required a license, but now is free of
	  AT&T code.  There are many descendants, including the Darwin kernel
	  component code used in the Mac OS X.
     
 -  Solaris - originally the OS of Sun Microsystems was based on
	  Berkeley unix.  Sun migrated to the AT&T based Solaris and
	  eventually open-sourced most of the code it developed.  Some of
	  Solaris is still closed source.
     
 -  Utility - one might say that open-sourcing is a movement that is 
          helping to increase participation in software development.