assignment on operating systems

20
ASSIGNMENT ON OPERATING SYSTEMS By: Karthik Mohan II nd  YEAR, CSE ‘B’

Upload: shaunik-taneja

Post on 25-Feb-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 1/20

ASSIGNMENT ON

OPERATING

SYSTEMS

By:

Karthik Mohan

IInd YEAR, CSE ‘B’

Page 2: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 2/20

CONTENTS

1 Co!"#t$r Sy%t$! O&$r&i$'

( Ba%i) E*$!$nt%

+ In%tr#)tion E$)#tion

- Int$rr#"t

. M$!ory /i$rar)hy

0 IO

Page 3: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 3/20

COMPUTER SYSTEM

OVERVIEW 

 An operating system (OS) is system software that manages computer 

hardware and software resources and provides common

services for computer programs. The operating system is a component

of the system software in a computer system. Application

programs usually require an operating system to function.

Time-sharing operating systems schedule tasks for efficient use of the

system and may also include accounting software for cost allocation of 

processor time, mass storage, printing, and other resources.

For hardware functions such as input and output and memory allocation,

the operating system acts as an intermediary etween programs and thecomputer hardware, although the application code is usually e!ecuted

directly y the hardware and frequently makes system calls to an "#

function or is interrupted y it. "perating systems are found on many

devices that contain a computer$from cellular phones and video game

consoles to we servers and supercomputers.

%!amples of modern operating systems include Apple "# &, 'inu! andits variants, and icrosoft indows.

Page 4: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 4/20

TYPES OF OPERATRING SYSTEMS

#ingle- and multi-tasking

 A single-tasking system can only run one program at a time, while

a multi-tasking operating system allows more than one program to e

running in concurrency. This is achieved y time-sharing, dividing theavailale processor time etween multiple processes which are each

interrupted repeatedly in time-slices y a task scheduling susystem of 

the operating system. ulti-tasking may e characteri*ed in pre-emptive

and co-operative types. +n pre-emptive multitasking, the operating

system slices the time and dedicates a slot to each of the

programs. /+&-like operating systems, e.g., #olaris, 'inu!, as well

as Amiga"# support pre-emptive multitasking. ooperative multitasking

is achieved y relying on each process to provide time to the other 

processes in a defined manner. 01-it versions of icrosoft indowsused cooperative multi-tasking. 23-it versions of oth indows /T and

in4!, used pre-emptive multi-tasking.

#ingle- and multi-user 

#ingle-user operating systems have no facilities to distinguish users, ut

may allow multiple programs to run in tandem. A multi-user operatingsystem e!tends the asic concept of multi-tasking with facilities that

Page 5: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 5/20

identify processes and resources, such as disk space, elonging to

multiple users, and the system permits multiple users to interact with the

system at the same time. Time-sharing operating systems schedule

tasks for efficient use of the system and may also include accounting

software for cost allocation of processor time, mass storage, printing,and other resources to multiple users.

5istriuted

 A distriuted operating system manages a group of distinct computers

and makes them appear to e a single computer. The development of 

networked computers that could e linked and communicate with eachother gave rise to distriuted computing. 5istriuted computations are

carried out on more than one machine. hen computers in a group work

in cooperation, they form a distriuted system.

Templated

+n an "#, distriuted and cloud computing conte!t, templating refers tocreating a single virtual machine image as a guest operating system,

then saving it as a tool for multiple running virtual machines. The

technique is used oth in virtuali*ation and cloud computing

management, and is common in large server warehouses.

%medded

%medded operating systems are designed to e used in emedded

computer systems. They are designed to operate on small machines like5As with less autonomy. They are ale to operate with a limited

numer of resources. They are very compact and e!tremely efficient y

design. indows % and ini! 2 are some e!amples of emedded

operating systems.

Page 6: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 6/20

6eal-time

 A real-time operating system is an operating system that guarantees toprocess events or data within a certain short amount of time. A real-time

operating system may e single- or multi-tasking, ut when multitasking,

it uses speciali*ed scheduling algorithms so that a deterministic nature

of ehaviour is achieved. An event-driven system switches etween

tasks ased on their priorities or e!ternal events while time-sharing

operating systems switch tasks ased on clock interrupts.

'irary

 A lirary operating system is one in which the services that a typical

operating system provides, such as networking, are provided in the form

of liraries. These liraries are composed with the application and

configuration code to construct unikernels $ which are

specialised, single address space, machine images that can e

deployed to cloud or emedded environments.

HISTORY 

%arly computers were uilt to perform a series of single tasks, like a

calculator. 7asic operating system features were developed in the

0489s, such as resident monitor functions that could automatically run

different programs in succession to speed up processing. "perating

systems did not e!ist in their modern and more comple! forms until the

early 0419s. :ardware features were added, that enaled use of runtime

liraries, interrupts, and parallel processing. hen personal

computers ecame popular in the 04;9s, operating systems were made

for them similar in concept to those used on larger computers.

Page 7: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 7/20

+n the 04<9s, the earliest electronic digital systems had no operating

systems. %lectronic systems of this time were programmed on rows of 

mechanical switches or y =umper wires on plug oards. These were

special-purpose systems that, for e!ample, generated allistics tales for 

the military or controlled the printing of payroll checks from data onpunched paper cards. After programmale general purpose computers

were invented, machine languages (consisting of strings of the inary

digits 9 and 0 on punched paper tape) were introduced that sped up the

programming process (#tern, 04;0).

+n the early 0489s, a computer could e!ecute only one program at a

time. %ach user had sole use of the computer for a limited period of time

and would arrive at a scheduled time with program and data on punchedpaper cards or punched tape. The program would e loaded into the

machine, and the machine would e set to work until the program

completed or crashed. rograms could generally e deugged via a

front panel using toggle switches and panel lights. +t is said that Alan

Turing was a master of this on the early anchester ark 0 machine,

and he was already deriving the primitive conception of an operating

system from the principles of the niversal Turing machine.

BASIC ELEMENTS

+magine, if you can, that an operating system is roken down into five

layers. +n the following list +>ll start at the ottom most layer and work my

way up to the very top.

'ayer 0? The @ernel.

The kernel is the heart of the operating system. Amongst its

responsiilities are ensuring that each running process is given a fair 

amount of time to e!ecute while a controlling the amount of resources

each process can use.

Page 8: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 8/20

'ayer 3? emory anagement.

The name of this layer gives you a good idea what it is all aout. +t is theresponsiility of this layer to share your computers physical memory

among the processes which want to use it. +t also has to manage such

situations where there may not e enough physical memory to share

out.

'ayer 2? +nput"utput.

"n this layer all the physical communication etween your computers

hardware, such as disk drives, keyoards, mice, screens and so on,

takes place.

'ayer <? File anagement.

 Again the name of this layer may give you a clue as to what it does. +t is

the =o of this layer to control how the files on your computers hard driveare stored and accessed y any application seeking to use them.

'ayer 8? The ser +nterface.

The last element, or layer as we have een calling them, of an operating

system is the ser +nterface. This layer is proaly the easiest of all to

understand since it is the first thing you see when your operating systemhas logged you in. +t is the =o of this layer to provide a means for the

user to actually interact with the rest of the layers and as such the

system as a whole.

@eep in mind there are two different types of ser interfaces. The first

one is proaly the one you are most familiar with, the graphical user 

interface, which is where you see windows and icons for each of your 

files and so on.

Page 9: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 9/20

The second is a command line interface, or te!t ased interface where a

user would interact with the system using te!t ased commands.

Page 10: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 10/20

INSTRUCTION

EXECUTION

Step Description

1 Fetch Instruction from Memory

2 Decode Instruction and Fetch Operands

3 Perform ALU Operations

4 Memory Access for !oad"store#

$ Store ALU resu!t to re%ister fi!e

& Update P'

+/ 5%TA+'?

The main purpose of a is to e!ecute instructions. e>ve alreadyseen some simple e!amples of instructions, i.e., add and addi.

The e!ecutes the inary representation of the instructions, i.e.,machine code.

#ince programs can e very large, and since s have limitedmemory, programs are stored in memory (6A). :owever, s do itsprocessing on the . #o, the must copy the instruction frommemory to the , and once it>s in the , it can e!ecute it.

The is used to determine which instruction is e!ecuted, and asedon this e!ecution, the is updated accordingly to the ne!t instruction toe run.

%ssentially, a repeatedly fetches instructions and e!ecutes them.

The following is a summary of the si! steps used to e!ecute a singleinstruction.

Page 11: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 11/20

• Step 1: Fetch instruction

For some reason, the ver BfetchB is always used with instruction.e don>t Bget an instructionB or Bretrieve an instructionB. e Bfetchan instructionB.

To fetch an instruction involves the following steps?

• must place an address to the A6.

• must activate the tri-state uffer so A6 contents are

placed on the address us.

• sends R/\W = 1 and CE = 1 to memory, to indicate it

wants to do a read.

• emory eventually puts instruction on the data us.

• emory sends ACK = 1.

• loads the instruction to the 56.

• transfers instruction from 56 to +6.

• sets CE =  to memory indicate it>s done with fetching

the instruction.

 As you can see, the steps are rather involved. Cou can speed upthis step if you assume instructions are in a fast instruction cache.For now, we won>t assume that.

Cou should go ack to the notes on memory if you have forgottenhow it works, in particular, if you have forgotten the control signalsused y memory.

• Step !: "ecode instruction and Fetch Operands

+n the second step, the its used for the opcode (and function, for 6-type instructions) are used to determine how the instructionshould e e!ecuted. This is what is meant y BdecodingB the

instruction.

Page 12: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 12/20

6ecall that operands are arguments to the assemly instruction.

:owever, since 6-type and +-type instructions oth use registers,and those registers are in specific locations of the instruction, we

can egin to fetch the values within the registers at the same timewe are decoding.

+n particular, we>re going to do the following?

• Det #R$1%!&, the opcode

• Det #R!'%!1, which is (rs, the first source register.

• Det #R!%1&, which is (rt, the second source register.

• Det #R1'%11, which is (rd, the destination register.

• Det #R1'%, the immediate value

• Det #R'%, the function code

Cou>ll notice that we>re e!tracting these its directly from theinstruction register.

Cou>ll also notice that we e!tracted #R1'%11 and #R1'%. :ow can wedo othE ell, they>re merely wires, so there>s no reason you can>tget oth quantitie out.

The key is to reali*e that sometimes we use #R1'%11 and sometimeswe use #R1'%. e need to have oth of them ready ecause this ishardware. +t>s easier to have everything we need, and then figureout what we need, than to decide what we need and try to get it.

+n particular, when we fetch the operands (i.e., the registers) wewant to send the source and destination registers its to a devicecalled the register )i*e.

For e!ample, if #R!'%!1 has value 99000, this means we wantregister (r+ from the register file. e sent in 99000 to this circuit,and it returns the contents ack to us.

e>ll e discussing the register file soon.

Page 13: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 13/20

+f we are e!ecuting an +-type instruction, then typically, we>ll sign-e!tend (or *ero-e!tend, depending on the instruction) theimmediate part (i.e., #R1'%) to 23 its.

Step $: ,er)orm A-. operation

The A' has two 23-it data inputs. +t has a 23-it output. Thepurpose of the A' is to perform a computation on the two 23-itdata inputs, such as adding the two values. There are somecontrol its on the A'. These control its specify what the A'should do.

For e!ample, they may specify an addition, or a sutraction, or aitwise A/5.

here do the input values of the A' come fromE

6ecall that an instruction stores information aout its operands. +nparticular, it encodes registers as 8-it 7 numers. These register encodings are sent to the register file as inputs.

The register file then outputs the 23-it values of these registers.These are the sent as inputs to the A'.

• Step : Access memory

There are only two kind of instructions that accessmemory? *oad and store.

-oad  copies a value from memory to a register. Store copies aregister value to memory.

 Any other instruction skips this step.

• Step ': Write 0ac resu*t to register )i*e

 At this point, the output of the A' is written ack to the register file. For e!ample, if the instruction was? add (r!2 (r$2 (r thenthe result  of adding the contents of (r$ to the contents of (rwoulde stored ack into (r!.

The result could also e due to a *oad from memory.

Page 14: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 14/20

#ome instructions don>t have results to store. For e!ample, ranchand =ump instructions do not have any results to store.

• Step &: .pdate the ,C

Finally, we need to update the program counter. Typically, weperform the following update?

,C 3% ,C 4

6ecall that ,C holds the current address of the instruction to ee!ecuted. To update it means to set the value of this register to thene!t instruction to e e!ecuted.

nless the instruction is a ranch or =ump, the ne!t instruction toe!ecute is the ne!t instruction in memory. #ince each instructiontakes up < ytes of memory, then the ne!t address in memory is,C 4 , which is the address of the current instruction plus <.

The ,C might change to some other address if there is a ranch or  =ump.

These are the si! steps to e!ecuting an instruction. /ot every instruction

goes through every step. :owever, we lael each step so that you cane aware they e!ist.

#ome of these steps may not make much sense now, ut hopefully,they>re e clearer once we start implementing the steps in depth.

Page 15: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 15/20

INTERRUPT 

+n system programming, an interrupt is a signal to

the processor  emitted y hardware or software indicating an event that

needs immediate attention. An interrupt alerts the processor to a high-

priority condition requiring the interruption of the current code the

processor is e!ecuting. The processor responds y suspending its

current activities, saving its state, and e!ecuting a function called

an interrupt handler  (or an interrupt service routine, +#6) to deal with the

event. This interruption is temporary, and, after the interrupt handler 

finishes, the processor resumes normal activities. There are two types of 

interrupts? hardware interrupts and software interrupts.

5ard6are interrupts are used y devices to communicate that they

require attention from the operating system. +nternally, hardware

interrupts are implemented using electronic alerting signals that are sent

to the processor from an e!ternal device, which is either a part of the

computer itself, such as a disk controller , or an e!ternal peripheral. For 

e!ample, pressing a key on the keyoard or moving the mouse triggers

hardware interrupts that cause the processor to read the keystroke or 

Page 16: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 16/20

mouse position. nlike the software type (descried elow), hardware

interrupts are asynchronous and can occur in the middle of instruction

e!ecution, requiring additional care in programming. The act of initiating

a hardware interrupt is referred to as an interrupt request (+6).

 A so)t6are interrupt is caused either y an e!ceptional condition in the

processor itself, or a special instruction in the instruction set which

causes an interrupt when it is e!ecuted. The former is often called

a trap or exception and is used for errors or events occurring during

program e!ecution that are e!ceptional enough that they cannot e

handled within the program itself. For e!ample, if the

processor>s arithmetic logic unit  is commanded to divide a numer y*ero, this impossile demand will cause a divide-by-zero exception,

perhaps causing the computer to aandon the calculation or display an

error message. #oftware interrupt instructions function similarly

to suroutine calls and are used for a variety of purposes, such as to

request services from low-level system software such as device drivers.

For e!ample, computers often use software interrupt instructions to

communicate with the disk controller  to request data e read or written to

the disk.

%ach interrupt has its own interrupt handler. The numer of hardware

interrupts is limited y the numer of interrupt request (+6) lines to the

processor, ut there may e hundreds of different software interrupts.

+nterrupts are a commonly used technique for computer multitasking,

especially in real-time computing. #uch a system is said to e interrupt-

driven. 

Page 17: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 17/20

MEMORY HIERARCHY 

emory management refers to management of rimary emory or 

ain emory. ain memory is a large array of words or ytes where

each word or yte has its own address.

ain memory provides a fast storage that can e access directly y the

. #o for a program to e e!ecuted, it must in the main memory.

"perating #ystem does the following activities for memory

management.

Page 18: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 18/20

• @eeps tracks of primary memory i.e. what part of it are in use y

whom, what part are not in use.

• +n multiprogramming, "# decides which process will get memory

when and how much.

•  Allocates the memory when the process requests it to do so.

• 5e-allocates the memory when the process no longer needs it or 

has een terminated.

The term memory hierarchy is used in computer architecture when

discussing performance issues in computer architectural design,algorithm predictions, and the lower level programming constructs such

as involving locality of reference. A Bmemory hierarchyB in computer 

storage distinguishes each level in the BhierarchyB y response time.

#ince response time, comple!ity, and capacity are related, G0H the levels

may also e distinguished y the controlling technology.

The many trade-offs in designing for high performance will include the

structure of the memory hierarchy, i.e. the si*e and technology of each

component. #o the various components can e viewed as forming a

hierarchy of memories (m0,m3,...,mn) in which each memer mi is in a

sense suordinate to the ne!t highest memer miI0 of the hierarchy. To

limit waiting y higher levels, a lower level will respond y filling a uffer 

and then signalling to activate the transfer.

There are four ma=or storage levels.

0. Internal  J rocessor registers and cache.

3. ain J the system 6A and controller cards.

2. "n-line mass storage J #econdary storage.

<. "ff-line ulk storage J Tertiary and "ff-line storage.

This is a general memory hierarchy structuring. any other structures

are useful. For e!ample, a paging algorithm may e considered as a

level for virtual memory when designing a computer architecture, and

one can include a level of near line etween online and offline storage.

Page 19: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 19/20

I/O

+n computing, input/output or #/O (or, informally, io or #O) is the

communication etween an information processing system, such as

a computer , and the outside world, possily a human or another information processing system. +nputs are the signals or data received

Page 20: Assignment on Operating Systems

7/25/2019 Assignment on Operating Systems

http://slidepdf.com/reader/full/assignment-on-operating-systems 20/20

y the system and outputs are the signals or data sent from it. The term

can also e used as part of an actionK to Bperform +"B is to perform

an input or output operation. +" devices are used y a human (or other 

system) to communicate with a computer. For instance,

a keyoard or mouse is an input device for a computer,while monitors and printers are output devices. 5evices for  

communication etween computers, such as modems and network

cards, typically perform oth input and output operations.

/ote that the designation of a device as either input or output depends

on perspective. ice and keyoards take physical movements that the

human user outputs and convert them into input signals that a computer can understandK the output from these devices is the computer>s input.

#imilarly, printers and monitors take signals that a computer outputs as

input, and they convert these signals into a representation that human

users can understand. From the human user>s perspective, the process

of reading or seeing these representations is receiving inputK this type of 

interaction etween computers and humans is studied in the field

of humanJcomputer interaction.

+n computer architecture, the comination of the  and main memory,

to which the can read or write directly using individual instructions,

is considered the rain of a computer. Any transfer of information to or 

from the memory como, for e!ample y reading data from a disk

drive, is considered +". The and its supporting circuitry may

provide memory-mapped +" that is used in low-level computer 

programming, such as in the implementation of device drivers, or may

provide access to +" channels. An +" algorithm is one designed toe!ploit locality and perform efficiently when e!changing data with a

secondary storage device, such as a disk drive.