operating system

42
Pre-Course Pre-Course Study Material Study Material O O perating perating S S ystems ystems

Upload: nitinsrivastava

Post on 11-Apr-2016

6 views

Category:

Documents


2 download

DESCRIPTION

operating system

TRANSCRIPT

Page 1: operating system

Pre-Course Study Pre-Course Study MaterialMaterial

OOperating perating SSystemsystems

Page 2: operating system

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?

Page 3: operating system

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, Railway System are

analogous to Operating Systems.

Page 4: operating system

What does an Operating What does an Operating System do?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.

Page 5: operating system

• 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.

Structural Elements of a ComputerStructural Elements of a Computer

Page 6: operating system

Schematic Diagram of a Computer Schematic Diagram of a Computer SystemSystem

INPUT OUTPUT

MEMORY

CONTROL UNIT

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)

Page 7: operating system

Memory HierarchyMemory Hierarchy

Registers

Cache

Main Memory

Magnetic disk, CD-ROM, CD-RW

DVD-RW, DVD-RAM

Magnetic tape

GR

OW

ING

SP

EE

D A

ND

CO

ST G

RO

WIN

G S

IZE

AN

D D

ATA

RE

TAIN

AB

ILIT

Y

Page 8: operating system

Objectives of an OSObjectives 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.

Page 9: operating system

Thus the basic functions of an OS are –

1. Process Management – Managing the programs that are running.

2. Memory Management – Managing and rationing the memory between processes and data.

3. Storage Management – Managing the permanent Storage of data on disks or other media

4. I/O Management – Managing the input and output5. Device / Resource Management – Managing devices and

resources and allowing the users to share the resources6. Security and Protection – Securing the system against

possible unauthorized access to data or any other entity. Protecting the parts of the system against damage.

7. Booting the System and getting it ready to work.8. Data communications – Providing interface to connect to

other computers or allowing others to connect

Page 10: operating system

Operating System as an InterfaceOperating System as an Interface

Application Programs

Utilities

Operating System

Computer Hardware

End user

Programmer

OS System Designer

Page 11: operating system

Operating System ServicesOperating 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.

Page 12: operating system

Operating System ServicesOperating 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.

Page 13: operating system

What is the OS made of? What is the OS made of? The architecture shown below is applicable for The architecture shown below is applicable for

Unix and its family – Including LinuxUnix and its family – Including Linux

Hardware

Shell

Kernel and system software

Users

Other Applications

Page 14: operating system

What the hell are these…..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.

Page 15: operating system

Why Unix or Linux?Why Unix or Linux?How the hell are they different from others?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 9x2. Multi User – Multiple users can access the OS at the same time. E.g.

Unix, Windows NT, LinuxProcessing Based1. Single processing – Only one process (job) has control of the whole

system at a time. E.g. DOS2. Multi Processing – Multiple processes (jobs) control defined domain

of their own. E.g. Windows (All versions), Unix, LinuxEnvironment Based1. Stand alone – Does not support connection from other systems. E.g.

DOS, Windows 9x, Workstation versions of Windows NT2. Networking – Supports connection from other systems. E.g. Unix,

Linux, Server versions of Windows NT

Page 16: operating system

My God…My God…One OS! One Machine! One OS! One Machine!

Multiple jobs?Multiple jobs?

Techniques of Multiprocessing –• Multiprogramming• TimesharingNote 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.

Page 17: operating system

Closer look to the above techniquesCloser look to the above techniquesP1, P2, P3 are three different processesP1, P2, P3 are three different processes

Run Wait Run Wait

Run RunWait Wait

Run RunWait Wait

Wait

Wait

Run Run Run Run Run RunWait Wait

P1

P2

P3

P1, P2, P3

Any Advantage?

MultiprogrammingMultiprogramming

Page 18: operating system

So what is timesharing?So what is timesharing?

P1

P2

P3

Normal Time interval

I/O Started by P1

P1 Completed

Page 19: operating system

So which is better?So which is better?Multiprogramming or TimesharingMultiprogramming or Timesharing

• Multiprogramming maximizes CPU utilization

• Time-sharing minimizes user response rime

What about the Throughput?

Page 20: operating system

ProcessesProcesses

A process is

• Normal: A program in state of execution program in state of execution

• Waste of words: Waste of words: An instance of a program running on a computerAn instance of a program running on a computer

• Fundoo…: Fundoo…: The entity that can be assigned to and executed on a The entity that can be assigned to and executed on a

processorprocessor

• More fundoo?... More fundoo?... A unit of activity characterized by a single A unit of activity characterized by a single

sequential thread of execution, a current state, and an associated sequential thread of execution, a current state, and an associated

set of system resourcesset of system resources

Page 21: operating system

Parts of a ProcessParts 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.

Main memory

context

data

Program code

context

Program code

data

Process list

Page 22: operating system

Process Control Block Process Control Block A data structure by which the system identifies a process.A data structure by which the system identifies a process.It contains -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 devicesallocated to the process, a list of files is use by the process, etc.• Accounting information: amount of processor time, etc.

Page 23: operating system

Other fundas…Other fundas…Resource ManagementResource Management

Responsibilities of the OS in Resource ManagementResponsibilities 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.

Page 24: operating system

Memory ManagementMemory 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 available3. Meets the requirements of multiple user processes to reside

simultaneously in main memory without any interference4. (Demand) Paging system and Page faults5. Address of a word of a program = page number + offset within page6. Pages vs. Blocks mapping

Page 25: operating system

……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.

Page 26: operating system

Then how does it manage the disk?Then how does it manage the disk?Storage Management…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 systemFile System – By File System we also mean the tree of directories and files that is logically created in the memory.

Page 27: operating system

How does the tree look?How does the tree look?Shown below is typically a part of the Unix/Linux file systemShown below is typically a part of the Unix/Linux file system

home

/

dev etc usrbin

donkey monkey yankee bin sbin

america schedule

washington texas california

root

I am a directory 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.

Page 28: operating system

/ /C: D:

Typical example of a Typical example of a DOS/Windows file system.DOS/Windows file system.

The names of common directories have been left to the reader to fill up.The names of common directories have been left to the reader to fill up.

Page 29: operating system

Directory Content

/bin Common programs, shared by the system, the system administrator and the users.

/bootThe 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 Structure of Linux File Directory Structure of Linux File SystemSystem

Page 30: operating system

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.

/procA 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.

/varStorage 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.

……

Page 31: operating system

Some important conceptsSome important conceptsData CommunicationData 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.

Page 32: operating system

Some technologies to Some technologies to implement the IPC conceptsimplement 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.

Page 33: operating system

Security and ProtectionSecurity and ProtectionThe system may be vulnerable to attacksThe 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.

Page 34: operating system

Who is going to attack?Who is going to attack?

There are various types of intrudersNaï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.

Page 35: operating system

Some well known security threatsSome well known security threatsViruses – 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.

Page 36: operating system

ContinuedContinued

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.

Page 37: operating system

Some ways to tackle intrudersSome 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.

Page 38: operating system

ContinuedContinuedEncryption – 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.

EncryptionAlgorithm

Decryption Algorithm

PlaintextP

PlaintextP

Ciphertext C

A B

Encryption Key Decryption Key

Page 39: operating system

ContinuedContinued

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.

Page 40: operating system

ProtectionProtection

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.

Page 41: operating system

Ways to ensure protectionWays to ensure protectionThe 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 WriteReadexecute

Read

user2 read ReadWrite

Page 42: operating system

That ends our discussion on Operating That ends our discussion on Operating SystemsSystems

Books suggested –Process Management , Memory Management, Storage Management – Fundamentals of

Operating Systems, Silbershatz, Galvin

Security, Encryption – Modern Operating Systems, Tanenbaum

Happy Studying!!!!