Download Pre-Course Study Material

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Information privacy law wikipedia , lookup

Computer file wikipedia , lookup

Business intelligence wikipedia , lookup

Asynchronous I/O wikipedia , lookup

Transcript
Pre-Course Study
Material
Operating Systems
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.
Surprised?
1.
2.
3.
What if there is no interface to the key board?
What if there is nothing that will control the output to VGA card?
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, Railway System are
analogous to Operating Systems.
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 communication equipments,
and terminals.
• System bus: Provides for communication between processors,
main memory, and I/O modules.
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)
ALU: Arithmetic Logic Unit – The unit that performs the computations. (MACHINES)
Registers
GROWING SPEED AND COST
Cache
Main Memory
Magnetic disk, CD-ROM, CD-RW
DVD-RW, DVD-RAM
Magnetic tape
GROWING SIZE AND DATA RETAINABILITY
Memory Hierarchy
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 development, testing and
introduction of new system functions without affecting the service.
Thus the basic functions of an OS are –
1.
2.
3.
4.
5.
6.
7.
8.
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.
Protecting the parts of the system against damage.
Booting the System and getting it ready to work.
Data communications – Providing interface to connect to
other computers or allowing others to connect
Operating System as an Interface
Application Programs
End user
Utilities
Programmer
Operating System
Computer Hardware
OS System
Designer
Operating System Services
• Program Development – variety of services and utilities such as
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 to provide a
common interface to the user/programmer.
Operating System Services
• Controlled 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.
• Accounting – collecting usage statistics, CPU usages, monitor
performance, etc.
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 required by all the upper levels.
Why Unix or Linux?
How the hell are they different from others?
Types of Operating Systems –
Access based –
1.
Single User – Only one user can access the OS at a time. E.g. DOS,
Windows 9x
2.
Multi User – Multiple users can access the OS at the same time. E.g.
Unix, Windows NT, Linux
Processing Based
1.
Single processing – Only one process (job) has control of the whole
system at a time. E.g. DOS
2.
Multi Processing – Multiple processes (jobs) control defined domain
of their own. E.g. Windows (All versions), Unix, Linux
Environment Based
1.
Stand alone – Does not support connection from other systems. E.g.
DOS, Windows 9x, Workstation versions of Windows NT
2.
Networking – Supports connection from other systems. E.g. Unix,
Linux, Server versions of Windows NT
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 slots. Small equal sized time slots
are defined and allocated to the processes.
Closer look to the above techniques
P1, P2, P3 are three different processes
Multiprogramming
P1
Run
P2
Wait
P3
P1, P2, P3
Wait
Run
Wait
Run
Wait
Run
Run
Run
Run
Wait
Run
Wait
Wait
Run
Wait
Run
Run
Any Advantage?
Run
Wait
Wait
So what is timesharing?
P1
P2
P3
Normal Time interval
I/O Started by P1
P1 Completed
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 execution, a current state, and an associated
set of system resources
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
data
context
Program code
data
context
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 memory blocks
• Context data: Data in the registers in the processor during
process execution.
• I/O status information: outstanding I/O requests, I/O devices
allocated to the process, a list of files is use by the process, etc.
• Accounting information: amount of processor time, etc.
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.
 Efficiency: Maximize throughput, minimize response time, and
accommodate as many concurrent users as possible.
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…
1. A facility that allows programs to address memory from a logical viewpoint
2. Disregards the amount of physical memory actually available
3. Meets the requirements of multiple user processes to reside
simultaneously in main memory without any interference
4. (Demand) Paging system and Page faults
5. Address of a word of a program = page number + offset within page
6. Pages vs. Blocks mapping
…
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 allocation of block to a page depends
upon the allocation policy used by the system.
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
File System – By File System we also mean the tree of directories and files
that is logically created in the memory.
How does the tree look?
Shown below is typically a part of the Unix/Linux file system
/
root
bin
donkey
home
monkey
dev
etc
yankee
usr
bin
sbin
america schedule
washington
I am a
directory
texas
california
I am a file
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
Directory
Content
/bin
Common programs, shared by the system, the system administrator and
the users.
/boot
The startup files and the kernel, vmlinuz. In recent distributions also grub
data. Grub is the GRand Unified Boot loader and is an attempt to get rid
of the many different boot-loaders we know today.
/dev
Contains references to all the CPU peripheral hardware, which are
represented as files with special properties.
/etc
Most important system configuration files are in /etc, this directory
contains data similar to those in the Control Panel in Windows
/home
Home directories of the common users.
/initrd
(on some distributions) Information for booting. Do not remove!
/lib
Library files, includes files for all kinds of programs needed by the system
and the users.
…
Directory
Content
/lost+found
Every partition has a lost+found in its upper directory. Files that were saved during
failures are here.
/misc
For miscellaneous purposes.
/mnt
Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.
/net
Standard mount point for entire remote file systems
/opt
Typically contains extra and third party software.
/proc
A virtual file system containing information about system resources. More information
about the meaning of the files in proc is obtained by entering the command man
proc in a terminal window.
/root
The administrative user's home directory. Mind the difference between /, the root
directory and /root, the home directory of the root user.
/sbin
Programs for use by the system and the system administrator.
/tmp
Temporary space for use by the system.
/usr
Programs, libraries, documentation etc. for all user-related programs.
/var
Storage for all variable files and temporary files created by users, such as log files,
the mail queue, the print spooler 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
1. Message Passing – Data is sent from one process to another
via the kernel and other subsystems.
2. Shared Memory – A location of the memory is shared between
two processes – one process writes data to the location and
another process reads the data.
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. Whatever is written to the file gets
written to the memory an vice versa. The shared
memory concept is implemented in this way.
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 unavailability of resource.
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 nasty jobs on
purpose – e.g. Hacking the Military Data of enemy nation,
Hacking confidential data of the rival company, etc.
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 rather innocent program which is sent to
somebody on the network. This loader later on loads the worm onto this
computer. Whenever the worm finds that the network is on it sends the
loader to the connected machines and thus it spreads.
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
Plaintext
P
A
Encryption
Algorithm
Decryption Key
Ciphertext C
Decryption
Algorithm
Plaintext
P
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
system adds to the loopholes.
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 a situation that the next day the
network doesn’t work. Securing the components of the
system against these kinds of problems is known as
Protection.
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
execute
Read
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!!!!