Você está na página 1de 42

Pre-Course Study

Material
Operating S ystems
Basic Principles of Operating Systems

An operating system is a collection of


software that coordinates the working of
the different components of the system
and gets the user’s job done. The
operating system provides the user with
all the basic things necessary to do his
job.

Is it enough to have microsoft word to


write letters?

No.
1. What if there is no interface to the key board?
2. What if there is nothing that will control the
output to VGA card?
3. What if there is no interface to the human user
so that he can switch on “MS Word “ ?
Yes the answers to all these questions is operating
system.

Technical Definition: An OS is a collection of


system software that coordinates between
the hardware, provides a platform for
softwares to run on and provides the user
with an interface for command inputs.
EG. DOS, Linux, Unix, Windows, MAC, OS/2,
Minix, and many more.
The governmental systems like Postal system,
What does an
Operating System
do?
• An Operating System exploits the
hardware resources of one or more
processors to provide a set of
services to system users.

• An Operating System also manages


secondary memory and input/output
devices on behalf of its users.
Structural Elements of a
Computer
• Processor: Controls the operation of the
computer and its
Data Processing functions.. A single processor
is often termed as
the Central Processing Unit.

• Main memory: Stores data and programs. This


memory is
typically volatile. Contents of this memory are
not retained even
when the computer is shut down.

• I/O modules: Moves data between the


computer and its external
environment, such as disks, data
Schematic Diagram of a
Computer System
MEMORY

INPUT CONTROL UNIT OUTPUT

ALU

• INPUT: Input devices (Keyboard, Mouse etc.) (RAW


MATERIALS)
• OUTPUT: Output devices (VDU, Printers etc. ) (FINISHED
PRODUCTS)
• MEMORY: Main memory (Volatile – commonly known as RAM)
(GODOWN / INVENTORY)
• CONTROL UNIT: A device that generates Signals to command
other units that what to do and what not to. (TOP
MANAGEMENT)
Memory Hierarchy

GROWING SIZE AND DATA RETAINABILITY


Registers

Cache
GROWING SPEED AND COST

Main Memory

Magnetic disk, CD-ROM, CD-RW


DVD-RW, DVD-RAM

Magnetic tape
Objectives of an OS
• It is a program that
 controls the execution of application programs
 acts as an interface between applications and
computer hardware
 manages the resources associated with a
computer

Objectives of an O.S.
 Convenience of use of the computer

 Efficient use of the computing resources


 Should be such that it can permit effective
Thus the basic functions of an OS are –

 Process Management – Managing the


programs that are running.
 Memory Management – Managing and
rationing the memory between processes
and data.
 Storage Management – Managing the
permanent Storage of data on disks or
other media
 I/O Management – Managing the input
and output
 Device / Resource Management –
Managing devices and resources and
allowing the users to share the resources
 Security and Protection – Securing the
system against possible unauthorized
access to data or any other entity.
Operating System as an
Interface
Application Programs End user

Utilities

Programmer

Operating System

Computer Hardware OS System


Designer
• Program Development – variety of services and
Operating
utilities such as System Services
Editors and debuggers. They are usually referred to as
application program
development tools.

• Program Execution – involves a number of steps,


such as loading
Instruction and data in the main memory, initialization of
I/O devices and files, and other resources to be allocated.
OS handles the scheduling.

•Access to I/O devices – Each I/O device has its own


set of
Instructions and control signals. O.S. hides these details
Operating System
• Controlled Services
access to files- nature of I/O device (disk
drive, tape drive) and structure of the data stored in the
files in the storage medium. In the case of multiple users
accessing the processor concurrently, proper protection
mechanisms have to be used.

• System access- For shared or public systems, the


O.S. controls access to the system as a whole and to
specific system resources. Access system provides
protection of resources, and data from unauthorized
users, and resolves resource conflicts

• Error detection and response – Variety of errors


may occur in computer system. Responses may range
from program termination, retrial of the same operation,
or reporting error to the application.
What is the OS made of?
The architecture shown below is
applicable for Unix and its family –
Including Linux
Hardware

Shell

Kernel and
system software

Users

Other Applications
What the hell are
these…..
• User – The system representation of the
human operator who requests for services.
• Application Software – Special software to
help the user do his task (E.g.. MS Word)
• Shell – The program that interprets the
commands or requests given by the user
and gets the job done by the kernel.
• Kernel – The core of the operating system.
It uses the hardware to do the jobs required
by the user or the system. It coordinates
among the hardware and interfaces it with
the above layers.
• System Software – Software that can
access the hardware directly and generally
provides various system services. (E.g.. The
kernel itself, device drivers etc.).
• Hardware – The set of electronic devices
that work together to ultimately do the job
Why Unix or Linux?
How the hell are they different from
others?

Types of Operating Systems –


Access based –
 Single User – Only one user can access the OS
at a time. E.g. DOS, Windows 9x
 Multi User – Multiple users can access the OS at
the same time. E.g. Unix, Windows NT, Linux
Processing Based
 Single processing – Only one process (job) has
control of the whole system at a time. E.g. DOS
 Multi Processing – Multiple processes (jobs)
control defined domain of their own. E.g.
Windows (All versions), Unix, Linux
Environment Based
 Stand alone – Does not support connection
from other systems. E.g. DOS, Windows 9x,
Workstation versions of Windows NT
 Networking – Supports connection from other
systems. E.g. Unix, Linux, Server versions of
My God…
One OS! One Machine!
Multiple jobs?

Techniques of Multiprocessing –
• Multiprogramming
• Timesharing
Note that Multiuser is maintained using
multiprocessing techniques – especially timesharing
technique.
Multiprogramming: When one process
waits to get some job done which does
not requires the CPU, instead of sitting
idle the CPU picks up another process to
work on.
Timesharing: The CPU time is equally
divided among the processes in small
Closer look to the above
techniques
P1, P2, P3 are three different
Multiprogramming
processes
P1 Run Wait Run Wait

Wait Run Wait Run Wait


P2

P3 Wait Run Wait Run Wait

P1, P2, P3 Run Run Run Wait Run Run Run Wait

Any Advantage?
So what is timesharing?

P1

P2

P3

Normal Time interval P1 Completed

I/O Started by P1
So which is better?
Multiprogramming or Timesharing

• Multiprogramming maximizes CPU utilization


• Time-sharing minimizes user response rime

What about the Throughput?


Processes
A process is

• Normal: A program in state of execution

• Waste of words: An instance of a program


running on a computer

• Fundoo…: The entity that can be assigned to


and executed on a processor

• More fundoo?... A unit of activity


characterized by a single sequential thread of
Parts of a Process
• Components of a process
 An executable program
 Associated data required by the program (variable,
work space, buffer, etc.)
 Execution context: internal data used by O.S. to
supervise a process = process state.

Process list Main memory

Program code

Program code
context

context
data

data
Process Control Block
A data structure by which the system
identifies a process.
It contains -
• Identifier: A unique integer associated with a
process
• State : A currently executing process is in
running state
• Priority : Priority level relative to other
processes
• Program counter : Address of the next
instruction of the
program to be executed.
• Memory pointers: pointers to the program
code and data
associated with the process, and any shared
Other fundas…
Resource Management
Responsibilities of the OS in Resource
Management

Scheduling – The management of the queue of


processes so as to make the decisions of when to
execute which process.
O.S. manages the resources of a computer system
and rations them among the processes.
• Factors for scheduling policy:
 Fairness: processes competing for a resource should
be given fair chance of resource access
 Differential responsiveness: O.S. should make
allocation and scheduling decisions to meet total set of
requirements, and in a dynamic manner. E.g., if a
process is waiting for an I/O device, O.S. may schedule
that process as soon as the device is free.
Memory Management
The OS manages the computer’s memory
and allocates memory to processes and
data.
Out of various memory management
schemes the mot used nowadays is Virtual
Memory. The fundas for Virtual Memory
are given below…

4. A facility that allows programs to address memory


from a logical viewpoint
5. Disregards the amount of physical memory actually
available
6. Meets the requirements of multiple user processes
to reside simultaneously in main memory without
any interference
7. (Demand) Paging system and Page faults

Physical memory is not alone
now… !!!

It uses a fast disk (Backing store) to keep


the parts of the processes not in use at
the moment of time.
The process's memory (also called
logical memory) is divided into pages of
equal size and kept in the backing store.
The pages are brought in t the physical
memory as and when required.
The pages are kept in blocks created in
the physical memory called frames. The
sizes of frames and pages are equal. The
Then how does it manage
the disk?
Storage Management…
Auxiliary Memory (Secondary Memory/Non-Volatile
Memory – Mainly Disks) are used to store data
permanently.
The unit of data storage on the Disk is called a File.
A File is a logical structure that stores a chunk of data
in the memory (specially auxiliary memory).
A Directory is a logical group of files which is used to
manage the manage the files on the disk.
File Management –
The way the OS stores the files on the disk and
keeps track of each of the files is called File
Management.
File System – The logical arrangement of files and
metadata (Data about data) on a disk is known as the
file system
How does the tree look?
Shown below is typically a part of the Unix/Linux file
system
/

root bin home dev etc usr

donkey monkey yankee bin sbin

america schedule

washington texas california


I am a
I am a file
directory

The above diagram is only a part of the file system. The tree can be
bigger and any number of nodes can exist under another.
Typical example of a
DOS/Windows file system.
The names of common directories have been left to
the reader to fill up.

C: D:
/ /
Directory Structure of
Linux File System
Direct
Content
ory
Common programs, shared by the system, the
/bin
system administrator and the users.
The startup files and the kernel, vmlinuz. In recent
distributions also grub data. Grub is the GRand
/boot
Unified Boot loader and is an attempt to get rid of
the manyreferences
Contains different boot-loaders weperipheral
to all the CPU know today.
/dev hardware, which are represented as files with
special properties.
Most important system configuration files are in
/etc /etc, this directory contains data similar to those in
the Control Panel in Windows
/home Home directories of the common users.
(on some distributions) Information for booting. Do
/initrd
not remove!
Library files, includes files for all kinds of programs
/lib
needed by the system and the users.
Directo
ry
Content

/lost+fou Every partition has a lost+found in its upper directory. Files
nd that were saved during failures are here.
/misc For miscellaneous purposes.
Standard mount point for external file systems, e.g. a CD-
/mnt
ROM or a digital camera.
/net Standard mount point for entire remote file systems
/opt Typically contains extra and third party software.
A virtual file system containing information about system
resources. More information about the meaning of the files in
/proc
proc is obtained by entering the command man proc in a
terminal window. user's home directory. Mind the
The administrative
/root difference between /, the root directory and /root, the home
directory
Programs of
forthe
useroot
by user.
the system and the system
/sbin
administrator.
/tmp Temporary space for use by the system.
Programs, libraries, documentation etc. for all user-related
/usr
programs.
Storage for all variable files and temporary files created by
users, such as log files, the mail queue, the print spooler
/var
area, space for temporary storage of files downloaded from
the Internet, or to keep an image of a CD before burning it.
Some important concepts
Data Communication
Data Communication is an important function of
the Operating System.
Communication always takes place between two
processes. This is because processes are the
only active entity inside a computer system.
The punch word in Data Communication is IPC
(Inter Process Communication). IPC is the
communication of data between two
processes.
Different Techniques of IPC are
 Message Passing – Data is sent from one
process to another via the kernel and other
subsystems.

Some technologies to
implement the IPC concepts
• Pipes – A virtual data flow is established
between two processes. The shared
memory concept is implemented using
pipes.
• Sockets – A logical connection point is
opened for a process. The kernel an
network subsystems take responsibility
to efficiently manage the sending and
receiving of data. The message passing
concept is implemented in this way.
• Memory Mapped Files – A portion of
the memory is mapped to a file.
Security and Protection
The system may be vulnerable to
attacks
More the functionalities in the
system more the loop holes and
more vulnerable to external or
internal attacks

Are they the same things?


No.
Security is protecting a system against
unauthorized attacks (Mostly external).
Protection is protecting the components
of the system from damage, blocking and
Who is going to attack?
There are various types of intruders
Naïve Users – These are kind of people
who have a long nose and have nothing to
do. They know less but keep on checking
out places for other people’s data (Mails
etc.).
Skilled Users – These are people like
inquisitive students who are more or less
skilled and try out ways to access things
they are not meant to just for fun or to
learn.
Purposeful Intruders – These people do
Some well known security
threats
• Viruses – These are malicious codes that believe in
infecting some data and spread. They generally
come from infected removable storage media
(floppies, CD’s) or recently they are also coming with
mails on the internet. The viral code is generally
executed by the user unknowingly. They reside as a
part of some important program, file or metadata
(Partition Table, Boot Sector etc.) and are activated
whenever the innocent infected data is read or
executed. When active it tries to search for other
such files or data where it can copy itself.
• Trojans – These are sent to a person by an intruder
on purpose. The program is sent with some innocent
looking program or file and the user runs it
unknowingly. The program when active acts as a
server. The intruder can connect to it from the
remote machine and command it to do malicious
jobs in the recipient's computer.
• Worms – These consist of two parts one is called the
loader and the other is the worm itself. The loader is
Continued
• Spoofing – This is a method to access a
system one is not meant to access. The
intruder takes form of a valid user or process
and enters the system.
• Phising – This is a hacking method very much
in use nowadays. The intruder creates a login
screen similar to some well known site or
system (Yahoo/ Google/ Unix or Linux login
screen) and puts in online. Some way the fake
login screen is run when the user needs to
login. The user delivers the username and
password without the knowledge of what is
actually happening and this data is stored to a
database accessible by the intruder.
Some ways to tackle intruders
Passwords –
Good passwords – Mixture of numbers, letters of
different case is a good security measure.
Passwords ideally should not carry any personal
information. These steps make it difficult to
guess passwords.
Periodically changing passwords – Some systems
allow us to specify passwords and specify some
period within which the password will have to be
changed.
Recursive Passwords – This is a technology in
which each time a password is used, it is re-
encrypted or changed automatically. The user is
given a list of passwords for a period of time. If
that list is secured, the user’s data is secured.
Continued
Encryption – However good a password is, it is of no
use without a good encryption algorithm protecting it.
Encryption is a technique of generating a new text by
applying some functions on the original text. The new
text is called Cipher text. Some encryption algorithms
allow the Cipher text to be Decrypted to the original
text and some don’t.
Encryption Key Decryption Key

Plaintext Encryption Ciphertext C Decryption Plaintext


P Algorithm Algorithm P

A B
Continued
Antiviruses – These are programs which
catch Viruses (Nowadays they detect all
malicious programs – Trojans, Worms etc.)
either when they are resident on the disk in
some form or when trying to enter the
system from some source.
Firewalls – Firewall blocks access of the
system by any means from some specified
external machines. So we create a firewall
against some machine if we distrust it.
However inspite of all these security
measures, 100% security can never be
ensured as any functionality in the
Protection
The components in a system can also be
vulnerable to internal malfunctioning. Just
consider the situation that normal users
are allowed to add new users. So any
body can be bribed or made to create a
new user which makes intrusion so easy.
Let’s take another situation. Just suppose
that a normal user can modify the
configuration file that contains
information for the network configuration.
As he does not have the knowledge of the
full network, his modifications may lead to
Ways to ensure protection
The most widely used technique for ensuring
protection is maintaining an access matrix. The
components of the system are called entities. A
matrix is maintained with the “entities to protect” on
one axis and “entities to protect from” on the other.
The cell corresponding to these two contain the
access rights (Who can access what).

file1 CD Writer

user1 Write Read


Read
execute
user2 read Read
Write
That ends our discussion on
Operating Systems
Books suggested –
Process Management , Memory Management, Storage
Management – Fundamentals of Operating Systems,
Silbershatz, Galvin

Security, Encryption – Modern Operating Systems, Tanenbaum

Happy Studying!!!!

Você também pode gostar