Sie sind auf Seite 1von 21

OPERATING SYSTEMS I Course description:

Page 1 of 21

CHAPTER 1: INTRODUCTION TO OPERATING SYSTEMS All modern computers are collections of different pieces of circuit board, silicon chips and other devices all interconnected. These pieces are called the computers hardware. All these pieces of hardware together cannot do anything by themselves. Something has to tell the hardware what to do and how to communicate between the parts. The something that does this is the Operating system (ie creates a virtual interface, performs scheduling, multitasking/multiprogramming, memory management, I/O interaction/management, resource management, processor management, taking logs etc. Definition: The Operating System acts as an interface (or translator) between the application s/ware (e.g. word processor) and the h/ware (i.e. tells the h/w what to and how to communicate between the parts).

Fig. 1.1

User

Application s/w

Application s/w

Application s/w

Operating system

Hardware
When the application wants to accomplish something such as to save, rename, format, obtain directory listings etc, the OS takes over and tells the h/w what to do and then relays the results back to the application when it finishes. The primary purpose of an OS is to insulate the user and their application programs from the underlying details of the machine. The second reason is to allow the resources of the computer to be shared. The various types of OS are outlined here below. Types of Operating Systems 1. Single User Systems:- Here, the OS can only undertake one operation at a time for a single user (i.e. single user single tasking) DOS is a good example of such an OS. These may also provide multitasking i.e. undertake several jobs (seemingly simultaneously) for a single user (single user multitasking) Windows 3.0, 3.11, 95, 98 or 2000 is a good example of these the user can have many windows open, work is carried out in the background while user uses the foreground. 2. Process Control: - Generally implies the control by computer of an industrial process such as the refining of oil, the manufacture of machine tools or even the monitoring of a patients condition in a hospital. The common feature of all these applications is feedback i.e. the computer receives input from the controlled process, computes a response which will maintain its stability, and initiates the mechanism for giving it. For example, if the input specifies a dangerous rise in temp, then the response may be to open a valve in order to raise the flow of coolant. The main function of the OS in process control is to provide maximum reliability (i.e. avoid faults, tolerate faults and detect and recover from faults) with the minimum of operator intervention, and to fail safe in the even t of any h/w malfunctions. 3. File Interrogation Systems: - Are used by large-scale database applications, which can be interrogated for information. The response to information requests must occur within a short time, and the database must be capable of being modified as information is updated. Examples are MIS, where the database consists of information on company performance, and Medical Information Systems in which the database is a set of patients records. The user expects to access information without any knowledge of how the database is organized. The OS must therefore make interrogation facilities available without involving the user with the details of implementation. 4. Transaction Processing: - are used to support business s/w applications such as airline seat reservations and banking. They must allow multiple simultaneous accesses to data, allow updates and operate within strict response times. 5. General Purpose Systems: - are systems that support multiple users and multitasking (e.g. one user could be analyzing survey data, another calculating the monthly payroll etc). The system must be able to handle

Page 2 of 21

the wide variety of peripherals, which may be required (e.g. terminal, bar code reader etc). The provision and control of these facilities, together with the organization of the flow of work are the broad functions of a general-purpose OS. The systems may support batch processing i.e. once a job enters the computer; the user has no further contact with the job until it has been completed. They must be fully interactive and remain responsive to users (e.g. the user may supply data which are dependant on the results so far received). Each user has the impression that he/she has the entire machine to him/herself.

Page 3 of 21

CHAPTER 2: FUNCTIONS AND CHARACTERISTICS OF OPERATING SYSTEMS i. ii. Job sequencing: - the OS carries out the sequence of steps necessary to read in, compile, load and execute one or more programs. Job control or command language interpretation: - since all jobs do not necessarily require the same sequencing operations (some jobs for example may not need compilation), the OS needs to infer precisely which operations are to be performed in any particular case. The OS must therefore be capable of interpreting a job control language. Error handling: - the OS must not allow the errors which inevitably occur in some jobs to affect jobs later in the sequence. I/O handling: The OS handles the conversion of input (from e.g. keyboard) to output (e.g. printed output. Interrupt handling: - the OS implements multiprogramming through a system of interrupts. An interrupt is a signal which transfers control of the central processor (CPU) to some fixed location, while at the same time storing the previous value of the program counter. Thus the program execution is temporarily abandoned, but can be resumed later at the point where it was interrupted. Scheduling: - This is a method of organizing the jobs stored on disk so as to decide which one is to be run next. This is a method of organizing the sharing of the CPU to the several jobs stored on disk so that each is given a fair chance to run. Resource Control (mgt): - resources are allocated by an OS according to user needs and system capabilities under the usual constraints of efficient and reliable operations. Examples of resources to be allocated include processor time, peripheral devices e.g. printer, backing store, files etc. Protection: - in a multiprogramming environment, the OS protects one job from the activities of another. Multi-access: - the OS shares the computing resources among the various users so that it appears as if each user has exclusive use of the entire machine. Allow programs to store and retrieve information. Establish a user interface: - the OS should be easy to run from the users point of view. Accounting of computing resources: - the OS should be easy to control from the system managers point of view i.e. taking logs.

iii. iv. v.

vi.

vii.

viii. ix. x. xi. xii.

Operating System Characteristics i. Concurrency:- is the existence of several simultaneous or parallel activities such as the coexistence n memory of several user programs. Problems associated with concurrency include: Switching from one activity to another. Protecting one activity from the effects of another. Synchronizing activities which depend on each other. ii. Sharing: - concurrent activities may be required to share resources (e.g. printer) or information (e.g. in memory). The advantages of sharing resources include: Cost it is wasteful to provide resources for all users separately. Building on the work of others it is useful to use other peoples programs or routines. Sharing data it may be necessary to use the same data for several different programs or users. Removing redundancy it is economical to share a single copy of a program (e.g. an editor or compiler) among several users rather than provide a separate copy for each user or process. Problems associated with sharing include: Resource allocation Simultaneous access to data Simultaneous execution of programs Protection against corruption iii. Long-term storage the need for sharing programs and data implies the need for long term storage of information in the computer. Long term storage also allows users the convenience of keeping their programs or data in the computer rather than on some external medium. The problems associated with long term storage include: Providing easy access Protection against interference (malicious or otherwise) Protection against system failure Non-determinacy the OS must be determinate in that the same program, run today or tomorrow with the same data, should provide the same results. On the other hand it is indeterminate in that it must respond to

iv.

Page 4 of 21

events which will occur in unpredictable order. Examples of such events are resource requests, run-time errors in programs, and interrupts from peripheral devices. It is unreasonable to expect to write the OS to cater for all individual contingencies that can arise. Instead the system must be written to handle any sequence of events. Desirable features The following are the desirable features for an OS to display: i. Efficient the OS should be efficient i.e. Minimize CPU idle time Minimize response time ( in interactive systems) Minimize turn-around times for batch jobs. Minimize mean time between batch jobs where applicable. Maximize throughput (batch jobs per hour, rate at which work can be done interactively). Maximize resource utilization. ii. iii. Reliable the OS should be completely or almost free of errors and able to handle all contingencies (i.e. possible events). Easy to maintain it should be possible to enhance an OS or correct errors without involving an army of systems programmers. The system should therefore be modular in construction with clearly defined interfaces between the modules and be well documented. Small size the space to hold the OS (e.g. in memory) should be small so that enough space is available for productive computing. Additionally, a large system is more prone to error and takes longer to develop than a small one. Platform independent it should be possible to run it in different h/w and s/w combination that comprise the basic functionality of a computer.

iv.

v.

Features of Windows This is a task for your practical undertaking. Examine the features MS-DOS, MS-WINDOWS (various versions) etc.

Page 5 of 21

CHAPTER 3: CONCURRENT PROCESSES Programs, Processes and Processors An OS may be considered as a set of activities each providing one of the functions such as error handling or I/O handling. Each activity consists of the execution of one or more programs, and will be invoked whenever the corresponding function is to be provided. The word process is used to describe an activity of this kind. A process is therefore a sequence of actions, performed by executing a sequence of instructions (a program) whose net result is the provision of some system function A processor is an agent for running a process. It executes instructions; depending on the nature of instructions the processor may be implemented in h/w alone or in a combination of both h/w and s/w. For example, a CPU is a processor for executing machine language instructions, while a CPU together with an interpreter for a particular programming language can form a processor for executing instructions expressed in that programming language. Concurrency is the activation of several processes while apparent concurrency can be obtained by switching processes from one to another. Only when the number of processors = the number of jobs can we therefore talk of true concurrency. Concurrent processing (or parallel processing) can therefore be defined to mean that if a snapshot is taken of the system as a whole, then several processes may be found somewhere between their starting points and their end points. This definition clearly includes both true and apparent concurrency. Non-determinacy can be described in terms of processes. If we regard processes as sequences of actions which can be interrupted between steps, then non-determinacy is reflected in the unpredictable order in which the interruptions may occur and hence the unpredictable order in which the sequences proceed. To summarize, a process is a sequence of actions (dynamic) whereas a program is a sequence of instructions (static). A processor is an agent for running a process. Non-determinacy and concurrency can be described in terms of interrupting processes between actions and of switching processors among processes. In order to effect interruption and switching, sufficient information about a process must be stored in order that it may later be resumed. Communication between Processes Processes that work together to some common purpose or within some shared environment require to talk to each other. The areas in which communication is essential may be categorized as follows: i. Mutual exclusion system resources may be classed as sharable, meaning that they may be used by several processes concurrently or non-sharable, where their use is restricted to one process at a time. Examples of sharable resources include CPUs, read-only files and areas of memory which contain pure procedures or data protected against modification. Non-sharable resources include most peripherals (e.g. printer), writable files, and data areas which are subject to modification. The principal problem arising from the sharing of resources is to ensure that serially reusable resources are only used by one process at a time, i.e. to ensure mutual exclusion. If we assume, for example, that a printer is being used by a process, then the printer must remain allocated to the process until the printout is completed. Synchronization the speed of one process relative to another is unpredictable, as it depends on the frequency of interruption of each process and on how often and for how long each process is granted a processor. We say that processes run asynchronously with respect to each other. To achieve successful cooperation, there are certain points at which processes must synchronize their activities. These are points beyond which a process cannot proceed until another process has completed some activity. E.g. a process which schedules user jobs cannot proceed until an input process has read at least one job into the machine. It is the OSs responsibility to provide mechanism by which synchronization can be effected. Deadlock two or more processes are said to be deadlocked if each waits for a resource held and not released by the other. Starvation then occurs as processes wait on future execution sequence before they can proceed and a system grinds to a halt.

ii.

iii.

The avoidance of deadlock is one of the functions of the OS. There are several methods of deadlock prevention. The figure below demonstrates a deadlock situation.

Page 6 of 21

Fig. 3.1

Process 1

Has resource A needs resource B

Has resource C needs resource A

Process 2
Has resource B needs resource C

Process 3

A deadlock situation can only arise if the fololowing conditions prevail: a) Non-preemptive schediuling a resource can only be released by the process which has acquired it (ie process holds resource it has been allocated while waiting for new one) b) Mutual exclusion a resource can only be given to one proces at a time (ie the resources involbed are unsharable). c) Partial allocation a process can acquire its resources piecemeal (resources cannot be preempted while being used). d) Circular waiting processes acquire part of their total resource needs and enter an indefinite waity state to acquire each others resources. There are several methods of deadlock prevention. a) Simultaneuous access to a resource by several processes. This is an unrealistic method for security and integrity b) Preemptive scheduling processes are forced to release resources temporarily in favour of other processes. Again this is unrealistic if peripheral devices use private data eg pre-printed stationary. (the OS uses this approach). c) Complete allocation a process can only run when all of its resources are allocated to it. The overall effect will be to slow the multiprogramming process. d) Sequential ordering of requests this method will prevent circular waiting but ususally results in expensive algorithms. Mechanisms For Interprocess Communication i. Semaphores these operate exactly as the early trains used to obtain access to a single (bi-directional) piece of track. See fig 3.2 below.
Train A awaits track key

Fig. 3.2

Train B gets track key

Systems programmers operate a similar principle by declaring a semaphore. A semaphore is used to lock a shared resource prior to its use. The process uses the resource and uses a semaphore to release the resource. A semaphore is s simple integer variable which can take non-negative values and upon which two operations, called wait and signal are defined. A semaphore is initially set to 1 (available). When a process requires a resource, it executes a wait on a named semaphore. If the value is 1, 1 is deducted and the process is allowed to proceed. If another process requires access to the same resource, the semaphore is 0, (unavailable) and it will have to wait. When the first process finishes with the shared resource, it signals the appropriate semaphore (adding 1 to its value). A waiting process will then wake up, subtract 1 from semaphore and then proceed to use the resource. The definitions of these operations are given below:

Page 7 of 21

wait(s): else

if s>0 then set s to s-1 block the calling process (i.e. wait on s) endif

signal(s): wait(s))

if a process is waiting on s, (i.e. suspended as a result of resume it (i.e. start one of these processes) else set s to s+1 endif

Note that, for each semaphore, the system must maintain a queue of processes which are waiting for that semaphore to become 0. The OS guarantees that wait and signal are indivisible i.e. once started, execution of that operation cannot be interrupted. ii. Monitors: (pg 176 OS Colin Ritchie): a monitor in the context of concurrent processes is a programming construct which is used to control access to shared data. In effect, the monitor encapsulates both the shared data and the procedures used to access and manipulate the data. The monitor data can only be accessed via the monitors procedures which can be called from within the applications processes. The important feature of the monitor is that it enforces mutual exclusion with respect to access of shared data i.e. only one process can use any monitor procedure at one time. User processes are free to invoke the monitor procedures whenever they wish, without worrying about the presence of competing processes. If the data is already being accessed, the process required is placed in a queue and serviced by the monitor in due course. iii. Message passing: some systems (mostly client-server systems) implement interprocess communication and synchronization by passing messages between processes. The primitives provided by the OS allow processes to send and receive messages e.g. send-message(destination, message); and receive-message(source, message); Each of the above primitives takes two forms: blocking and non-blocking. A blocking send operation waits until the receiving process accepts the massage, a non-blocking simply places the message in some form of queue and allows the sender to continue execution. A blocking receive operation waits for a message to be sent to the process; a nonblocking receive accepts a message if one is waiting, otherwise it returns some indication that no massage was available.

Page 8 of 21

CHAPTER 4: MEMORY MANAGEMENT Memory management is important because unless a process possesses some memory, there is very little it can do. It certainly cannot execute, since there is no room for the associated program nor can it perform input or output without space for buffers. The objectives of memory management are: a) Relocation: as processes run to completion, the space they use becomes free for other processes and it may be necessary to move processes around in memory in order to make best use of the space available. In particular, it may be desirable to move processes so that small noncontiguous areas of free memory become compacted into a larger more useful single area. b) Protection: it is essential that each process running in a system does not interfere with the code or data of any other process, either by accident or deliberate intrusion. c) Sharing: despite the need for protection, it is also desirable in some circumstances that process code and/or data be sharable by two or more processes. For example, if a number of processes are executing the same program, it is advantageous to allow each process to access the same copy of the program rather than have its own separate copy. Similarly, processes may need to share data and thus have common access to the area of memory holding it. d) Logical organization: most programs are structured in some way into modules or procedures and refer to distinct areas of modifiable or unmodifiable data. If the logical divisions into program and data are reflected in a corresponding segmentation of address space then several advantages accrue. These are: It is possible for segments to be coded independently and for references from one segment to another be filled in by the system at run time. It is possible to give different degrees of protection (e.g. read only, write only, execute only etc) to different segments. It is possible to introduce mechanisms by which segments can be shared among processes. e) Physical organization: historically, the general desire for large amounts of storage space and the high cost of fast memory have led to the almost universal adoption of two-level storage systems. These are a relatively small amount of main memory and a much larger amount of secondary memory. Main memory uses semiconductor technology and secondary storage is usually based on magnetic disks. Others include the provision of memory space to enable processes to be executed at the same time, provision of satisfactory level of performance for the system users, protect preprocesses from each other, enable sharing of memory etc.

f)

Mechanisms of Memory Management The following techniques, ranging from simple to complex are aimed at minimizing utilization of memory. a) Single process allocation (see fig below): in a computer which is only intended to run one process at a time, memory management is simple. The process to be executed is loaded into the free space area of the memory; in general, a part of the memory space will be wasted.

Fig. 4.1
Wasted User process Operating system

Such an arrangement is clearly limited in capability and is found nowadays primarily in simple systems such as games computers. Early MS-DOS systems operated in this manner. b) Fixed Partition Memory: the memory is divide into a number of separate fixed areas, each of which can hold one process (program) Fig. 4.2

Page 9 of 21

Process (prog)3

Partition 3

Process (prog)2 Process (prog)1 Operating system

Partition 2

Wasted/unused space

Partition 1

The sizes of the partitions are fixed and the system is able to carry out simultaneous executions of processes (multiprogramming). There is still wastage of memory, because the size of a job will seldom be such as to exactly fill one partition. This occurrence of wasted space is referred to as internal fragmentation. The disadvantages of fixed partition include: The fixed partition sizes can prevent a process being run due to the unavailability of a partition of sufficient size. Internal fragmentation wastes space which collectively could accommodate another process. These problems are addresses by the next technique. c) Variable partition allocation: in this technique, a process is allocated the exact amount of memory it requires at load time. Processes are loaded into consecutive areas until the memory is filled or more likely, the remaining space is too small to accommodate another process. This method is illustrated in the figure below. The memory is initially loaded with three programs the size of the partition being exactly the same as the size of the process (program). Process 2 finishes leaving its partition free. Process 4 is loaded into this partition, but of course is smaller than 2 and so the space at x will be wasted. This space cannot be recovered until process 3 finishes when process 5 can be loaded into memory starting at the end of process 4. Thus, the three partitions at stage 3are not all identical in size to the partitions at stage 1 since each process remains in exactly the same area of store throughout its execution.

y Process 3 Partition3 Process 3 x Process 2 Partition 2 Process 4 Process 4 Partition 2 Process 5 Partition 3

Process 1 Op.sys. Stage 1

Partition 1

Process 1 Op.sys. Stage 2

Process 1 Op.sys. Stage 3

Partition 1

The major problem with a partitioned memory allocation scheme is fragmentation, which is the development of temporarily unusable holes in memory (e.g. x in the above figure). At stage 2, it may have been process 6 on the READY queue could have made use of the amount of space represented by x+y. As those areas are not contiguous, the process would not be loaded and so x+y would remain unused. When process 3 finishes, a large space is available and the OS loads process 5into this space because this requires a large partition. The process of bringing together non-contiguous holes is referred to as coalescing and is a significant factor in maintaining fragments within usable limits.

Page 10 of 21

d) Variable Partition Allocation with Compaction: the fragmentation problem encountered in the previous method can be tackled by physically moving resident processes about the memory in order to close up the holes and hence bring the free space into a single large block. This process is referred to as compaction and is ill lustrated below.

Free Process 4 Process 3 10k

Free Free Process 3 50k

Free Process 45 Process 30k Process 3

Process 2 30k

Process 2

50k

Process 1 20k Op. sys. Stage 1

Free Op. sys. Stage 2

Process 2

30k

Op. sys. Stage 3

When fragmentation prevents a new job being loaded in stage 2, the processes which are still active in memory are compacted by relocating them downwards. E.g., when processes 1 and 4 are finished, processes 2 and 3 are moved so that process 5 can be filled into the contiguous area formed. The compaction can be done: As soon as any process terminates When a new process cannot load due to fragmentation When the user decides to There are two major problems associated with the compaction scheme. First, there is the overhead of physically moving processes for compaction, which must be traded off against the wasted memory in partitioned scheme. Second, a small amount of memory is wasted. e) Paging allocation: this is another approach to the problem of fragmentation. In a paged system, each process is split into a number of fixed size chunks called pages. The memory is also divided into page frames of the same size. The loading process now involves transferring each process page to some memory page frame. The figure below shows an example of three processes which have been loaded into contiguous pages in the memory.

(Insert diagrams)

Page 11 of 21

The figure above shows that there remain three free pages in memory which are available for use. Suppose now that process B terminates and releases its allocation of pages, giving us the position illustrated in figure (a) below. We now have two disconnected regions of free pages, reminiscent of holes in the variable allocation scheme. However, this is less of a problem in a paging system because the allocation is done on a page by page basis; the pages of a process as held in memory page frames do not need to be contiguous or even in the correct order. Let us assume now that two more processes require to be loaded; process D needs three pages and process E four pages. These are allocated to any memory pages which are free, producing figure (b). Paging alleviates the problem of fragmented free space since a process can be distributed over a number of separate holes. After a period of operation, the pages of active processes could become extensively intermixed, producing something like figure (c). There is still the residual problem of there being a number of free spaces available which are insufficient in total to accommodate a new process; such space would be wasted. However, in general, the space utilization and consequently the system throughput are improved. f) Segmentation: is the subdivision of a process into chunks by the programmer. It uses variable length chunks called segments. It is similar in some ways to the variable partition method of allocation discussed earlier except that a process can be loaded into memory in several portions, i.e. segments. Under a paging system, the process subdivisions are physical entities, not related to the logical structure of the process. However the segments in a segmentation scheme correspond to logical divisions of the process such as its modular structure (e.g. data in one segment and each subroutine in a number of code segments). The figure below illustrates the technique.

Page 12 of 21

g) Virtual Memory (Demand Paging): - often, the size of consigned jobs is far greater than the available memory, which would normally mean that a program cannot run or a user cannot have access. This problem is overcome by using a virtual system based on paging. Further, the programs which are to be loaded usually follow a linear chain of execution and so only the initial pages are needed to begin execution of the process by loading into memory only a fragment of the program, say the first 10 pages, then we have enough of the program to begin execution and enough free memory to load small chunks of all the programs required. We must be careful to load the next pages of the program when they are needed otherwise we will prevent the program from running. Preferably we need to load the pages in advance of the program requiring them otherwise we will cause unnecessary delay. Failure to load a required page in advance is termed a page fault. By operating in such a fashion we can execute a program whose size is larger than our computers memory. Thus the OS is using the computers disk storage to create virtual memory limited only to the size of our hard disk storage (i.e. with virtual memory, the user has the illusion that the computer has a large main memory space for use). The actual physical memory into which the process (program) parts are loaded is referred to as real memory. Fundamentally, VM operates by swapping out of memory pages, which are not being used and replacing them with pages which are about to be used. To further enhance performance, the OS keeps track of frequency of use of pages and swaps out the least frequently used ones. It should be borne in mind that there will typically be many processes competing for real memory space. Consequently the available real memory will become full of pages belonging to those active processes. (see figure below).

Page 13 of 21

Thrashing: if we push VM beyond their limits, then we run a risk of the system thrashing. It is therefore the situation where the computer spends more time loading and swapping pages to and from disk than it is doing useful work. This ultimately degrades the computers performances and the solution is simply more real memory.

Page 14 of 21

CHAPTER 5: THE INPUT AND OUTPUT SYSTEM The range of I/O devices and the variability of their inherent nature, speed, specific design etc make it difficult for the OS to handle them with any generality. The characteristics which give rise to the wide variations in the nature of the I/O devices are: i. Speed: e.g. a magnetic disks data transfer rate is far faster than with the keyboard. ii. Unit of transfer: data may be transferred in units of characters, words, bytes, blocks or records, according to the peripheral used (e.g. blocks of 512, 1024 etc, bytes for disk and single characters for screen). iii. Data representation: e.g. data may be coded in different ways on different I/O media and even on a single medium, e.g. a magnetic tape, several different codes may be employed. iv. Permissible operations: devices differ in the kind of operations they can perform e.g. for disk, you can read, write, seek etc while for printer you can move paper, select font etc. v. Error conditions: failure to complete a data transfer may have various causes such as h/ware detected data error, a printer that has run out of paper or a checksum error depending on the peripheral being used. The computer communicates with I/0 devices by means of an I/O bus system. Each I/O device has an associated hardware controller unit attached to this bus system, which can transmit and/or receive data to/from the computers main memory. Services on the bus are assigned addresses which enable the processor to identify the device to which a specific data item is to be directed. To enable the I/O devices to perform their activities independently of, and simultaneously with the processor activities, a system of interrupts is used. The device sends an interrupt signal to the processor when it has completed an assigned task, enabling the processor to further work for the device. Most computers also use a technique known as direct memory access DMA, which enables much faster data rates, since the processor is only involved in initiating the transfer; thereafter, data is transferred directly between memory and the device without involvement of the processor. The processor is notified by the interrupt only on completion of the transfer. (Nb: DMA module mimics the processor and performs cycle stealing). Objectives of I/O System i. Device independence: a program should be independent of the particular device of a given type which it happens to be allocated e.g. it should not matter which printer is used for a programs output. ii. Efficiency: perhaps the most important characteristic of the I/O system is the speed disparity between it and the processor and memory (reason the mechanical nature of the I/O devices). The design of the I/O system largely reflects the need to minimize the problems caused by this disparity. The intention is to maintain the devices operating at the highest possible rate doing useful work. iii. Uniform treatment of devices: in the interest of simplicity and freedom from error, it is desirable to handle all devices in a uniform manner. iv. Character code independence: the I/O system must take responsibility for recognizing different character codes used by various peripherals and for presenting data to user programs in standard form. Structure of the I/O System To meet the problems indicated above, the h/w and s/w el ements of the computers I/O system consists of a number of layers separating the user at one end to the physical devices at the other end. The overall picture is shown in the figure below, the individual components being described there after. Fig 4.1: Structure of I/O system Op. System I.O bus

Application program

I/O control system

Device driver (s/w)

Device controller (h/w)

Device (h/w)

System calls

Page 15 of 21

Application programs: within the application, I/O activity is expressed in user-oriented terms, such as, read record and from file xyz. Such instructions in a high level language are translated into corresponding system calls which invoke OS functions. The system calls are expressed in logical terms, largely independent of the device used. I/O control system (IOCS): - this term is used to denote that part of the OS which deals with I/O related system calls. It performs initial processing and validation on the request, and routes it to the appropriate handler at the next stage. It is also where the general management of I/O interrupts take place. Device drivers: this is a s/w module which manages the communication with, and the control of a specific I/O device. It is the task of the device driver to convert the logical requests from the user into specific commands directed to the device itself e.g. a user request to write a record to a floppy disk would be realized within the device driver as a series of actions such as checking for the presence of a disk in the drive, locating the file via the disk directory, positioning the heads etc. Although device drivers are in effect add on modules, they are nevertheless considered to be part of the OS since they integrate closely with IOCS. Device controllers: this is a h/w unit which is attached to the I/O bus of the computer and provides a h/w interface between the computer and the I/O device itself. Device: I/O devices are generally designed to be used in a wide range of different computer systems e.g. the same laser printer could be used on MS-DOS, Apple and Unix systems. Buffering: the description of the I/O procedures and the device handlers given above assumes that all data transfers are unbuffered i.e. each I/O request from a process causes a physical transfer of data to occur on the appropriate peripheral. If the process is performing repeated transfers on the same stream, it will repeatedly be suspended while the transfers take place e.g. considers a single process reading a succession of data blocks from a disk drive. Fig. 4.2 User process Operating system Disk drive

The process initially issues suitable system calls to read the first block of data, transferring it to a work area in th e processs memory space. When the block has been read, the process or performs some processing on the data, e.g. calculating results, assembling printable data etc. While this is in progress, the data in the work area must be retained intact, so for the time being, no further input of data from the disk is possible. After processing of the first block is complete, another block is transferred and the cycle repeats. The process is therefore switching between processing of blocks of data and transfers of the same. In order to avoid heavy overheads in process switching, it is sometimes convenient to perform I/O transfers in advance of requests being made, thus ensuring that data is available when required. This technique is known as buffering. A buffer is an intermediate main memory storage area under the control of the OS which holds data in transit between the users work area and the device. Input transfers are made by the OS into an area of memory called input buffer; the user process takes it s data from the buffer and is forced to wait only when the buffer becomes empty. When this occurs, the OS refills the buffer and the process continues e.g. Fig. 4.3 User process/wo rk area OS/ buffer

Disk drive

Page 16 of 21

Similarly, output transfers from a process are directed to an output buffer, and the OS empties the entire buffer when it is full. The process has to wait only if it tries to output an output before the system has emptied the buffer. The technique can be refined by the use of two buffers rather than one, this is called double buffering. Fig. 4.4 OS User process/work area Buffer A Disk drive Buffer B

A process now transfers data to (or from) one buffer while the OS empties (or fills) the other. This ensures that the process will wait only if both buffers are filled (or exhausted) before the OS has taken action. This ensures that the process will wait only when the process performs a rapid burst of I/O, and in this case the problem can be solved by the addition of yet more buffers (i.e. multiple buffering). Spooling: sharable devices as disk drives can handle successive requests from different processes while unsharable devices such as k/boards and printers can be allocated to only one process ant a time. The unsharable devices are those that operate in such a way that their allocation to several processes at once would lead to an extricable mingling of I/O transactions. On allocation, the unsharable device is released only when the process terminates (and is then allocated to a waiting process). This implies that during periods of high demand, several processes may be held up waiting for the use of scarce devices, while during other periods, these same devices may be lying idle. In order to spread the load and reduce the possibility of bottlenecks some other strategy may be needed. The solution adopted by many systems is to spool all I/O for heavily used devices. This means that instead of performing a transfer directly on the device, the transfer is executed on some intermediate medium, usually disk,. The responsibility of moving data between the disk and the required device is vested in a separate process, called a spooler which is associated with that device. NB: the output queue need not be processed on a first come first served basis, the spooler may for example, favour short files over long ones e.g. we have printer spoolers which take files from queue and send them to the printer. Advantages of spooling It evens out the pressure of demand on heavily used peripherals. It also reduces the possibility of deadlocks arising form injudicious peripheral allocation. It is also easy to produce several copies of the same output without rerunning the job Disadvantages of spooling A large amount of disk space is needed to hold the I/O queues. There is heavy traffic on the disk channel. It is not feasible on a real time environment since I/O transactions are required immediately.

Page 17 of 21

CHAPTER 6: PROTECTION This is the act of protecting interprocess interferences. It examines protection as a whole and the ways to implement protection mechanisms on a unified system wide basis. Motivation for protection: i. Protection from faults in this case, faults arising from one process should not interfere with other processes when running on the same machine. Fault protection applies to both user processes and the OS itself. Even for a single user with a single machine, protection is still desirable e.g. it can be an aid to debugging by limiting the error propagation and localizing the original source. Even faults arising form the malfunction of h/w and operator error. ii. Protection from malice the security of data essentially requires guarantee. This could be for various reasons e.g. commercial interest, privacy, legal issues etc. for example, a program creator would not wish to have his/her copyright infringed upon. A worthwhile protection mechanism must thus allow legitimate sharing (for those processes that need to share data/programs) while preventing unauthorized interferences. It is otherwise the coexistence in a computing system of both cooperation and competition which makes protection a problem. Development of protection mechanisms: Elementary protection that excludes unauthorized users would require user identity e.g. username and password provision. Such username and password are checked against the system accounting file. This technique can be made more secure by encrypting the users password when first assigned and storing the encrypted version in the accounting file. Another protection scheme is implemented if the host machine is equipped with segmentation hardware. In such case the address space of each process is divided into logical segments each segment being given a particular degree of protection (e.g. read only, execute only etc) by incorporating a protection indicator into its descriptor. In this case two processes may reference the same physical segment through descriptors which have different protection indicators, thus allowing sharing. Draw diagram

A reads information that is stored by B. The figure shows segment sharing with different access privileges. NB: there are various other mechanisms which have been tried. A hierarchical protection system: Figure shows rings of protection.

Page 18 of 21

The structure takes the form of the diagram shown. Each ring contains a subset of the capabilities of the one outside it. Progression from the outermost to the innermost rings bestows successively greater privileges. A ring may be a collection of segments. Procedures that require a large number of privileges reside in segments in inner rings, while those that need fewer privileges or which cannot be trusted to be error free, are contained in segments in outer rings. Access to inner rings is prohibited while to outer rings is subject to the access indicators. An attempt by a process to cross a ring boundary by calling a procedure in a different ring causes generation of an error trap. The disadvantage of hierarchical protection systems is that if an object must be accessible in domain A which is not accessible in domain B, then A must be higher up in the hierarchy.

Page 19 of 21

CHAPTER 7: RELIABILITY Can be defined as the degree to which it meets its specifications in respect of service to its users, even when subjected to unexpected and hostile conditions e.g. h/w malfunction or user error. Some systems such as those that control a space capsule or monitor the condition of a hospital patients demand high reliability while a system for document preparation and retrieval requires less reliability. The following should be done to produce a highly reliable OS: i. Eliminate faults (i.e. fault avoidance) in the design and implementation stages ii. Detection of errors as soon as possible in order to reduce damage caused. iii. Treatment of faults which produce errors. iv. Error recovery i.e. assessment and repair of damage resulting from error. Fault avoidance: faults may come from h/w of s/w or from operator/user. a. Operator/user faults can be reduced through appropriate training and user education programmes, and by design and development of a good user interface. b. H/w faults use the most reliable components which can be obtained within the overall cost constraints. c. S/W faults three approaches are - adopt management practices e.g. small development teams, programming methodologies e.g. structured, object-oriented, and software tools. - Attempt to prove by more or less formal means that all programs in the OS and all their interactions are correct. - systematic testing in order to detect faults e.g. black box testing (general function) and white box testing (code by code). Error detection: the provision of superfluous (redundant) information to check the validity of the main information contained within the system is the key to error detection. Coding is also a useful means of error detection and in some cases can also be used for recovery. Errors detected by the hardware may be masked by the hardware itself or they may be reported to the OS by means of interrupts. The OS should be capable of reacting to errors soon after they occur. Fault treatment: involves identifying the fault causing the error and having it repaired. The search for a fault is generally directed by the investigators understanding of the same structure. This may be done through the use of transaction logs of recent activity. Events recorded in the log could be process activations, procedure entries, I/O transfers etc. Once a fault has been located, its treatment involves some sort of repair, e.g. for h/w faults, repair may comprise replacement of a faulty component e.g. disk drive. Faults in s/w components are removed through the replacement of a number of lines of code in program, while a corrupted program could be replaced through a backup copy. Error recovery: recovery from error involves assessment of the damage caused, followed by repair. The repair involves reversing or rolling back the affected processes to a state which existed before the error occurred. This can be enhanced by the use of audit trails (logs) to record information about the state of the process. Audit trail techniques are analogous to the incremental dump of a file system, described earlier. Multi-level error handling The aim is to mask from each level of the OS errors which occur at levels below it. Each level of the system must as much as possible be responsible for its own error recovery, so that levels above it appear fault free. In cases where masking is impossible, errors in a lower level may be reported to the higher level s for recovery. Those errors which cannot be masked at any level must be reported to the user/operator. The following errors should not be masked: - user errors - memory and protection violations resulting form execution of user programs.

Page 20 of 21

CHAPTER 8: THE USER INTERFACE This is the users gateway into the computer, enabling the required human -computer interaction to take place. There are three classes of users namely: i. Programmers produce s/w for use of themselves and others. ii. Operational concerned with the provision, operation and management of computing facilities for others, e.g. the systems engineers concerned with systems efficiency, s/w installation etc. iii. End user apply s/w to some problem areas e.g. cash machine user etc. Types of user interface i. System call all interaction with the h/w has ultimately to be implemented by system calls. A lowlevel language programmer may use system calls directly. ii. Command language most OSs provide the user with the facility of entering commands directly via an interactive terminal. Such systems are used to initiate execution of programs and to perform housekeeping control routines on the system (setting up directories, deleting old files, taking backups etc). Examples of this technique include MS DOS interface and the Unix Shell programs. iii. Job control language JCLs are used to define the requirements and parameters of work submitted to a batch system and would generally be used by computer operations staff in a mainframe environment. Batch operation implies that jobs are initiated by a user and subsequently run with no (or minimal) interaction of intervention. The principal characteristics of this mode of working are: a. Execution is intensive as there are no delays caused by human intervention. b. Most suitable for routine jobs typically found in commercial processing e.g. payroll production, financial reports etc. c. Since job runs on its own, responses to possible abnormal events must be planned. d. Resources required by job generally predictable. e. Work being done is often costed and charged to some cost center within the organization The last three of the above indicate tasks which must be managed by JCL. Qn: what aspects of JCL distinguish it from a command language? Ans: JCLs are designed for batch use and supply information of relevance to this mode of working e.g. establishment of resources required, accounting information, error processing etc. Modern systems use much more advanced languages in their user interfaces. Modern control languages serve as command language and JCLs (macros). iv. Graphical User Interface provides a means of interacting with the system using a windows and mouse-driven environment. The main features of GUI include: a. Onscreen overlapping windows b. Pointing device e.g. mouse c. Other features e.g. buttons, icons, dialogue boxes etc.

The Job pool: The term scheduling covers the questions of when to introduce new processes into the system and the order in which processes should be run. This is done by a single system process called the scheduler. In a batch system, jobs awaiting execution are stored in a job pool which is held in secondary memory. The scheduler starts execution of a job by initiating an appropriate process. The choice of which job to start next depends on the resources that each job requires and on the current pattern of resource allocation in the system. The job pool may be structured as a single list or a number of lists each of which contains jobs with particular characteristics. System messages: This is the information supplied by systems, particularly when job errors have occurred. In a multi-access environment, a user should be able to request information about the current state of the system, eg the number of users logged on, the resources available etc. &&&& The end &&&&

Page 21 of 21

Das könnte Ihnen auch gefallen