Operating System
(01)
Introduction to Operating System
What is an Operating System?
• An operating system acts as an intermediary between the
user of a computer and the computer hardware. The
purpose of an operating system is to provide an
environment in which a user can execute programs in a
convenient and efficient manner.
• An operating system is a program that manages the
computer hardware. It also provides a basis for
application programs and acts as an intermediary
between the computer user and the computer hardware.
Introduction to Computer Networks
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
Definition Operating System
• Definition
An operating system is a
program that acts as an
interface between the user
and the computer hardware
and controls the execution
of all kinds of programs.
Computer System Structure
Computer system can be divided into four components:
1. Hardware – provides basic computing resources
CPU, memory, I/O devices
2. Operating system -- Controls and coordinates use of
hardware among various applications and users
3. Application programs – define the ways in which the
system resources are used to solve the computing problems
of the users
Computer System Structure
Word processors,
compilers, web
browsers, database
systems, video games
4. Users --
• People, machines,
other computers
What Operating Systems Do
The operating system controls the hardware and
coordinates its use among the various application
programs for the various users.
The operating system provides the means for proper use of
these resources in the operation of the computer system.
Functions of Operating Systems
Provide a user interface
Run programs
Manage hardware devices
Organized file storage
Providing a User Interface
User interface
How a user interacts with a computer
Require different skill sets
Providing a User Interface
Graphical user interface (GUI)
Most common interface
Windows, OS X, Gnome, KDE
Uses a mouse to control objects
Shortcuts open programs or documents
Open documents have additional objects
Task switching
Dialog boxes allow directed input
Graphical User Interface
Providing a User Interface
• Command line interfaces
– Older interface
• DOS, Linux, UNIX
– User types commands at a prompt
– User must remember all commands
– Included in all GUIs
Command Line Interface
Running Programs
• Many different applications supported
• System call
– Provides consistent access to OS features
• Share information between programs
– Copy and paste
– Object Linking and Embedding
Managing Hardware
• Programs need to access hardware
• Interrupts
– CPU is stopped
– Hardware device is accessed
• Device drivers control the hardware
Organizing Files and Folders
• Organized storage
• Long file names
• Folders can be created and nested
• All storage devices work consistently
Operating systems history
First generation: 1945 – 1955
Vacuum tubes
Plug boards
Second generation: 1955 – 1965
Transistors
Batch systems
Third generation: 1965 – 1980
Integrated circuits
Multiprogramming
Operating systems history
Fourth generation: 1980 – present
Large scale integration
Personal computers
Next generation: ???
Systems connected by high-speed networks?
Wide area resource management?
First generation
• Computers were using vacuum tube technology.
First generation
• Run one job at a time
– Enter it into the computer (might require rewiring!)
– Run it
– Record the results
• Problem: lots of wasted computer time!
– Computer was idle during first and last steps
– Computers were very expensive!
Second generation: batch systems
Bring cards to 1401
Read cards onto input tape
Put input tape on 7094
Perform the computation, writing results to output tape
Put output tape on 1401, which prints output
Second generation: batch systems
• Original batch systems used tape drives
• Later batch systems used disks for buffering
– Operator read cards onto disk attached to the
computer
– Computer read jobs from disk
– Computer wrote job results to disk
– Operator directed that job results be printed from
disk
– Computer overlapped I/O of one job with execution
of another
– Better utilization of the expensive CPU
– Still only one job active at any given time
Third generation: multiprogramming
• Multiple jobs in memory
– Protected from one another
• Operating system protected from each job as well
• Resources (time, hardware) split between jobs
• Still not interactive
– User submits job
– Computer runs it
– User gets results minutes (hours, days) later
Third generation: multiprogramming
• Multiprogramming allowed several jobs to be active at one
time
– Initially used for batch systems
– Cheaper hardware terminals -> interactive use
• Computer use got much cheaper and easier
– No more “priesthood”
– Quick turnaround meant quick fixes for problems
Operating-System Operations
• The modern operating systems are interrupt driven. If
there are no processes to execute, no I/0 devices to service,
and no users to whom to respond, an operating system
will sit quietly waiting for something to happen.
• The interrupt-driven nature of an operating system
defines that system's general structure. For each type of
interrupt, separate segments of code in the operating
system determine what action should be taken.
Introduction to Computer Networks
Operating-System Operations
• Interrupt driven by hardware.
• Software error or request creates exception or trap.
• Division by zero, request for operating system service.
• Other process problems include infinite loop, processes
modifying each other or the operating system.
• Without protection against ضدthese sorts of errors, either
the computer must execute only one process at a time or all
output must be suspect. A properly designed operating
system must ensure that an incorrect (or malicious)
program cannot cause other program to execute
incorrectly.
Dual-Mode Operation
• To ensure the proper execution of the operating system,
we must be able to distinguish between the execution of
operating-system code and user defined code.
• The approach taken by most computer systems is to
provide hardware support that allows us to differentiate
among various modes of execution.
• we need two separate modes of operations. Dual-mode
operation allows OS to protect itself and other system
components.
Dual-Mode Operation
– User mode and kernel mode .
– Mode bit provided by hardware.
• Provides ability to distinguish when system is
running user code or kernel code.
• Some instructions designated as privileged, only
executable in kernel mode.
• System call changes mode to kernel, return from
call resets it to user.
Transition from User to Kernel Mode
Timer to prevent infinite loop / process hogging resources.
• Set interrupt after specific period.
• Operating system decrements counter.
• When counter zero generate an interrupt.
• Set up before scheduling process to regain control or
terminate program that exceeds allotted time.
Usage of Timer
• we can use the timer to prevent a user program from
running too long. A simple technique is to initialize a
counter with the amount of time that a program is allowed
to run.
• A program with a 7-minute time limit, for example, would
have its counter initialized to 420. Every second, the timer
interrupts and the counter is decremented by 1.
• As long as the counter is positive, control is returned to the
user program. When the counter becomes negative, the
operating system terminates the program for exceeding the
assigned time limit.
Process Management
• A process is a program in execution. It is a unit of work within the
system. Program is a passive entity, process is an active entity.
– A program in execution, as mentioned, is a process.
– A time-shared user program such as a compiler is a process.
– A word-processing program being run by an individual user on a
PC is a process.
– A system task, such as sending output to a printer, can also be a
process
Process Management
A process is a program in execution. A process needs
certain resources, including CPU time, memory, files, and
I/O devices, to accomplish its task.
• Process termination requires reclaim of any reusable
resources.
• Single-threaded process has one program counter
specifying location of next instruction to execute.
-Process executes instructions sequentially, one at a
time, until completion.
Process Management
• Multi-threaded process has one program counter per
thread.
• Typically system has many processes, some user, some
operating system running concurrently on one or more
CPUs.
-Concurrency by multiplexing the CPUs among the
processes / threads.
Process Management Activities
The operating system is responsible for the following
activities in connection with process management:
• Creating and deleting both user and system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
• Providing mechanisms for deadlock handling
Memory Management
• Memory is a large array of words or bytes, each with its
own address. It is a repository of quickly accessible data
shared by the CPU and I/O devices.
• Main memory is a volatile storage device. It loses its
contents in the case of system failure.
• All data in memory before and after processing
• All instructions in memory in order to execute
Memory Management
• Memory management determines what is in memory when
- Optimizing CPU utilization and computer response to
users
• The operating system is responsible for the following activities
in connections with memory management:
• Keep track of which parts of memory are currently
being used and by whom.
• Deciding which processes and data to move into and out
of memory
• Allocate and deallocate memory space as needed.
Storage Management
• Since main memory (primary storage) is volatile and too
small to accommodate all data and programs permanently,
the computer system must provide secondary storage to back
up main memory.
• Most modern computer systems use disks as the principle on-
line storage medium, for both programs and data.
• The operating system is responsible for the following activities
in connection with disk management:
-Free space management
-Storage allocation
-Disk scheduling
Storage Management
• Each medium is controlled by device (i.e., disk drive, tape
drive) Varying properties include access speed, capacity,
data-transfer rate, access method (sequential or random).
• Some storage need not be fast
• Tertiary storage includes optical storage, magnetic tape
• Varies between WORM (write-once, read-many-times)
and RW (read-write)
Performance of Various Levels of Storage
Movement between levels of storage hierarchy can be
explicit or implicit.
File Management
• A file is a collection of related information defined by its creator.
Commonly, files represent programs (both source and object forms)
and data. Files usually organized into directories.
• The operating system is responsible for the following activities in
connections with file management:
– File creation and deletion.
– Directory creation and deletion.
– Support of primitives for manipulating files and directories.
– Mapping files onto secondary storage.
– File backup on stable (nonvolatile) storage media.
I/O System Management
• I/O subsystem responsible for
– 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)
– General device-driver interface
– Drivers for specific hardware devices
Protection and Security
• Protection refers to a mechanism for controlling access by
programs, processes, or users to both system and user
resources.
• The protection mechanism must:
– distinguish between authorized and unauthorized usage.
– specify the controls to be imposed.
– provide a means of enforcement.
• Security – defense of the system against internal and external
attacks Huge range, including denial-of-service, worms,
viruses, identity theft, theft of service.
Protection and Security
• Systems generally first distinguish among users, to determine who
can do what
– User identities (user IDs, security IDs) include name and associated
number, one per user.
– User ID then associated with all files, processes of that user to
determine access control.
– Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file.
– Privilege escalation allows user to change to effective ID with more
rights.
Networking (Distributed Systems)
• A distributed system is a collection processors that do not
share memory or a clock. Each processor has its own local
memory.
• The processors in the system are connected through a
communication network.
• A distributed system provides user access to various system
resources.
Networking (Distributed Systems)
• Network Operating System provides features between
systems across network
– Communication scheme allows systems to exchange
messages
• Access to a shared resource allows:
– Computation speed-up
– Increased data availability
– Enhanced reliability
Special-Purpose Systems
• Real-time embedded systems most prevalent form of computers.
– Vary considerable, special purpose, limited purpose OS, real-time OS.
• Multimedia systems.
– Streams of data must be delivered according to time restrictions .
• Handheld systems.
– PDAs, smart phones, limited CPU, memory, power
– Reduced feature set OS, limited I/O.
Peer-to-Peer (P2P) Computing
• In its simplest form, a peer-to-peer (P2P) network is created when
two or more PCs are connected and share resources without
going through a separate server computer.
• A P2P network can be an ad hoc connection—a couple of
computers connected via a Universal Serial Bus to transfer files.
• P2P does not distinguish clients and servers
– Instead all nodes are considered peers
– May each act as client, server or both
– Node must join P2P network
– Examples include Napster and Gnutella
Peer-to-Peer Computing