osunit12_(1)

Embed Size (px)

Citation preview

  • 8/8/2019 osunit12_(1)

    1/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    Unit-1Evolution of the operating system, resident monitor, batch processing,

    multiprogramming, multiprocessing, time sharing, real time system, I/O interrupt,

    DMA, dual mode operation, operating system services.

    EVOLUTION OF THE OPERATING SYSTEM

    An operating system is an integrated set of program that is used to manage the varesources and overall operations of a computer system. Operating system goes by different names depending on the manufacture of the computer. Other terms used to deoperating systems are, monitor, executive supervisor controller programs. An opersystem manage and co-ordinates the function performed by the computer hardincluding the CPU, input device, secondary storage devices, communication and neequipment.When a number of computers connected through a network and more than one comtrying for a common printer or a common resources then the operating system followorder and manage the resources in an efficient manner. Generallyresource sharing in two ways in time and in space. When aresource is a time sharing resource first one of the tasks getsresource for some time, then another and so on. For example aCPU is an in time sharing system. In time sharing system, theoperating system fixes the time slot of the CPU. First one of the processes gets the CPU when the time slot expired the CPUswitches to next process in the ready queue. The other kind of sharing is the space sharing. In this method the user sharing thespace of the resources. For example the main memory consisting of several processetime. So the main difference between in time sharing resource and in space shresources is that in time resource is not divided in to units where as in space resoudivided in to units. The structure of operating system consist four layers such as hardsoftware, system programs and application program. The hardware part consists of Cmain memory, input /output devices, secondary storage etc. The software includes prmanagement routines, memory management routines, input/output control routinemanagement routine. The system programs layer consists of compiler, assembler, linkThe application programs are depending on the user.EVALUTION OF THE OPERTING SYSTEM: The first operating system was developed in the year 1950 for the IBM 701 computeroperating system was elementary in nature and was not as powerful as the operating sof todays computer. Since then lot of research has been carried out in this direction wiresult that today we are very powerful operating system and can execute several jobtime on the same machine.

    1

  • 8/8/2019 osunit12_(1)

    2/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    In the early days of computers job to job transaction was not automatic. For each jexecuted by the computer the operator had to clear the main memory to remove anyremaining from the previous job, load the program and data of the current job from thedevice, sets the appropriate switches and finally run the job to obtain the result from th put device, after the completion of one job by the same process had to repeated for th job by the computer operator because of this manual transaction for one job to anotheof computer time was wasted. Since the computer remain idle while the operator loadon loaded jobs .In order to reduce the idle time, a method of automatic job to job transwas devised with this facility when one job is finished, the system control is automattransferred back to the operating system which automatically performs the house ke jobs needed to load and run the next job.FUNCTION OF OPERATING SYSTEM:

    1. Processor management that is assignment of processor to different task being2. Performed by the computer system.3. Memory management that is allocation of main memory and other storage area o4. The system programmers as well as the user programs and data.5. Input /output management that is allocation of the different input and output6. Device while one or more programs are being executed.7. Interpretation of command and instruction. Facilities easy communication8. Between the Computer system and the computer operator.9. Transfer input from the key board (any one of the input devices) to the memory.10.Display the messages, be it input or output on the screen.11.Store datas or programs in external storage device.12.Output data to the printer (any one of the output devices) from the memory.13.Control the printer and other peripherals.

    14.Load programs and packages from storage devices and media to the main memo15.Copy data or programs from one device to another.16.Communicate, control, and provide error message given the status of peripherals

    processes.17.Execute the user programs and commands.18.Protect working storage from overwriting by another program.19.Store details of data and location stored for all media and drives.20.Security and protection to the user data program and files.

    MEASURING SYSTEM PERFORMANCEThe efficiency of an operating system and the overall performance of a computer systeusually measured in terms of the following:Throughput: Throughput is the amount of work that the system is able to do per unit timis measured as the number of processes that are completed by the system per unit time.For example: if n processes are completed in en interval of t second, the throughput isas n/t processes per second during that interval. Throughput is normally measureprocesses/ hour . The performance of the CPU is measured in terms of throughput (Methe performance of the CPU).Turnaround time: Turn around time is the interval from the time of submission of a jothe system for processing to the time of completion of the job.

    2

  • 8/8/2019 osunit12_(1)

    3/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    Turn around time = Submission of the job- completion of a job.Response time : Another measure used in case of interactive system is response time, wis the interval from the time of submission of a job to the system for the processing time the first response for the job is produced by the system.RESIDENT MONITOR

    A small program, called a resident monitor, is created to transfer control automaticallyone job to another. The resident monitor is always in memory or resident. Whecomputer was turned on, the resident monitor was invoked and it would transfer contr program .When the programs terminated it would return control to the resident mowhich would then go to the next program. Thus the resident monitor would automatsequence from one program to another andfrom one job to another. How the residentmonitor would knows which program toexecute? In addition to the program or datafor a job, the programmer included the controlcard, which contained directives to residentmonitor indicating the program to run.Control cards provide the information directlyto the monitor. Example: A normal user program may require one of the three programs to run:

    1) The FORTRAN complier(FTN)2) The ASSEMBLER (ASM)3) Users Program(RUN)

    We could use a separate control cards for each of three:$FTN: - Execute the FROTRANcomplier.$ASM: - Execute the assembler.$RUN: - Execute the user program.These cards tell the resident monitor which program to run. We can use twoadditional control cards to define the boundaries of each job:$JOB: - First card of the job.$END: - Final card of the job.These two cards might be useful in account for the machine resource used by programmer. Parameter can be used to define the job name, account number to be chand so on. Other control cards can be defined for other function, such as asking the opto load or unload a tape. One problem with control is how to distinguish them from d program cards. The solution is to identify them by a special character pattern on theSeveral system used the dollar sign character ($) in the first column to identify a cocard. Others used a different card. A resident monitor has several identifiable parts:

    3

  • 8/8/2019 osunit12_(1)

    4/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    1) The control card interpreter is responsible for reading and carrying out the instructithe cards at the point of execution.2) The Loader is invoked by the control card interpreter, to load system programapplication program into memory at intervals.3) The Device Driver is used by both the control card interpreter and the loader fosystems I/O devices to perform I/O. The system and application programs are linked tosame device drivers, providing continuity in their operation, as well as saving memoryand programming time. In batch system, the resident monitor provides automaticsequence as indicated by the control cards. When a control card indicates that a program be run, the monitor loads the program into memory and transfer control to it. Whe program completes, it transfer control back to the monitor, who reads the next controload the appropriate program and so on. Thus cycle is repeated until all control carinterpreted for the job. Then the monitor automatically continues with the next job.BATCH PROCESSING

    In older day (before 1960) it is difficult to execute a program using computer becaucomputer located in three different rooms. One rooms for card reader one roomexecuting the program and another rooms for printing the result. The user or maoperator runs in between these rooms to complete a job. We can solve this problem batch processing. Batch processing is one of the oldest methods of running program oand submits it to the computer center. A computer operation collects the program which been punched on cards and stacks one program or job on top of another when a ba programs have been collected to operator loads this batch of programs in to the compone time where they are executed one after another. Batch processing is also known asor sequential or stacks job processing. When a computer is used in this way, the inpuare introduced in to the computer and processed automatically without operaintervention. Many different jobs (or set of data) are processed one after another osame time but without any interaction from the users during program execution .The mof batch processing reduces the ideal time of a computer system because transition fro job to another does not required operator intervention.MULTIPROGRAMMING

    Basically there are two types of programs such asI/O bound programs and CPU boundprograms . Programs used for commercial data processing normally read in vast amoudata perform very little computation and output large amount of information such prare known as I/O bound programs on the other hand programs used for scientifiengineering application need very little I/O but requires enormous computation programs are called CPU bound programs because more of CPU time is require processing such programs. In order to overcome the problem of under utilization ofmemory and the CPU concept multiprogramming introduced in operating system. Whe program is waiting for I/O transfer, there is another program ready to utilize the CPU. Tis possible for several users to share the time of CPU.Multiprogramming is a technique to execute number of program simultaneously by a processor. In multiprogramming number of processes and reside main memory at a timoperating system picks and begins to execute one of the jobs in the main memory. In

    4

  • 8/8/2019 osunit12_(1)

    5/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    multiprogramming system the CPU can execute only one program at a time if the ru program is waiting for an I/O device the CPU becomes idea it will effect on the perforof CPU. But in multiprogramming environment any I/O wait happened in a process thCPU switches from that hob to another job in job pool, so the CPU is not idle at anyThe doctor doesnt have only one patient at a time. Number of patients resides in the hounder treatment. If the doctor has enough patients a doctor never to be idle.

    It is important to note here that multiprogramming is not defined to be the executiinstruction from several programs simultaneously. Rather, it does means that there number of programs available to the CPU (stored in the main memory) and that a portone is executed, then a segment of another and so on. Although two or more user proreside in the main memory simultaneously, the CPU is capable of executing onlyinstruction at a time. Hence, at any given time, only one of the programs has control CPU and is executing instruction. Simultaneous execution of more than one program single CPU is impossible. In some multiprogramming system, only fixed number of jo be processed concurrently (Multiprogramming with fixed task)(MFT), while in others the

    number of jobs can vary (multiprogramming with variable task)(MVT).

    A typical scenario of jobs in a multiprogramming system is shown in the figure. A particular time instances shown in the figure, Job A is not utilizing the CPU since the Cis busy writing output data on the disk (I/O operation). Hence the CPU is being utiliexecute job B, which is also present in the main memory. Job C, also residing in thememory, is waiting for the CPU to become free. Actually, as shown in the figure, in cmultiprogramming all the jobs residing in the main memory will be in one of the follthree states that is running (it is using the CPU), blocked (it is performing I/O operation

    5

  • 8/8/2019 osunit12_(1)

    6/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    ready (it is waiting for CPU to be assigned to it). In our example, Jobs A, B and C blocked, running and ready states respectively. Since job C is in the ready state, as sothe execution of job B is completed or job B requires doing I/O operation, the CPU wiexecuting job C. In the mean while, if job A completes its output operation, it will beready state waiting for the CPU. Hence, in multiprogramming, the CPU will never be ilong as there is always some job to execute. Note that although many jobs may be in and blocked states, only one job can be running at any instances. The area occupied by job residing simultaneously in the main memory is known asmemory partition. The actualnumber of partition and hence jobs, allowed in the main memory at any given time vdepending upon the operating system in use. Moreover, those jobs awaiting entry intomemory are queued on a fast secondary storage device such as magnetic disk. The firfrom this queue will be loaded into the main memory as soon as only one of the jobs aoccupied the main memory is completed and the corresponding memory partition becfreeRequirements of multiprogramming system

    Multiprogramming has two main advantages: increased throughput (performanthe CPU) and lowered response time. Throughput is increased by utilizing the ideal tithe CPU for running other programs that are already residing in the main memory. Restime is lowered by recognizing the priority of a job as it enters the system and by proce jobs on a priority basis.

    On the other hand, the incorporation of multiprogramming in the operating syhas, of course, complicated matter. For a computer to work simultaneously on m programs, the flowing additional hardware and software features are required:

    Large memory: For multiprogramming to work satisfactory, large main memory is requto accommodate a good number of user programs along with the operating system.Memory Protection: Computer designed for multiprogramming must provide some typmemory protection mechanism to prevent a job in one memory partition from chainformation or instruction of a job in another memory partition. For example: In figurwould not want job A to inadvertently destroy something in the completely independeB or Job C. In a multiprogramming system, this is achieved by the memory protefeatures, a combination of hardware and software, which prevents one job from addr beyond the limits of its own allocated memory area.Job status preservation: In a multiprogramming, when a running job is blocked for I processing, the CPU is taken away from this job and given to another job that is readexecution. Later, the former job will be allocated the CPU to continue its execution. Nthat this requires preserving of the jobs complete status information when the CPU isaway from it and restoring this information back, before the CPU is given back to it To enables this, the operating system maintains aProcess control block (PCB) for eachloaded process. With this arrangement, before taking away the CPU from the run process, its status is preserved in its PCB, and before the process resumes executionthe CPU is given back to it later, its status is restored back from its PCB. Hence, the pcan continue execution without any problem.

    6

  • 8/8/2019 osunit12_(1)

    7/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    Proper job mix: A proper mix of I/O bound and CPU bound jobs required to effectivoverlap the operations of the CPU and I/O devices. It is necessary that when a progrwaiting for I/O operation, another program must have enough computation to keep the busy. If all programs need I/O at the same time, the CPU will again be idle. Hence, thememory should contains some CPU bound programs and some I/O bound programsvarious partition so that at least one of the program which does not need I/O is alavailable to the CPU for processing.CPU scheduling: In a multiprogramming system, often there will be situation in which or more jobs will be in the ready state, waiting for CPU to be allocated for execution. more then one process is in the ready state when the CPU becomes free, the operating smust decide which of the ready jobs should be allocated the CPU for execution. The pthe operating system concerned with this decision is called the CPU scheduler, analgorithm is uses are called the CPU scheduling algorithm.MULTIPROCESSING

    Multiprocessing is a technique to execute two or more program simultaneously by a Computer system havingmore than one CPU. The term multiprocessing is used todescribe interconnected computer configuration or computers with two or more independent CPU that havethe ability to simultaneously execute several programs.In such a system, instruction from different andindependent programs can be processed at the instant of time by different CPU or the CPU may simultaneously execute different instruction frosame program. There are almost limit less number of possible multiprocessing syste

    provides a built backup. If one of the CPUs breakdown the CPUs automatically takethe complete work load until repairs are made. In some systems, CPUs are connectecomputers networks. In these networks, small CPUs called front-end processors whiused for data communication and the main CPU or host computer of back-end Processused only for major processing jobs and not for data communication. In smultiprocessing System each CPU performs only specific type pf application, for examcase of multiprocessing system with two CPUs one may be used for process only onlinwhile another one may be meant for processing only batch applications. How ever system are so design that incase of breakdown of one CPU the other CPU takes ovcomplete workload until repairs are made, moreover deferent multiprocessing systemdifferent type of memory configuration in some system each CPU has its own main min other all the CPU may share a common memory while in some others each CPU maaccess to both separate and Common memories. Multiprocessing systems are of two tightly coupled system and loosely coupled systems. In tightly coupled system, there is asingle system-wide primary memory, which is shared by all the processor. On the hand, in loosely coupled system, the processors do not share memory, and each prochas its own local memory.Advantage and limitation of Multiprocessing: Multiprocessing systems typically have the following advantages:

    7

  • 8/8/2019 osunit12_(1)

    8/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    Better Performance: Due to multiplicity of processors, multiprocessor systems have performance (shorter response times and higher throughput) than single processor syFor example: if there are two different programs to be run, two processors are evidently powerful than one because the programs can be simultaneously run on different procesBetter reliability: Due to multiplicity of processors, multiprocessor systems also breliability than single processor system. In a properly designed multiprocessor systemof the processor breaks down, the other processor(s) automatically takes over the syworkload until repairs are made. Hence, a completely breakdown of such systems cavoided.Multiprocessing systems, however, requires a very sophisticated operating systeschedule, balance, and coordinates the input, output and processing activity of processor. The design of such an operating system is a complex and time takingMoreover multiprocessing system are expensive to procure and maintain. In addition high charge paid initially, the regular operation and maintains of these systems is acostly affairs.TIME SHARING PROCESS

    Time sharing is a way or system of allowing more than one person to use a computer same time. A number of terminals may all share the same computer. A time sharing shas many even 100 of terminals linked up to the same computer at the same time. Omultiprogramming where programs are executed on a priority basis but in time sharincomputer is divided (320*10-9) among all users on a schedule basis. For example let assume that the time slice for time sharing system is to millisecond i.e. the time shoperating system allocates to milliseconds to each user during which a Program belongthis user is executed. Suppose there are 100 user for this time sharing system then

    millisecond is allocated to each user a particular user will get the CPU attentions oevery 10 *10milliseconds = 1 second. In a time sharing system only one program cancontrol of the CPU at a given time as a result all the users who are using a time shsystem will form in one of following three states group such as:

    1. Active state : The user program currently has control of the CPU. Obviously onlyuser will be active at a time.2. Ready state(s): The user program is ready to continue but it is waiting for its turnget the attention of CPU More than one user can be in ready state at a time.3. Waiting or blocked state(s) : The user has made no request for execution of his job

    the Users program is waiting for some I/O operation. Again more than one use cin wait state at a time.

    8

  • 8/8/2019 osunit12_(1)

    9/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    In fig (b) user 2 is active, user1, 3 and 4 are in wait state and user 5 and 6 are in readyAs soon as the time slice of user 2 is completed the time sharing supervisor moves on next ready user (those in wait state are skipped since they are making no demand for The next ready user in the queue is user 5 which now becomes active as shown in the f

    Users will remain active until the allocated time slice expires or if the program executover during this time period at that time control is passed on to the next ready user queue which is user 6 for our example whenever I/O operation is completed for a waithat user state will be change to ready and serviced the next time around.

    In a typically time sharing systems 100 of users may be using the system simultaneousAs the total main memory available in a computer is limited it is not possible to keep thProgram of all the users of a time sharing systems simultaneously in the main memoryThus in this case, the time sharing operating system keeps only a few programs in theMain memory and the rest are stored on the disk storage. The memory residence progr

    include the active program and some of the ready program which will get CPU attentivery shortly, a wait program of the main memory is normally replaced by a ready

    program on the disk storage. When a program is to be executed it is brought pad to themain memory from the disk and the inactive program is send to the disk, theoperation of transforming program from the main memory to the disk storage and backnow asswapping . Some times this type of swapping process is called as or known as

    9

  • 8/8/2019 osunit12_(1)

    10/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    roll in roll out.

    Requirement of time sharing system:Time sharing system typically requires the following additional hardware and softfeatures:

    1. A number of terminals simultaneously connected to the system, so that multiplecan simultaneously use the system in interactive mode.

    2. A relatively large memory to support multiprogramming.3. Memory protection mechanism to prevent one jobs instruction and data from

    jobs in a multiprogramming environment.4. Job status preservation mechanism to preserve a jobs complete status inform

    when the CPU is taken away from it, and restoring this information back, beforCPU is given back it again.

    5. A special CPU scheduling algorithm which is allocates the CPU for a very period one by one to each user process in a circular fashion.

    6. Alarm clock mechanisms to send an interrupt signal to the CPU after every time Advantages of time sharing systems:Although time sharing systems are complex to design, they provide several advantatheir users. The main advantages of time sharing system are as follows:Reduce CPU idle time:The speed of thinking and typing of user is much slower than the processing speed computer. Hence, during interactive usage of a system, while a particular user is engagthinking or typing his/her input, a time sharing system can service many other users. Imanner time sharing system help in reducing the CPU idle time, increasing the sythroughput.Provides advantages of quick response time:The special CPU scheduling algorithm used in time sharing systems ensures quick restime to all users. This feature can be effectively used for interactive used for intera programming and debugging to improve the programmer efficiency. Multiple programcan simultaneously work for, writing, testing, and debugging of portions of their progrtry out various approaches to a problem solution.Offers good computing facility to small users:Small users can get direct access to much more sophisticated hardware and softwarethey could otherwise justify of affords. In time sharing systems, they merely pay a feresources used and are relived of the hard ware, software and personnel problems asso

    with acquiring and maintaining their own initialization.REAL TIME PROCESSINGIn a real time or on line operating system all the resources are accessible 24 hours (onThe computer processes immediately, one or all the inputs and delivers or transmioutput instantaneously. These operating system are generally single application orieuser are not permitted to prepare or modify programs but allowed only to input data,enquiry and get reports. Theses are dedicated system meant for only one specific applicTransaction processing is on line method in which the data are processed immediatelfiles get updated as soon as a transaction takes place. On-line processing facilitates the

    10

  • 8/8/2019 osunit12_(1)

    11/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    interactive programs, by which users can communicate with the computer during procoperation, when such an interactive program supplies the result of processing so they cused when needed to control or modify an operation or answer a customers inquire procedure is referred to as real-time processing. Airline reservation system, for exarequires immediate processing. Each time a ticket is issued or cancelled, the data moimmediately entered into a computer, processed and made available. This is how the sworks. The airline agent interacts with the computer and gets information about flighfiles the customer schedules. When an available flight is found, the computer immedrecords the sale of the desired seat. This automatically reduces the number of seats avaon the flight. Since more than one terminal is used to make reservation for a flight, the to record a transaction immediately prevents duplication of a sale that already been madReal-time processing usually uses terminal linked to a CPU via telecommunication When a one-line computer system operates quickly enough to facilitate the decision m process in an organization, it is a real-time system.There are many applications that require an immediate response from the computer. G

    a stock market quotation, finding the current level of product inventory, and searchcriminal data files for a possible suspect may all be action that needs to be done widelays. In these cases, a real time processing system is needed. Real time means immresponse from the computer. A system in which a transaction accesses and updates quickly enough to affect the original decision making is called a real-time systemessential feature is that the input data must be processed quickly enough so that fuaction can then be promptly taken on the result. One of the early and very sophisticommercial real-time systems was the American AirlinesSABER reservation system. Thefollowing factors justify the user of real-time processing for an airline reservation syste1. There are hundreds of flights daily.

    1. Each flight may have as many as 300 seats or more in inventory.2. As soon as a seat is reserved/cancelled, the concerned files are upda before the next transaction can be processed.

    3. The response time should be very short because a customereservation is to be done while he waits.

    4. Seats may be sold for only a portion of flight. For example, Mr.X m book a seat to Baroda on a Delhi to Bombay flight which stopBaroda. That seat will then be available for the Baroda to Bombay

    5. Hundred of agents throughout the country are selling seat from inventory. An air lines seat is a very perishable item. If it is not solis lost once a flight is made.

    Few more examples of business real-time processing are:1. Air traffic control system.2. Reservation system used by hotels and car rental agencies.3. Systems that provide immediate updating of customer accounts in saving banks.

    4. System that provide up to the minute information on stock prices. Process cosystem as in nuclear reactor plants and steel mills.I/O STRUCTURE AND I/O INTERRUPT

    11

  • 8/8/2019 osunit12_(1)

    12/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    A general purpose computer system consists of a CPU and multiple device controllerare connected through a common bus. Each device controller is in charge of a specifiof device. Depending on the controller, there may be more then attached device. A dcontroller maintains some local buffer storage and a set of register. The device controresponsible for moving the data between the peripheral devices that it controls and its buffer storage. The size of the local buffer within a device controller varies formcontroller to controller, depending on the particular devices being controlled.To start an I/O operation, the CPU loads the appropriate registers with in the dcontroller. The device controller examines the contents of these register to determineaction to take. For example, if it finds a read request, the controller will start the transdata from the devices to its local buffer. Once the transfer of data is completed, the dcontroller informs the CPU that it has finished its operation. It accomplishescommunication by triggering an interrupt.

    This result will occur as the result of a user process requesting I/O. Once the I/O is st

    two actions are possible: 1. Insynchronization I/O, the I/O is started then I/O completioncontrol is return to the user program, 2.A synchronization I/O returns control to the user program without waiting for the I/O to complete. The I/O then can continue whilesystem operation occurs.

    Waiting for I/O completion may be accomplished in one of the two ways:1) Some computer has a special wait instruction that ideal the CPU until the

    interrupt. If the CPU always waits for I/O completion, at most one I/O requeoutstanding at a time. Whenever an I/O interrupt occurs, the operating system kexactly which device is interrupting. On the other hand, this approach exclconcurrent I/O operation to several devices and also excludes the possibilitoverlapping useful computation with I/O.

    2) A better alternative is to start the I/O and then to continue processing other opersystem or user program code. A system call is then needed to allow the user pro

    12

  • 8/8/2019 osunit12_(1)

    13/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    to wait for the I/O completion, if desired. If no user program is ready to run anoperating system has no other work to do, we still require the wait instruction oridleloop . We also need to be able to keep track of many I/O request at the same time.this purpose, the operating system uses a table containing an entry for eachdevice: the device- status table. Each table entry indicates the devices type, addand state (not functioning, idle or busy). If the devices are busy with a requesttype of request and other parameter will be stored in the table entry for that deSince, it is responsible for other processes to issue the request to the same devicoperating system will also maintain a wait queue a list of waiting request forI/O device.

    An I/O device interrupts, when it needs services. When an interrupt occurs, the opesystem first determines which I/O devices caused the interrupt. It then indexes into thdevices status table to determine the status of that devices, and modifies the table enreflect the occurrence of the interrupt. For most device, an interrupt signals completionI/O request. If there are additional request waiting in the queue for this device, the opesystem starts processing the next request.Finally, Control is returned from the I/O interrupt. If a process was waiting for this requcomplete (as recorded in the device-status table), we can now return control to it. Othewe return to whatever we were doing before the I/O interrupt: to the execution of th program (the program started an I/O operation and that operation has now finished b

    program has not yet waited for the operation to complete) or to the wait loop (the prstarted two or more I/O operation and is waiting for a particular one to finish, buinterrupt was from one of the other operation).Many interactive systems allow users to type ahead-to enter data before the datrequested on the key board. In this case, interrupts may occur, signaling the arrivcharacteristics from the terminal, while the device-status table indicates that no prograrequired input from the devices. If type ahead is to be allowed, then a buffer mu provided to store the type ahead character until some program wants them. We may n buffer for each input device.

    13

  • 8/8/2019 osunit12_(1)

    14/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    DMA (Direct Memory Access):

    One key to obtain good performance in computer system is minimizing the numbinterrupts that occurs while a program executes. Direct Memory Access (DMA) reqonly a single interrupt for each block of character transferred in an I/O operation. It is

    then the method in which the processor is interrupt for each character transferred. OnI/O operation is initiated , character are transferred to primary storage on a cycle stealin priority) basis the channel temporarily usurps the processors path to storage whcharacter is being transferred, then the processor continues operation.When a device is ready to transmit one character of the block, it interrupts the procBut with DMA, the processor state does not have to be saved; the processors are delayed then interrupt. Under the control of special hardware, the character is transfer primary storage. When the transfer is complete, the processor resumes operation. DMuseful in system that supports a very large volume of I/O transfer. The hardware respofor stealing cycles and operation the I/O devices in DMA mode is called a DMA chann Normally, a programmed CPU loop to read the bytes one at a time from the controller wCPU time. DMA was developed to free the CPU from this low-level work. When DMused, the CPU gives the controller two items of information, the disk address of the the memory address where the block is to go and the number of bytes to transfer.After the controller has read the entire block from the device into its buffer, it copies th bytes or word into the main memory at the address specified by the DMA memory adThen it increment the DMA address and decrements the DMA count by the number of just transferred. This process is repeated until the DMA count becomes zero, at whichthe controller causes an interrupt. When the operating system starts up, it does not hcopy the block to memory; it is already there.

    DUAL-MODE OPERATION

    To ensure proper operation, we must protect system and all other programs and theifrom any malfunctioning program. Protection is needed for any shared resource. Wetwo separate modes of operation. Such as:

    a) User Mode, b) Monitor Mode/ System Mode/ Privileged Mode/ Supervisor Mode.A bit, called the mode bit is added to the hardware of the computer to indicate the cmode: Monitor (0) or user (1). When the mode bit is 0, the track is executed on behalfoperating system and when the mode bit is 1, the track is executed on behalf of the userAt system boot time, the hardware starts in monitor mode. The operating system isloaded, and starts user processes in user mode. Whenever an interrupt occurs, the har

    14

  • 8/8/2019 osunit12_(1)

    15/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    switches from user mode to monitor mode i.e. changes the state of the mode bit to 0.whenever the operating system gain control of the computer, it is in monitor modesystem always switches to user mode by setting the mode bit to 1 before passing contruser program.The dual mode of operation provides us with the means for protecting the operating sfrom errant (unauthorized) user and errant users from one another. We accomplish protection by using machine instruction that may cause harm as privileged instructionhardware allows privileged instruction to be executed only in monitor mode. If an attemade to execute privilege instruction in user mode, the hardware does not executinstruction, but rather treats the instruction as illegal and traps it to the operating systemWhen a system call is executed, it is treated by the hardware as software interrupt. C passes through the interrupt vector to a service routine in the operating system and the bit is set to monitor mode. The system call services routine is a part of the operating syThe monitor examines the interrupting instruction to determine what system caloccurred; a parameter indicates what type of services the user program is reques

    Addition information needed for the request may be passed in register, on the stackmemory with pointer to the memory location passed in register. The monitor verifies th parameters are corrected and legal, executes the request and return control to the instrfollowing the system call.OPERATING SYSTEM SERVICES

    1. The operating system provides a user-friendly environment for the creationexecution of program and provides services to the user. The main serviceoperating systems are:

    2. Program execution : A number of tasks required to execute a program. The tasinclude instruction and data must be loaded into the main memory. I/O devicefiles must be initialized and other resource must be prepared. The operating syhandles these tasks for the user.

    3. Input /Output operation: A running program may require input and output. This Imay involve a file or an I/O operation directly; the operating system must prosame means to do I/O.

    4. File system Manipulation : Program need to read and write files .Program also neto create and delete files by name. Operating system also provide the facilities tuser for creating the user file into his/her name and also provide some ofoperation which is associated with that file.

    5. Communication: In many circumstances, one process needs to exchange informatwith another process. Such communication can occurs in two ways such as : fitakes place between processes that are executing on the same computer. secondly, takes place between processes that are executing on the different comsystem that are tied together by a computer network. Communication mayimplemented via shared memory, or by the technique of message passing, in w packets of information are moved between processes by the operating system.

    6. Error Detection : The operating system detects the different types of error and shotake appropriate action. The errors include memory error, power failure, printed o

    15

  • 8/8/2019 osunit12_(1)

    16/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    paper, illegal instruction in the program (division by zero, arithmetic overfattempt to access illegal memory local).

    7. Resource Allocation : When multiple users are logged on the system or multiple jare running at the same time, resources must be allocated to each of them. Mdifferent types of resources are managed by the operating system. The resoincludes CPU cycles, main memory, I/O devices, file storage and so on.

    8. Accounting: The operating system can keep track of which users how much and wkind of computer resources. This record keeping is useful to improve compuservices.

    9. Protection : Protection is a mechanism or technique through which we are protecour files against some of the unauthorized user who may do the corruption. Opersystem gave the facilities to protect the user file.

    MULTITASKINGTechnically speaking, multitasking is the same as multiprogramming. That is, multitask

    the systems capability to concurrently work on more then one task (job or process)means that whenever a task (job or process) needs to perform I/O operation, the CPU used for executing some other task that is also residing in the system and is ready to uCPU.

    Many authors do not distinguish between multiprogramming and multitas because both the terms refer to the same concept. However, some authors prefer to uterm multiprogramming for multi-user system and multitasking for single user systemthat even in a single user system, it is not necessary that the system work only on one jotime. In fact, a user of a single user system often has multiple tasks concurrently proc by the system. For example while editing a file in the foreground, a sorting job can be

    in the background. Similarly, while completion of a program is in progress in background, the user may be reading his/her electronic mails in the foreground. Imanner, a user may concurrently work on many tasks. In such situation, the status of ethe tasks is normally viewed on different windows in a multi tasking system.

    Hence, for those who like to differentiate between multiprogramming multiprogramming is the concurrent execution of multiple jobs in a multi user system,multitasking is the concurrently execution of multiple jobs in a single user system.DISTRIBUTED DATA PROCESSING :Earlier computer systems were centralized that is an organization had large computer sat one place. The programs to be executed were brought to this centre. The distri processing system had brought the computing power to the place where it is needeunderstand the concept of a distributed processing system, let us consider an examporganization has diversified with its offices situated at different places. Each office hown computer system and is capable of accomplishing its own computational needs. Tin fact, just decentralization, however if there is such a data processing requirement w particular office is unable to complete , may be due to lack of data or hardware limitatithis situation this office requires the services of the other computer systems located inoffices. The best way to solve this problem is to link all the computer systems in alloffices, thus reducing the burden on the host computer. Thus a computer system capa

    16

  • 8/8/2019 osunit12_(1)

    17/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    distributing the computational work among various computer installations is cdistributing processing system. In such a data processing technique, each cominstallation is capable of fulfilling its own needs, but in exceptional situation, it maupon the other installations for help .The advantages of distributed systems are:1. Reduction of the load on the host computer.2. Minimization of cost in data processing.3. Reduction of delays in data processing.4. Better services to the customer.SPOOLING PROCESS

    The process of storing the input data and output results on tape or disk is known as spoThe full form of spool isSimultaneousPeripheralOutputOn L ine. Spooling is a techniquethat has been successfully used on a number of computer systems to reduce the smismatch and turn the ideal time of CPU. It is a process of placing all data that comesan input device or goes to an out put device on either a magnetic tape of disk. A bat program, when fed to the keyboard or card reader or any other input devices is reatemporally stored on a magnet tape or disk instead of being directly stored in the memory. The programs stored on tape or disk are now fed to and processed by the computer. The results obtained are again written on tape or disk instead of being dir printed on any output device. Special spooling program are executed by the operating sto transfer the data from the disk or tap to the main memory or an input to output devithis case the disk or tap devices act as a buffer area between main storage which is extefast and I/0 devices which are relatively slow. A buffer is a temporally storage area wwill take information from one device and hold it until another device is ready to receThis is done at different speed. If data is typed in very fast some characters go in to a before they appear on the screen. Spooling programs are executed when the CPU is r busy with other jobs.

    17

  • 8/8/2019 osunit12_(1)

    18/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    UNIT-2

    File system, file concept, file attribute, file operation, filetype, file structure, access method, sequential access,index sequential access and direct access, directorystructure, single level, two level, tree structure, fileprotection and access control.

    FILE SYSTEMAn important component of an operating system is the file system. File system gencontains:Accessed method: These are concerned with the manner in which stored data within aaccessed.File management: This is concerned with providing the mechanism for files to be sreferenced, shared, and secured.Auxiliary storage management: This id concerned with the allocating space for filsecondary storage device.File integrity mechanism: These are concerned with generating that the information in a is uncorrupted.

    18

    ROOT DIRECTORY

    USER DIRECTORY

    USER FILE

  • 8/8/2019 osunit12_(1)

    19/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    On a large scale time sharing systems and distributed processing systems. It is commonuser accounts to contain between 10 and 100 files. Thus with a user community of s1000 users, a system disk might easily contain 50,000 to 100,000 more separate files. files need to be accessed quickly to keep response time small. File system for thenvironment may be organized as per the mentioned above figure. A root is used to inwhere on disk the root directory begins. The root directory points to the variousdirectories. A user directory contains an entry for each of a users file. Each entry poiwhere the corresponding files are stored on disk. Files name need only be unique wigiven user directory. In hierarchical structured file systems, the system name of a fusually formed as thePath name from the root directory to the file.

    File system function :Some of the functions normally attributed to the file system follow:

    1. User should be able to create, modify and delete files.

    2. The mechanism for sharing files should provide various type of controlled accesas: read access, write access, execute access etc.3. User should be able to order the transfer of information between the files.4. Backup and recovery capability must be provided to prevent either accidental l

    malicious destruction of information.5. Most important, the file system should a user

    friendly inter base. It shouldGive users a logical view of their data and the function to

    be performed upon it rather than a physical view.To provide an efficient and convenient access to the disk,

    the operating system imposes one or more file system toallow the data to be stored, located and retrieve easily. Afile system poses two quite different design problems. Thefirst problem is defining how the file system should look to the user. This task involves defining a file and itsattributes, the operation allowed on a file and the directorystructure for organizing files. The second problem iscreating algorithms and data structure map of the logicalfile system on to the physical secondary storage devices. File are managed by the opesystem that how they are structured, named,accessed used, protected and implemented are major topics in operating system design. As a whole that part of the operating system desi

    with files is known as the file system.The file system itself is generally composed of many different levels.The lowest level,I/O control consists of device drivers and interrupts handler to transfinformation between the main memory and the disk system. A device driver is thougha translator.The basic file system needs only to issue generic commands to the appropriate devdrivers to read and write physical block of the disk.

    19

    Application Program

    Logical file system

    File organization ModuleBasic file system

    I/O Control

    Devices

  • 8/8/2019 osunit12_(1)

    20/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    The file organization module knows about the file and their logical blocks as well physical blocks. By knowing the type of file allocation used and the location of the fifile organization module can translate logical block addresses to physical block addrethe basic file system to transfer.Finally,the logical file system manages metadata information. Meta data includes all of tfile system structure excluding the actual data. A file control block (FCB) coninformation about the file including permission and location of the file contains. The lfile system is also responsible for protection and security.FILE CONCEPTComputer can store the information in several different storage media such as magdisks, magnetic tapes and optical disks. So that the computer system will be conveniuse the operating system provides uniform logical view of information storage.operating system abstract from the physical properties of its storage devices to deflogical storage unit. Files are mapped by the operating system on to physical devices. storage devices are persistent through power failure and system reboots. A file is a n

    collection or related information that is recorded on secondary storage. Commonlyrepresent programs (both source and object forms) and data. Data files may be numalphabetic, alphanumeric or binary. In general, a file is a sequence of bits, bytes, linrecord the meaning of which is defined by the file creator and user. The information inis defined by its creator. Many different types of information may be stored in a file- s program, object program, executable program, numeric data, text, graphic images, andrecording and so on.All computer applications need to store and retrieve information. While a process is ruit can store a limited amount of information within its own address space. A second prwith keeping information within a process address space is that when the process to a

    the information at the same time. A third problem is that it is frequently necessarmultiple processes to access the information at the same time. Thus we have three essrequirements for long term information storage:

    a. The multiple processes must be able to access the information concurrently. b. It must be possible to store a very large amount of information.c. The information must survive the termination of the process using it.

    The usual solution to all these problems is to store information on disk and otherexternal media in units called files (Or) A file is a named collection of relatedinformation that is recorded on secondary storage .A file is named collection of data. It normally resides on a secondary storage devices sdisk or tape. It may be manipulated as a unit by operation such as:

    a) OPEN: Prepare a file to be referred. b) CLOSE: Prevent further reference to a file until it is reopened.c) CREATE: Build a new file.d) DESTROY: Remove a file.e) COPY: Create another version of the file with a new name.f) RENAME: Change the name of the file.g) LIST: Prevent or display the contents of a file.

    Individual data items within the file may be manipulated by operation like:

    20

  • 8/8/2019 osunit12_(1)

    21/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    a) READ: Input a data item to a process formation. b) WRITE: Output a data item from a process to file.c) UPDATE: Modify an existing data item in a file.d) INSERT: Add a new data item to a file.e) DELETE: Remove a data item from a file.

    File can be characterized by:a) VOLATILITY: This refers to the frequency with which additions and deletionmade to a file.

    b) ACTIVITY: This refers to the percentage of a file records accessed during a period of time.

    c) SIZE: This refers to the amount of information stored in the file.A Text File: A text file is a sequence of characters organized into lines.A Source File: A source file is a sequence of subroutines and function each of whfurther organized as declaration followed by executable statement.An Object File: An object file is a sequence of bytes organized into blocks understanda

    the system linkers.An Executable File: An executable file is a series of code section that the loader can into memory and execute.FILE ATTRIBUTE

    A file is named, for the convenience of its human users and is referred to by its namname is usually a string of character such as ajit.doc. Some systems differentiate betupper and lowercase character in names where as other system consider the two casesequivalent. When a file is named, it becomes independent of the process, the user andthe system that created it. For instances, one user might create the file ajit.doc wheanother user might edit that file by the specifying its name. The files owner might wrifiles to a floppy disk send it in an e-mail or copy it across a network and it could stcalled ajit.doc on the destination system.A file has certain other attributes which vary from one operating system another but typconsist of these:

    NAME: The symbolic file name is the only information kept in human readable formIDENTIFIERS: This unique tag, usually a number identifies the file within thesystem; it is the non- human readable name for the file.TYPE: This information is needed for those systems that support different type.LOCATION: This information is a pointer to a device and to the location of the fithat device.SIZE: The current size of the file (in bytes, words or blocks) and possibly the maxallowed size are included in this attributes.PROTECTION: Access control information determines who can do reading, wrexecuting and so on.TIME, DATE AND USER IDENTIFICATION: The information may be keptcreation, last modification and last use. These data can be useful for protection, seand usage monitoring.

    21

  • 8/8/2019 osunit12_(1)

    22/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    The information about all the files is kept in the dictionary structure that also residsecondary storage. Typically the directories entries consist of the files name and its uidentifier. In a system with many files the size of the dictionary itself may beMegabytes. Because dictionary like files must be nonvolatile, they must be stored odevices and brought into memory piecemeal as needed.FILE OPERATION :File exists to store information and allow it to be retrieved later. Different systems prdifferent operation to allow storage and retrieval. Some of the operation of the files is:CREATE: The file is created with no data. The purpose of the call is to announce that tis coming and to set some of the attributes.DELETE: When the file is no longer needed, it has to be deleted to free up disk space.OPEN: Before using a file, a process must open it. The purpose of the open call is to the system to fetch the attributes.CLOSE: When all the access are finished, the attributes and disk addresses are no lneeded. So the file should be closed to free up internal table space.READ: Data are read from file. The caller must specify how must data are needed an provide a buffer to put them in.WRITE: Data are written to the file again, unusually at the current position. If the c position is the end of the file, the file size increases. If the current position is in the midthe file, existing data are overwritten and lost for ever.APPEND: This call is a restricted from of write. It can only add data to the end of the fSEEK: For random access file, a method is needed to specify from where to take theOne common approach is system calls seek.SET ATTTRIBUTE: Some of the attributes are user settable and can be changed aftfile has been created. The protection mode information is an obvious example.

    RENAME: It frequently happens that a user needs to change the name of an existing is not always strictly necessary because the files can usually be copied to a new file winew name and the old file then deleted.

    FILE TYPE

    A common technique for implementing file types is to include the type as a part of thname. The name is split into two parts- a name and an extension name. Usually separaa period (.) character. The system uses the extension to indicate the file and the tyoperations uses the extension to indicate the type of the file and the type of operation th be done on that file. For instance only a file with a .com, .exe or .bat extension cexecuted. The .com and .exe files are two forms of binary executable files where as a .bis a batch file containing, in ASCII format, commands to the operating system. MSrecognizes only a few extensions, MS-DOS recognizes only a few extensions,application program also use extensions to indicate file types in which they are interFor example, assemblers expect source files to have an (.asm) extension and the word pword processor expects its file to end with a (.wp) extension. These extensions arrequired so a user may specify for a file with the given name and the extensions it ex because these extensions are not supported by the operating system they can be considehints to applications that operate on them.

    22

  • 8/8/2019 osunit12_(1)

    23/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    FILE TYPE USUAL EXTENSION FUNCTIONExecutable File .exe,.com, .bin or .none Read to run machine

    language program.Source code C, CC, java, pas, asm, a Source code for various

    languageBatch bat, ch Commands to the

    command interpretertext txt, doc Textual data documentsWord Processor wp, tex, rrt, doc Various word processor

    formatLibrary lib,a,so,dtl,mpeg,mov,r

    mLibraries of routines of programmer

    Many operating system support several type of files. UNIX and MS-DOS for exampleregular files and directories.Regular file : Regular files are the file that contains user information. Regular filesgenerally either ASCII files or binary files. The files that are created by the user withelp of any language (may be c, c++, assembly etc) except machine level language is kas regular file . ASCII file consist of lines of text. The great advantage of ASCII files isthey can be displayed and printed as is, and they can be edited with an ordinary text ediDirectories: The file which contains the information about the regular files in a hierarcmanner is known asdirectory . Directories are the system files for maintaining the structuof the file system.Character special file : Character special file are related to input/ output and used to mo

    serial I/O devices such as terminals, printers, and network. Basically it is used in netwsystem for the input/output operation.Block special file: Block special files are used to model disks. The operating systemonly executable a file if it has the proper format. The file which contains the informatvarious regular files to do a particular task is known asblocked file . It has the five sections:header, text, data, relocation bits, and symbol table. The header starts with a magic nuidentifying the file as an executable file. Following the header are the text and data program itself. These are loaded into memory and relocated using the relocation bitssymbol table is used for debugging.FILE STRUCTURE

    File types also may be used to indicate the internal structure of the file. Source and ofiles have structures that match the expectations of the programs that read them. Fucertain files must conform to a required structure that is understood by operating systemFor example, the operating system may require that an executable files have a spstructure so that it can determine where in memory to load the file and what the locatthe first instruction is. The Macintosh operating system also support a minimal numfile structure. It expects files to certain two parts: aresource folk and a data folk. Theresource fork contains in formation of interest of the user. A data fork contains programor data. Too few structures make programming in convenient, where as too many

    23

  • 8/8/2019 osunit12_(1)

    24/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    operating system bloat and programmer confusion. The buffer (it is the inner area computer where the data are stored temporarily) which contains the instruction ooperating system in two part such as resource part and data part. Resource folk containstruction of the user where as data folk contains the program code of the user. Basicis used IBM or Macintosh operating system.File can be structured in any of several ways. Three common possibilities are depictedas: (a) Byte sequence, (b) Record sequence and (c) Tree

    Figure (a) Figure (b)Figure(c)The file in figure (a) is an unstructured sequence of bytes. The operating system doeknow or care what is in the file. All it sees are bytes. Any meaning must be imposed buser level programs. Both UNIX and MS-DOS use this approach. The figure (b), a fisequence of fixed length records, each with some internal structure. The third kind ostructure is shown in figure(c). In this organization a file consist of a tree of recordnecessarily all the same length, each contains key field in a fixed position in the recordtree is sorted on the key field, to allow rapid searching for a particular key. If the fielddesigned or sorted in the tree basis then it is very much easier to access when ever

    necessary.FILE ACCESSSystem designers choose to organize, access and process records and file in differentdepending on the type of application and the needs of the user. The three commonly u business data processing application are: Sequential access, direct access/Random access,indexed sequential access. The selection of a particular file organization or access depenupon the type of application. The best access to use in a given application is the onhappens to meet the user needs in the most effective and the economical mannerorganization or access requires the use of some key field or unique identifying value found in every record in the field. The key value must be unique for each records of th because duplication would cause serious problem. In the payroll example the employefield may be used as the key field.SEQUENTIAL ACCESSIn a sequential file, records are store one andafter another in an ascending or descending order determine by the key fields of the records. In payroll example, the records of theemployee may be accessed sequentially byemployee code sequence. Sequentially

    24

    1 BYTE

    1R ECR D

  • 8/8/2019 osunit12_(1)

    25/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    organized files that are processed by computer systems are normally stored on storage such as magnetic tape or magnetic disk. To access these records, the computer must refile in sequence from the beginning. The first record is read and processed first thesecond record is in the file sequence and so on. To locate particular records the com program must read in each record in sequence and compare its key field to the one needed. The retrieval search ends only when the desired key matches with the key fithe currently key record.

    Advantages of the sequential access1. Easy to organize, maintain and organized.2. It is fast and efficient when dealing with large volume of data that need to be proc periodically (batch system).

    Disadvantages of the sequential access1. Requires that all new transaction to be stored in to the proper sequence for sequ

    access processing.2. Locating, sorting, modifying, deleting or adding records in the file requires rearthe file.

    3. This method is too slow to handle application requiring immediate updatinresponses.

    4. Timeliness of data in the field directories while batches are being accumulated.5. Data redundancy is typically high since the some data may be stored in severa

    sequence of different keys.

    DIRECT ACCESS OR RANDOM ACCESS OR RELATIVE ACCESS

    File whose bytes or records can be read in any order are called random access or daccess or relative access. Random access files are essential for many applicationsexample: if an air line customer call off and wants to reserve a seat on a particular fligreservation program/operator must be able to access the records for that flight without hto read all the records from the thousand of other flight first. Two methods are usespecifying where to start reading. In the first one everyREAD operation gives the positionin the file to start reading. In the second one special operationSEEK is provided to set thecurrent position. After a SEEK the file can be read sequentially from the new cu position. In some older mainframe operating system file are classified as being sequentially or random access, at the time they are created. This allows the system tdifferent storage techniques for these two classes. Modern operating systems do not this distinction. All their files are automatically randomly accessed. A direct file consrecords organized in such a way that it is possible for the computer to direct locate the the desired record without having to search through a sequence of other records. This that the time required for online enquire and updating of a few records is much fasterwhen batch techniques are used. However adirect access storage device (DASD) such as adrum, disk, etc is essential for storing a direct file. A record is stored in a direct file key field. Although it might be possible to directly use the storage location number in Das the key for the records stored on those location, this is seldom done. Instead an arith

    25

  • 8/8/2019 osunit12_(1)

    26/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    procedure calledHashing is frequently used. In this method an address generatinfunction is used to convert the record key number into a DASD storage address. The agenerating function is selected in such a manner that the generated address shoudistributed uniformly over the entire range of the file area and a unique address shougenerated for each record key. However in practice, the above constraints are usuallsatisfied and the address generating function, often maps a large number of records same storage address. Several methods are followed to overcome this problem of collisionwhen it occurs.

    Advantages of the Direct File AccessSome of the advantages of the direct accesses are:

    1. The access to and retrival of a record is quick and direct. Any record can be loand retrived directly in a fraction of second, without the need for a sequential sof the files.

    2. If requires, it is also possible process direct files records sequentially in a recor

    sequence.3. A direct file organization is must suitable for interactive online applications suair line or railway reservation system, teller facility in banking application etc.

    4. Transaction neednt be stored and placed in sequence prior to processing.

    Disadvantages of the Direct File AccessSome of the disadvantages of the direct accesses are:

    1. This file must be stored on a direct access storage device. Hence relatively expehardware and software resources are required.

    2. Files updation (addition and deletion of the records) is more difficult as compa

    sequence file access.3. Address generation overhead is involved for accessing each record due to hafunction.

    4. Special security measures are necessary for online direct files that are accessiblseveral stations.

    INDEX ACCESS (OR) INDEX SEQUENTIAL FILESWe are all familiar with the concept an index. For example: The directory in a large shared buildings is an index that helps us to locate a particular persons room withi building. For instances, to find the room of Mr. X within the building, we could look name in the directory (index) and read the corresponding floor number and room numb

    EmployeeCode

    AddressLocation

    AddressLocation

    EmployeeRecords

    0001 1003 1001 0002 Mr.X

    0002 1001 1002 0004 Mr.Y

    0003 1004 1003 0001 Mr.Z

    26

  • 8/8/2019 osunit12_(1)

    27/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    0004 1002 1004 0003 Mr.P

    0005 1005 1005 0005 Mr.A

    . . .. . Nth Number

    Nth Number

    Nth Number

    Nth Number

    Similarly, if we wished to read the section in the book about printers, we could not beg page 1 and read every page until we came across the topic of interest. Rather, we coulthe subject in the contents to locate the page number and then turn directly to that pa begin reading. Indexed sequential files use exactly the same principle. The records itypes of files are organized in sequence and an index table is used to speed up access records without requiring a search of the entire file. The records of the file can be storandom sequence but the index table is in sorted sequence on the key value. This prothe user with a very powerful tools. Not only the files can be processed randomly but be processed sequentially. Since the index table is in a sorted sequence on the key valufile management systems simply access the data records of the index values. From the figure, the concept or technique of file management is commonly referred to asindexedsequential access methods (ISAM). Files of this type are called ISAM files.Advantages:Some of the advantages features of the index file access are:

    1. Permits the efficient and economically use of sequential processing technique the activity ratio is high.

    2. Permits the direct access processing of records in a relatively efficient way whe

    activity ratio is low.Disadvantages:Some of the disadvantages of indexed file access are:

    1. Access to records may be slower than the direct access.2. The efficient in the use of storage space than some other alternatives. These files

    be stored on a direct access storage device. Hence relatively expensive hardwarsoftware resources are required.

    DIRECTORY STRUCTURE:

    The file systems of computers can be extensive. Some system stores million of files on bytes of disk. To manage all these data, we need to organize them. This organizatusually done in two parts.

    First, disks are split into one or more partitions also known as mini disk in the IBM wor volumes in the PC. Typically each disk on a system contains at least one partition, wis a low- level structure in which files and directories reside. Sometimes, partition are u provide several separate areas within one disk, each treated as a separate storage dwhere as other system allow partition to be large than a disk to group disk into one lostructure. In this way, the user needs to be concerned with only the logical directory an

    27

  • 8/8/2019 osunit12_(1)

    28/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    structure and can ignore completely the problems of physically allocating space for filethis reason partition can be thought of as virtual disks.Second , each partition contains information about files with in it. This information is kentries in a device directory or volume table of contents. The device directory reinformation such as name, location, size and type for all files on that partition.

    When considering a particular directory structure, we need to keep in mind the operatiois to be performed on a directory:SEARCH FOR A FILE: We need to be able to search a directory structure to find the enfor particular files. Since file have symbolic names and similar names may indicrelationship between the files.CREATE A FILE : New files need to be created and added to the directory.DELETE A FILE : When a file is no longer needed, we want to remove it from the direcas well as directory list.LIST A DIRECTORY : We need to be able to list the files in a directory and the contentthe directory entry for each file in the list.RENAME A FILE : Because the names of the files represent its contents to its user the nmust be changeable when the contents or use of the file changes. Remaining a file maallow its position within the directory structure to be changed.TRAVERSE THE FILE SYSTEM : We may wish to access every directory and every fiwithin a directory. For reliability, it is a good idea to save the contents and structure entire file system at regular intervals. This saving often consists of copying all filmagnetic tape.LOGICAL STRUCTURE OF A DIRECTORY:

    Depending on the nature of the files, directory structures are mainly four types. Such asa. Single level directory structure b. Two level directory structurec. Tree level structured directoryd. Acyclic graph directory structure.

    The directory structure is depends upon the three factor, such as how much amount owe have, as per the requirement of the user and the way of searching. We (user) may udifferent directory structure only for the quick access of a particular file.

    28

  • 8/8/2019 osunit12_(1)

    29/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    Single directory structure:The simplest directory structure is the single- leveldirectory. When the directory structure having a singlelevel is called assingle level directorystructure . Here the number of the level is not morethen one. In case of one level directory structure no levhas behaving as like a MFD as well as UFD. All files acontained in the same directory, which is easy tosupport and understand. A single-level directory has significant limitation, however whnumber of files increases or when the system has more then one user. Since all files the same directory they must have unique names. If two users call their data file theunique name rule is violated. MS-DOS operating system allow only 11 character file nUNIX allow 255 characters.Even a single user on a single-level directory may find it difficult to remember the naall the files, as the number of the files increases. It is not uncommon for a user to hundreds of file on one computer system and an equal number of additional files on asystem. In such an environment, keeping track of so many files is a daunting task. Idirectory system, having only one directory which consisting of all the files.Advantage: Ability to locate all the files quickly.Disadvantage: i) Different users may accidentally use the same names for their files. example, if the user-1 creates a file called Sample (name of the file) and the user-create a file into the same name like sample then the particular file name is over where.(ii) It is not in the multi user system. It is used on small embedded (organization) sy

    those who has a few amount of files.Two-level directory structure:A single level directory often leads to confusion of file names between different userstandard solution is to create a separate directory for each user. In the two level direstructures, each user has its own user filedirectory (UFD). Each UFD has a similar structure but list only the files of a single userWhen a user job starts or a user log in, thesystem master file directory (MFD) issearched. The MFD is indexed by user name or account number and each entry point to the UFD for that user.

    When a user refers to a particular file only his own UFD is searched. Thus differentmay have files with the same name as long as all the files names within each UFDunique. To delete a file, the operating system confines its search to the local UFD thus not accidentally delete another user file that has the same name. The user directthemselves must be created and deleted as necessary. A special system program is run

    29

  • 8/8/2019 osunit12_(1)

    30/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    the appropriate user name and account information. The program creates a new UFDadds an entry for it to the MFD. Although the two level directory structures solve thecollision problem, it still has disadvantages. This structure effectively isolates one useranother. This isolation is an advantage when the users are completely independent budisadvantage. When the user want to cooperate on some task and to access one anotheSome systems simply do not allow locating user files to be accessed by other user. Istructure MFD is one of the levels and UFD is another level so for that this is called alevel directory structure. To name a particular file uniquely in a two level directory, wegive both the user name and the file name. A two level directory can be thought of asor at least an inverted tree. The root of the tree is the MFD and the files are the leaves tree. A special case of this situation occurs in regard to the system files. Those prog provided as a part of the system loaders, assemblers, compliers, utility routines, librariso on are generally defined as files. When the appropriate commands are given toperating system, these files are read by the loader and executed. The standard solutiocomplicate the search procedure slightly. Whenever a file name is given to be loade

    operating systems first search the local UFD. If the file is found, it is used. If it is not fthe system automatically searches the special user directory that contains the systemThe sequence of directory searched when a file is named is called the searched path.DISADVANTAGES: It is not satisfactory for users with a large number of files.TREE LEVEL DIRECTORY STRUCTURE:The two level directories eliminate name conflict among user but it is not satisfactousers with a large number of files. To avoid this, creates the sub-directories and loasame type of files.Once we have seen how to view a two leveldirectory as a two level tree, the natural

    generalization is to extend the directory structure toa tree of arbitrary height. This generalization allowsthe users to create their own sub-directories and toorganize their files accordingly. The tree has a rootdirectory. Every file in the system has a unique pathname. A path name is the path from the root, throughout all the sub directories, to a spefile. A directory contains a set of files or sub-directory. A sub-directory is simply anoth but it is treated in a special way. All directories have the same internal format. In normeach user has a current directory. The current directory should contain most of the fileare of current interest to the user. When a reference is made to a file, the current directsearched. If a file is needed that is not in the current directory then the user must especify a path name or change the current directory to be the directory holding that fichange directories, a system call is provided that directory named as a parameter and uto redefine the current directory. Path name can be of two types such as:absolute pathname or relative path name . An absolute path name begins at the root and follows a padown to the specified file, giving the directory names on the path. A relative path defines a path from a current directory. Allowing the user to define his own sub-direc permits him to impose a structure on his files. This structure might result in sepdirectories for files associated with different topic or different forms of information

    30

  • 8/8/2019 osunit12_(1)

    31/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    interesting policy decision in a tree structured directory structure is how to handldeletion of directories. If a directory is empty, its entry in its containing directory can s be deleted. However suppose the directory to be deleted is not empty but contains sfiles or sub-directories; one of two approaches can be taken. Thus to delete a directoruser must first delete all the files in that directory. If any sub-directories exist, this procmust be applied recursively to them, So that they can be deleted also. A path to a file instructured directories can be longer then that in a two level directory. To allow useaccess program without having to remember these long paths, the Macintosh opersystem automates the search for executable programs. It maintains a file, called desktopcontaining the name and location of all executable programs it has seen. A double clicfile to be searched for a match. Once the match is found, the appropriate executable pris started with the clicked on files as its input.DISADVANTAGES : When we add links to an existing tree structured directory, the tstructure is destroyed.ACYCLIC GRAPHIC DIRECTORY STRUCTURE:

    Consider two programmers who are working on a joint project. The files associated wi project can be stored in a sub-directory, separating them from other project and files two programmers. But since both programmers are equally responsible for the projecwant the sub-directory to be in their own directories. The common sub-directory shoshared. A shared directory or files will exist in the file system in two (or more) plaonce.A tree structure prohibits the sharing of files or directories. An acyclic graph aldirectories to have shared sub-directories and files. The same file or sub-directory maytwo different directories. An acyclic graph that is a graph with no cycle is a nageneralization of the tree structure directory scheme.

    A shared file or directory is not the same as the two copies of the file. With two copies programmer can view the copy rather than the original. But if one programmer changfiles the changes will not appear in the other copies, with a shared file only one actuexist. So any changes made by one person are immediately visible to the other. Shar particularly important for such directories a new file creates by one person will automaappear in all the shared sub-directory.When the people are working as a team, all the files they want to share may be put in team member put each contents this directory of shared files as a sub-directory. Even there is a single user his file organization may require that same files be put in to difsub-directories. For example: A programmer written for a particular project should be bthe directory of all programs and in the directory for that project.An acyclic graph directory structure is more flexible than is a simple tree structure, it imore complex. Several problems must be considered carefully. A file may now multiple absolute path names. Consequently distinct file names may refer to the samThis situation is similar to thealiasing problem for programming language. Anothecommon approach to implementing shared files is simply to duplicate all informationthem in both sharing directories. Thus both entries are identical and equal. A link is cdifferent from the original directory entry. Thus the two are not equal. Duplicate dire

    31

  • 8/8/2019 osunit12_(1)

    32/83

    Material is Prepared By: Mr.Ajit Kumar Mahapatra, Lect. In Computer Science (ContactNumber: 9853277844)

    entries however make the original and the copy indistinguishable. A major problemduplicate directory entries is maintaining consistency of the file is modified.FILE PROTECTION

    When information is kept in a computer system, we want to keep it safe from phy

    damage (reliability) and improve access (protection). Reliability is generally provided duplicate copies of files. Many computer have systems programs that automaticallydisk files to tape at regular intervals to maintain a copy should a file system be accidedestroyed. File systems can be damaged by hardware problems such as reading and w by power surges or failures, head crashes, dirt, temperature extremes and vandalismmay be deleted accidentally. Bugs in the file system software can also cause file conte be lost. The need to protect files is a direct of the ability to access files. Systems that d permit access to the files of the other users do not need protection. Thus we could prcomplete protection by prohibiting access. Alternatively we could provide free accesno protection. Both approaches are too extreme for general use.Protection is a mechanism or methods or technique through which, the user may phis/her files against some of the unauthorized user who may do the disturbance or corruThere is no need of protection mechanism for the single user operating system but in cmulti user operating system means when a single system is operated through a more thuser, their must be need a protection mechanism to protect their individual files againstProtection mechanism provides controlled access by limiting the type of file access th be made. Access is permitted or denied depending upon the several factors, one of whthe type of access requested. Several different types of operation may be controlled, sucREAD: Read from the file.WRITE: Write or rewrite the files.EXECUTE: Load the files into memory and execute it.APPEND: Write new information at the end of file.DELETE: Delete the file and free its space for possible reuse.LIST: List the name and attributes of the file.Other operation such as renaming, copying or editing the file may also be controlled.There are three methods or techniques are their to provide the protection mechanismas: (a) Password Protection, (b) Access list or access control, (c) Access group.Password Protection:The protection problem is associated a password with each files. Just as access tcomputer system is often controlled by a pa