Chapter 3 Operating Systems (OS)
• 3.1 The Evolution of Operating Systems
• 3.2 Operating System Architecture
• 3.3 Coordinating the Machine’s Activities
• 3.4 Handling Competition Among Processes
• 3.5 Security
3-1
Some basic functions of an operation system
• Control operation of computer
• Store and retrieve files
• Schedule programs for execution
• Coordinate the execute of programs
Example operating systems:
Windows, UNIX, LINUX, MacOS, Multics,
VMS, MS-DOS, Mobile OS (IOS, Android) 3-2
Operating System
• A program that acts as an intermediary between a
user of a computer and the computer hardware.
• Operating system goals:
• Execute user programs and make solving user problems
easier.
• Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
• The OS depends on and complements the hardware
3-3
Some Operating Systems functions
• Interface manager
• Human interaction made easy
• Interfacing, abstraction, control and sharing
• Graphical User Interface
• GUI: recognize and point/click
• Command Line Interface
• CLI: remember and type (Mac Terminal, Command Prompt)
• Resource manager
• Efficient use of resources: Memory management
and processor scheduling
• System and data security and protection provider
3-4
3.1 History of Operating Systems
Evolution of shared computing
• Batch processing
– Job queue
• Time-sharing
– Interactive processing
– Real-time processing
– Multi-tasking: multiple tasks for a single user
• Scheduling multiprocessor machines
3-5
Figure 3.1 Batch processing
programmer
operator
Jobs are loaded all together and executed according to a
certain priority order with no interaction with the user.
3-6
Figure 3.2 Interactive processing
User interaction with executing program.
3-7
Real-time processing: Computer performs the
processing tasks quickly enough to be able to
keep up with activities in its external (real-world)
environment.
3-8
Uniprogramming: One CPU, one program, Program runs until
completion.
Multiprogramming: One CPU, many programs. Programs run
without interruption until an I/O request or termination.
Supporting interactive processing by computers running for
several users at the same time, perhaps in 'real-time' applications,
required a change in operating systems.
One solution: Design the OS so that it rotates various jobs in
and out of execution.
Time-sharing: One CPU, many programs. Each program can run
a short amount of time before being interrupted by the system.
3-9
•When computer usage evolved from batch mode to
interactive mode, multiprogramming was no longer a
suitable approach.
•Each user wanted to see his/her program running as if
it was the only program in the computer (parallel
processing).
3-10
Time-sharing
- creates the illusion of several jobs being executed
simultaneously
- originally used for multiple users, each running one
job (to avoid, e.g., one user’s job hogging the CPU)
- now used to allow one user to execute multiple
processes at the same time: multitasking
multitasking is time-sharing for one user’s processes
on a single-processor machine
3-11
3.2 OS Architecture
Types of software
• Application software
– Perform specific tasks for users
– Spreadsheets, games, etc.
• System software
– Perform tasks common to computer systems in general
– Operating system
– Utility software
• extend the capabilities of the OS
– format disks, copy from disk to CD, compress/decompress data,
handling network communications, etc
3-12
Figure 3.3 A machine’s software
classification
3-13
Utility software: The majority of an installation’s utility
software consists of programs for performing activities
that are fundamental to computer installations but not
included in the operating system. In a sense, utility
software consists of software units that extend the
capabilities of the operating system. The ability to format
a disk or to copy a file from a magnetic disk to a flash
drive is often not implemented within OS.
3-14
Components of an OS
• Shell: portion that communicates with users
– Graphical user interface (GUI)
• Window manager
• Kernel: contains components performing basic
required functions
– File manager
– Device drivers
– Memory manager
– Scheduler and dispatcher
3-15
The shell and the kernel are two important components that
work together to enable the user to interact with the system.
•Shell : A shell is an environment or a special user program
which provide an interface to user to use operating system
services. It executes programs based on the input provided by
the user.
•Kernel : Kernel is the heart and core of an operating system
that manages operations of computer and hardware. It acts as a
bridge between the user and the resources of the system by
accessing various computer resources like the CPU, I/O
devices and other resources.
3-16
Figure 3.4 The shell as an interface
between users and
the operating system
3-17
File Manager
• Coordinates the use of the mass storage facilities:
maintain records (on the storage media) of
– all files stored, including their location
– which users are allowed access to which files
– where free storage space is available
• Directory or folder: user-created group or bundle of
files
• Path: position of a file in directory hierarchy
• File descriptor: information (in main memory) needed
to access a file
3-18
Device Drivers
• Software units that communicate with the
controllers (or sometimes directly with peripheral
devices.)
• Controller: intermediary device that handles
communication between the computer and a
device.
• Drivers
– are uniquely designed for particular types of devices.
– translates generic requests into more technical steps
• Thus, other software do not deal with details.
3-19
Controllers attached to a
machine’s bus
3-20
Memory manager
• Coordinates the use of main memory
• In multi-tasking / multi-user environments
many programs and blocks of data must reside
in main memory concurrently. Hence memory
manager must:
– find and assign memory space for these needs
– ensure the actions of each program are restricted to
its allotted space
– keep track of memory areas no longer occupied
3-21
Memory manager
• When total memory required is greater than
available memory, memory manager moves
programs to and from between main memory
and mass storage (paging)
• The fictional memory space created by paging
is called virtual memory.
• 2 other components of kernel (scheduler and
dispacther).
– Studied in the next section ...
3-22
Getting it Started
• Do we know how the operating system gets started?
• Boot strapping (a.k.a. booting):
– Main memory is empty when computer is first turned on.
The OS is permanent on mass storage.
– This procedure brings the OS into main memory.
– A small ROM memory contains the program called
bootstrap. CPU runs bootstrap when turned on.
– Transfers operating system from mass storage to main
memory.
– Directs the CPU to execute a jump instruction to that
memory area.
3-23
Figure 3.5 The booting process
3-24
3.3 Coordinating Machine’s Activities
• The words Program and Process are sometimes
used instead of each other, but there is actually
a distinction between the two.
– Program: a static set of directions, whereas
– Process: the dynamic activity of executing a
program (whose properties change with time).
• Process state: current status of the activity (or,
snapshot of machine at a particular time)
– Position in the program being executed (Program
Counter), values in processor registers, etc.
3-25
Process Administration
• Scheduler
– Maintains a record of all processes, introduces new
ones, and removes those that are complete.
– Keeps the process table in main memory. An entry
in the process table has information about a
particular process, such as:
• Memory area assigned to it,
• Priority of the process,
• Whether it is Ready or Waiting, etc.
3-26
Process Administration (continued)
• Dispatcher
– Ensures scheduled processes are actually executed.
– Gives one time slice or quantum to a process that is
ready
– Executes a process switch (or context switch) when
the running process’s time slice is over.
• Interrupt indicates that time slice is over
• Interrupt handler: part of dispatcher
3-27
Figure 3.6 Time-sharing between
process A and process B
•A timeslice typically is no more than 0.05 seconds
•When context switches occur frequently enough the
illusion of parallelism is achieved.
3-28
Deadlock
• Two (or more) processes block each other from
continuing
– each process is waiting for a resource allocated to
another
• Conditions that lead to deadlock [all 3 needed]
1. There is competition for non-sharable resources.
2. The resources are requested on a partial basis: i.e.
having received some resources, a process will return
later to request more.
3. Once a resource has been allocated it cannot be forcibly
retrieved.
3-29
Figure 3.7 A deadlock resulting from
competition for non-shareable railroad
intersections
3-30
•Deadlock problem can be removed by removing any
one of these three conditions.
•Techniques attacking 3rd condition fall into deadlock
detection and correction category.
•Techniques attacking first 2 conditions are known as
deadlock avoidance schemes.
•Convert a non-shareable resource into a shareable one, or
makes it appear shareable (e.g. Spooling)
•Each process can request all its resources at once
3-31
3.5 Security
• Computer system security requires a well-
designed, dependable operating system
• Administrator or super user has privileged
access to the operating system
– can monitor activity to detect destructive behaviour,
malicious or accidental
– auditing software: The software utilities to help
• identify attempts to login with incorrect password
• identify accounts where computer use has changed
suspiciously (e.g. Windows Event Viewer)
3-32
Security from attacks from within
• Operating system prevents illegal access to
resources
– Different memory for different processes
– Privileged instructions only allowed in kernel
• e.g. change content of memory limit registers
change privilege mode of the CPU
3-33