Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operating System book cum notes, Study notes of Operating Systems

Operating System Book cum accurate notes for study operating system subject in computer science engineering

Typology: Study notes

2019/2020

Uploaded on 04/03/2020

Nidhish1631
Nidhish1631 🇮🇳

1 document

1 / 130

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OPERATING SYSTEMS
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Operating System book cum notes and more Study notes Operating Systems in PDF only on Docsity!

Objectives:^ OPERATING SYSTEMS

Hello,students, it is your first class and I will introduce you to the basic concepts of an operating system -

- You will understand what is an operating system. - Why should you learn Operating System.

To understand an Operating Systems ,you need to know what is an Operating System

An Operating System is system software which may be viewed as an organized collection of software consisting of procedures for operating a computer and providing an environment for execution of programs. It acts as an interface between users and the hardware of a computer system.

Now ,I will explain you the main purpose of an Operating System

- Convenience : transform the raw hardware into a machine that is more amiable to users. - Efficiency : manage the resources of the overall computer system

Operating system can also be defined as:

  • System software which may be viewed as an organized collection of software consisting of procedures for operating a computer and providing an environment for execution of programs.
  • A large collection of software which manages resources of the computer system, such as memory, processor, file system and input/output devices. It keeps track of the status of each resource and decides who will have a control over computer resources, for how long and when.
  • It acts as an interface between users and hardware of a computer system.

Colloquially, the term is most often used to mean all the software which “comes with” a computer system before any applications are installed.

Examples of operating systems

  • UNIX
  • GNU/Linux
  • Mac OS
  • MS-DOS

Let us discuss the fundamental goal of a Computer System

The fundamental goal of computer system is to solve user problems. Accordingly to achieve this goal has been designed. Since hardware alone cannot be used to solve the user problems software’s are developed. These programs required certain common operations. The common operations for controlling and allocating resources are then brought together into one piece of software i.e. operating system. An operating system may process its tasks sequentially or concurrently. It means that the resources of the computer system may be dedicated to a single program until its

completion or they may be allocated among several programs in different stages of execution. Why should you need an Operating System? The feature of operating system is to execute multiple programs in interleaved fashion or different time cycle is called multiple programming systems. Some of the important reasons why do you need an Operating System are as follows:

  • User interacts with the computer through operating system in order to accomplish his/her task since it is his primary interface with a computer.
  • It helps the user in understand the inner functions of a computer very closely.
  • Many concepts and techniques found in operating system have general applicability in other applications. An operating system is an essential component of a computer system. The primary objectives of an operating system are to make computer system convenient to use and utilizes computer hardware in an efficient manner. An operating system is a large collection of software which manages resources of the computer system, such as memory, processor, rite system and input/output devices. It keeps track of the status of each resource and decides who will have a control over computer resources, for how long and when. The positioning of operating system in overall computer system is shown in figure 1.

UNIT 1 LESSON-

300 | yyyy <— SW to handle interrupt type 1

.. .. ..

HW support: for each interrupt type (e.g. clock interrupt, IO completion, change to supervisor state, invalid instruction) the HW changes to program counter to a “prewired” memory address (in the above example, 100 for interrupt type 0, 101 for interrupt type 1, etc.) This results in the specific code to handle that interrupt being executed.

Examples:

  1. Suppose clock interrupts are “wired” to memory location 100. Then in a typical RR system, the interrupt causes a transfer to code which checks the cause of the timer interrupt. If the cause is that a process has gotten its “time slice” then scheduling code will save the state of the current process, maybe do accounting, pick the next process to execute, restore its state, and start it.
  2. Suppose memory location 102 is associated with the “invalid instruction” interrupt. What then?

Well, for one thing, this allows things the same machine code to be used in machines that don’t have quite the same instruction sets (say, across a product line from cheap slow processors to expensive fast processors). (Homework: explain how this might be done.)

Once the hardware supports this, then I/O can be handled much more efficiently. It is also used for security. If some instructions are privileged, then if a “normal” process attempts to execute them, the OS (through interrupt code) can validate what is happening.

The point has been to do things FAST. So that things are only checked when they need to be. This requires a combination of HW and SW support.

Memory Protection:

1. Base register: contents of base register are automatically added (by HW) to each address. Not done by SW since this would be too slow. Main Memory 0 +——————+ | | To switch from J1 to J3, OS changes | OS | base register contents of 10000 to | | 60000. 10000 +——————+ | | | J1 | This simplifies much system software. | | For example, compilers can now “pretend” 40000 +——————+ that all code is loaded starting at | J2 | addr 0.

| J3 |

| J4 |

2. Limit register: make sure user does not reference beyond allocation memory size. Load limit register with size of memory allocated to process. HW traps (that is causes an interrupt) if the process attempts to use an address larger than limit register contents. Note: this is NOT checked in software (much too slow). It must be done in hardware as a side effect of addressing memory SO THAT NOTHING SLOWS MEMORY REFERENCES DOWN. THE SAME GOES FOR THE USE OF THE BASE REGISTER. If memory references are validated, the mechanism must be very fast. How does the OS get around this? Two basic approaches:

  • some machines allow interrupts to be turned off, or
  • interrupt handler can check to see who is trying to do memory reference. Review Exercise:
  1. Define an Operating System?








  1. Explain the need for an Operating System?








Reference Books:

Author Dahmke, Mark.

Main Title Microcomputer Operating Systems / Mark Dahmke.

Publisher Peterborough, N.H : Mcgraw-Hill/Byte Books, C1982.

Author Deitel, Harvey M., 1945-

Main Title An Introduction To Operating Systems / Harvey M. Deitel.

Edition Rev. 1st Ed.

Publisher Reading, Mass : Addison-Wesley Pub. Co., C1984.

Author Lister, A. (Andrew), 1945-

Main Title Fundamentals Of Operating Systems / A.M. Lister.

Edition 3rd Ed.

Publisher London : Macmillan, 1984.

Author Gray, N. A. B. (Neil A. B.)

Main Title Introduction To Computer Systems / N.A.B. Gray.

Publisher Englewood Cliffs, New Jersey ; Sydney : Prentice-Hall,

Author Peterson, James L.

Main Title Operating System Concepts / James L. Peterson, Abraham Silberschatz.

Edition 2nd Ed.

Publisher Reading, Mass. : Addison-Wesley, 1985.

Author Stallings, William.

Main Title Operating Systems / William Stallings.

Edition 6th Ed.

Publisher Englewood Cliffs, Nj : Prentice Hall, C1995.

Author Tanenbaum, Andrew S., 1944-

Main Title Operating Systems : Design And Implementation / Andrew S. Tanenbaum, Albert S. Woodhull.

Edition 2nd Ed.

Publisher Upper Saddle River, Nj : Prentice Hall, C1997.

Author Nutt, Gary J.

Main Title Operating Systems : A Modern Perspective / Gary J. Nutt.

Publisher Reading, Mass. : Addison-Wesley, C1997.

Author Silberschatz, Abraham.

Main Title Operating System Concepts / Abraham Silberschatz, Peter Baer Galvin.

Edition 6th Ed.

Publisher Reading, Mass. : Addison Wesley Longman, C1998.

Notes

The second problem has been overcomes over the years through the technological improvement resulted in faster I/O devices. But CPU speed increased even faster. Therefore, the need was to increase the throughput and resource utilization by overlapping I/O and processing operations. Dedicated I/O processors, peripheral controllers brought a major development.

The development of Direct Memory Access(DMA) chip Was a major achievement, which directly transfer the entire block of data from its own memory buffer to main memory without intervention of CPU .DMA can transfer data between high speed I/O devices and main memory ,while the CPU is executing. CPU requires to be interrupted per block only by DMA. Apart from DMA, there are other two approaches to improve system performance by overlapping input/output and processing. These are:

  • Buffering
  • Spooling. 1. Buffering: It is a method of overlapping input/output and processing of a single job. The idea is quite simple. After data has been read and the CPU starts operating on it, the input device is instructed to begin the next input immediately. The CPU and the input device are both busy. The CPU can begin the processing of the newly read data, while the input device starts to read the following data. Similarly, this can be done for output In this case; the CPU creates data that is put into buffer until an output device can accept it.

Now ,I will explain you the situation –“,what happens if the CPU is fast”?

  • In the case of input, the CPU finds an empty buffer and has to wait for the input device.
  • In Case of output, the CPU can proceed at full speed until, eventually all system buffers are full .Then the CPU waits for the output device. This situation occurs with input/output bound jobs where the amount of input/output relation to computations very high. Since the CPU is faster than the input/ output device, the speed of execution is controlled by the input/ output device, not by the speed of the CPU. 2. Spooling: It stands for simultaneous peripheral operation on line. It is essentially use the disk as a large buffer for reading and for storing output files as shown in the figure.

Spooling allows CPU to overlap the input of one job with the computation and output of other jobs. Even in a simple system, the spooler may be reading the input of one job while printing the output of a different job. Compared to buffering approach spooling is better. Multi-Programming Buffering and spooling improve system performance by overlapping the input, output and computation of a single job, but both of them have limitations. A single user cannot always keep CPU or I/O devices busy at all times. Multiprogramming offers a more efficient approach to increase system performance. It refers to a computer system’s ability to support more than one process (program) at the same time. Multiprocessing operating systems enable several programs to nm concurrently. This is a kind of parallel processing. More number of programs competing for system resources which lead to better utilization of system resources. The idea is implemented as follows. The main memory of a system contains more than on program as shown in the figure.

Multiprogramming The operating system picks one of the programs and start executing. During execution process program 1 may need some I/

O operation to complete. In a sequential Execution environment, the CPU would sit idle. In a Multiprogramming system, operating system will simply switch over the next program. When that program needs to wait for some I/O operation, it switches over to program 3 and so OIL if there is no other new program left in the main memory, the CPU will pass its control back to the previous programs.

Compared to operating system which supports only sequential execution, multiprogramming system requires some form of CPU and memory management strategies.

With each new generation of operating systems, you are introduced to new ways of thinking about how our computers work. To simplify things for the user, you must deploy a consistent interface in which they can do their work. It is equally important to extend this consistency to programmers, so they too can benefit. As an operating system ages, it gradually becomes burdened with a plethora of interfaces which break the simplicity of its original architecture. UNIX originally followed the “everything is a file” mantra, only to lose sight of that design with numerous task- specific APIs for transferring files (FTP, HTTP, RCP, etc.), graphics (X11, svgalib), printers (lp, lpr), etc. Plan 9, introduced in 1989, and demonstrated how even a GUI can be represented as a set of files, revitalizing the “everything is a file” idea.

Let us discuss the Types of an Operating System

1. Batch Operating System:

As discussed earlier during batch processing environment it requires grouping of similar jobs which consist of programs, data and system commands.

The suitability of this type of processing is in programs with large computation time with no need of user interaction/involvement. Some examples of such programs include payroll, forecasting, statistical analysis and large scientific number crunching programs., Users are not required to wait while the job is being processed. They can submit their programs to operators and return later to collect them.

But it has two major disadvantages:

  • Non-interactive environment
  • Off-line debugging

Non-interactive environment: There are some difficulties with a batch system from the point of view of programmer or user. Batch operating systems allow little or no interaction between users and executing programs. The turn around time taken between job submission and job completion in batch operating system is very high. Users have no control over intermediate results of a program. This type, of arrangement does not create flexibility in software development.

The second disadvantage with this approach is that programs must be debugged which means a programmer cannot correct bugs the moment it occurs.

Process scheduling (i.e. allocation strategy for a process to a processor), memory management file management and I/O management in batch processing are quite simple.

Jobs are typically processed in the order of submission, that is, in the first come, first served basis.

Memory is usually divided into two areas. One of them is permanently fixed for containing operating system routines and the other part contains only user programs to be executed; when one Program is over, the new program is loaded into the same area. Since there is only one Program in the execution at a time, there is no competition for 110 devices, therefore, allocation and de- allocation for 1/0 devices is very trivial. Access to files is also serial and there is hardly a need of Protection and file access control mechanism.

2. Multiprogramming Operating System : Multiprogramming operating systems compared to batch operating systems are fairly sophisticated. As illustrated in figure 5, multiprogramming has a significant potential for improving system throughput and resource utilization with very minor differences. Different forms of multiprogramming operating system are multitasking, multiprocessor and multi-user operating systems. In this section, we will briefly discuss the main features and functions of these systems. Multitasking Operating Systems: A running state of a program is called a process or a task. A multitasking operating system (also called multiprocessing operating system) supports two or more active processes simultaneously. Multiprogramming operating system is operating system which, in addition to supporting multiple concurrent process (several processes in execution states simultaneously) allows the instruction and data from two or more separate processes to reside in primary memory simultaneously. Note that multiprogramming implies multiprocessing or multitasking operation, but multiprocessing operation (or multitasking) does not imply multiprogramming. Therefore, multitasking operation is one of the mechanism that multiprogramming operating system employs in managing the totality of computer related resources like CPU, memory and I/O devices. The simplest form of multitasking is called serial multitasking or context switching. This is nothing more than stopping one temporarily to work on another. If you have used sidekick, then you have used serial multitasking. While a program is running, you decide that you want to use the calculator, so you pop it and use it. When you stop using the calculator, the Program continues running. Multiuser operating system allow simultaneous access to a computer system through or more terminals. Although frequently associated with multiprogramming, multiuser operating system does, not imply multiprogramming or multitasking. A dedicated transaction processing system such as railway reservation system that hundreds of terminals under control of a single program is an example of multiuser operating system. On the other hand, general purpose time sharing systems (discussed later in this section) incorporate features of both multiuser and multiprogramming operating system. Multiprocess operation without multiuser support can be found in the operating system of some advanced personnel computers and in real systems (discussed later). Time Sharing System:

  • Controlling access so that only users in the proper authorisation are allowed to access particular resources.
  • Making the use of remote resources appear to be identical to the use of local resources
  • Providing up-to-the minute network documentation on-line.

As we said earlier, the key issue that distinguishes a network operating system from a distributed one is how aware the users are of the fact that multiple machines are being used. This visibility occurs in three primary areas; file system, protection and program execution.

File System: The important issue in file system is related to how a file is placed (accessed) on one system from another in a network. ‘Mere are two important approaches to this problem.

  • Running a special file transfer program
  • Specifying a path name

Running a special file transfer program: When connecting two or more systems together, the first issue that must be faced is how to access the rile system available on some other system. To deal with this issue user runs a special file transfer program that copies the needed remote file to the local machine, where they can then be accessed normally. Sometimes remote printing and mail is also handled this way. One of the best known examples of network that primarily support file transfer and mail via special programs is the UNIX’s UUCP (user to user control program) program and its network USENET.

Path name specification: The second approach in this direction is that programs from one machine can open files on another machine by providing a path name telling where the file is located.

A (virtual) subdirectory above the root directory provides access to remote tiles protection:

Execution Location

Program execution is the third area in which machine boundaries are visible in network operating systems. When a user or a running program wants to create a new process, where is the process created? At least four schemes have been used thus far. The first of these is that the user simply says “CREATE PROCESS” in one way or another, and specifies nothing about where. Depending on the implementation, this can be the best or worse Way to do it.

The second approach to process location is to allow users to run jobs on any machine by first logging in there. In this model, processes on different machines cannot communicate or exchange data, but a simple manual load balancing is possible. The third approach is a special command that the user types at a terminal to cause a program to be executed on a specific machine. A typical command might be remote vax4 who to run the who program on machine vax4. In M arrangement, the environment of the new process is the remote machine. In other words, if that process tries to read or write files from its current working directory, it will discover that its working directory is on the remote machine, and that files that were in the parent process’s directory are no longer present. Similarly, files written in the working directory will appear on the remote machine, not the local one. The fourth approach is to provide the “CREATE PROCESS” system call with a parameter specifying where to run the new process, possibly with a new system call for specifying the default site. As with the previous method, the environment will generally be the remote machine. In many cases, signals and other forms of inter-process communication between processes do not work properly among processes on different machines. Now let us see how file system protection and program execution are supported in distributed operating systems.

4. Distributed Operating System A distributed operating system is one that looks to its users like an ordinary centralized operating system but runs on multiple independent CPUs. The key concept here is transparency. In other words, the use of multiple processors should be invisible to the user. Another way of expressing the same idea is to say that user views the system as virtual uniprocessor but not as a collection of distinct machines. In a true distributed system, users are not aware of where their programs are being run or where their files are residing; they should all be handled automatically and efficiently by the operating system. Distributed operating systems have many aspects in common with centralized ones but they also differ in certain ways. Distributed operating system, for example, often allow programs to run on several processors at the same time, thus requiring more complex processor scheduling (scheduling refers to a set of policies and mechanisms built into the operating systems that controls the order in which the work to be done is completed) algorithms in order to achieve maximum utilisation of CPU’s time. Fault-tolerance is another area in which distributed operating systems are different. Distributed systems are considered to be more reliable than uniprocessor based system. They perform even if certain part of the hardware is malfunctioning. This additional feature, supported by distributed operating system has enormous implications for the operating system. I will tell you the Advantages of Distributed Operating Systems There are three important advantages in the design of distributed operating system: 1. Major breakthrough in microprocessor technology : Micro- processors have become very much powerful and cheap, compared with mainframes and minicomputers, so it has

become attractive to think about designing large systems consisting of small processors. These distributed systems clearly have a price/performance advantages over more traditional systems.

2. Incremental Growth : The second advantage is that if there is a need of 10 per cent more computing power, one should just add 10 per cent more processors. System architecture is crucial to the type of system growth, however, since it is hard to give each user of a personal computer another 10 per cent. 3. Reliability: Reliability and availability can also be a big advantage; a few parts of the system can be down without disturbing people using the other parts; On the minus side, unless one is very careful, it is easy for the communication protocol overhead to become a major source of inefficiency. Now let us see how file system, protection and program execution are supported in distributed operating system.

File System: Distributed operating system supports a single global file system visible from all machines. When this method is used, there is one directory for executable programs (in UNIX, it is bin directory), one password file and so on. When a program wants to read the password file it does something like

Open (*/etc/password”, READ-ONLY)

without reference to where the file is. It is upto the operating system to locate the file and arrange for transport of data as they are needed.

The convenience of having a single global name space is obvious. In addition, this approach means that operating system is free to move files around among machines to keep all the disks generally full and busy and that the system can maintain replicated copies of files if it chooses. When the user or program must specify the machine name, the system cannot decide on its own to move a file to a new machine because that would change the (user visible) name used to access the file. Thus in a network operating system, control over file placement must be done manually by the users, whereas in a distributed operating system it can be done automatically by the system itself.

Protection: In a true distributed system there is a unique UID for every user, and that UID should be valid on all machines without any mapping. In this way no protection problems arise on remote access to files; a remote access can be treated like a local access with the same UID. There is a difference between network operating system and distributed operating system in implementing protection issue. In networking operating system, there are various machines, each with its own user to UID mapping but in distributed operating system there is a single system wide mapping that is valid everywhere.

Program Execution: In the most distributed case the system chooses a CPU by looking at the processing load of the machine, location of file to be used etc. In the least distributed case, the system always run the process on one specific machine (usually the machine on which the user is logged in).

An important difference between network and distributed operating system is how they are implemented. A common way to realize a networking operating system is to put a layer of software on top of the native operating system of the individual machines. For example one could write a special library package that could intercept all the system calls and decide whether each one was local or remote. Although most system calls can be handled this way without modifying kernel (kernel is that part of operating system that manages all resources of computer). Historical Development of Operating Systems

1. Open shop

  • Each user was allocated a block of time to load and run his/her program, which was input from punch cards.
  • Debugging consisted of inspecting the internal machine states and patching them directly.
  • Device drivers (device-specific routines), functions, compilers, and assemblers had to be explicitly loaded. 2. operator-driven shop
  • The computer operator loaded the jobs and collected output.
  • Users debugged programs by inspecting a core dump, which was a hexadecimal listing of the exact contents of memory.
  • The operator could batch jobs or rearrange them according to priority, run time, etc.
  1. Offline input/output or simple batch system
  • A separate computer was used for I/O.
  • Several programs were first loaded onto tape, and then the full tape was read into the main computer.
  • Program output and dumps were written to tape, and then printed from the tape by the auxiliary computer.
  • A small resident monitor program reset the main computer after each job, interpreted some simple command language, performed some simple accounting, and did device- independent input and output.
  1. Spooling systems = multiprogrammed batch systems
  • treated separately in text (Sections 1.3.2.2 and 1.4), but were developed approximately simultaneously
  • Example: IBM OS/
  • spool: simultaneous peripheral operations on line
  • Disks were used for intermediate storage: faster than tapes and allowed jobs to be processed in any order.
  • A nucleus (or kernel) contained routines to manage processes ( jobs) and device interrupts.
  • Used interrupts to perform I/O (device tells computer when it is finished a task)
  • Device drivers included in the nucleus
  • A process (running program) requested assistance from the kernel by making a service call =system call
  • A scheduler sorted incoming jobs according to priority and processor time needed · Still used a human operator to mount data tapes needed by jobs, make some policy decisions about which jobs to run, and

Author Deitel, Harvey M., 1945-

Main Title An Introduction To Operating Systems / Harvey M. Deitel.

Edition Rev. 1st Ed.

Publisher Reading, Mass : Addison-Wesley Pub. Co., C1984.

Author Lister, A. (Andrew), 1945-

Main Title Fundamentals Of Operating Systems / A.M. Lister.

Edition 3rd Ed.

Publisher London : Macmillan, 1984.

Author Gray, N. A. B. (Neil A. B.)

Main Title Introduction To Computer Systems / N.A.B. Gray.

Publisher Englewood Cliffs, New Jersey ; Sydney : Prentice-Hall,

Author Peterson, James L.

Main Title Operating System Concepts / James L. Peterson,

Abraham Silberschatz.

Edition 2nd Ed.

Publisher Reading, Mass. : Addison-Wesley, 1985.

Author Stallings, William.

Main Title Operating Systems / William Stallings.

Edition 6th Ed.

Publisher Englewood Cliffs, Nj : Prentice Hall, C1995.

Author Tanenbaum, Andrew S., 1944-

Main Title Operating Systems : Design And Implementation /

Andrew S. Tanenbaum, Albert S. Woodhull.

Edition 2nd Ed.

Publisher Upper Saddle River, Nj : Prentice Hall, C1997.

Author Nutt, Gary J.

Main Title Operating Systems : A Modern Perspective /Gary J.

Nutt.

Publisher Reading, Mass. : Addison-Wesley, C1997.

Author Silberschatz, Abraham.

Main Title Operating System Concepts / Abraham Silberschatz, Peter Baer Galvin.

Edition 6th Ed.

Publisher Reading, Mass. : Addison Wesley Longman, C1998.

Notes

OPERATING SYSTEMS

Objective:

Dear students after learning about the different types of operating systems , lets us now discuss the different functions and services of an operating system.

Today I will discuss briefly the services and Functions of an Operating System. They are listed as follows:

  • Processor management
  • Memory management
  • Device management
  • Storage management
  • Application interface
  • User interface

With the different types of operating systems in mind, it’s time to look at the basic functions provided by an operating system.

When the power to a computer is turned on, the first program that runs is usually a set of instructions kept in the computer’s read-only memory (ROM) that examines the system hardware to make sure everything is functioning properly. This power-on self test (POST) checks the CPU, memory, and basic input-output systems (BIOS) for errors and stores the result in a special memory location. Once the POST has successfully completed, the software loaded in ROM (sometimes called firmware ) will begin to activate the computer’s disk drives. In most modern computers, when the computer activates the hard disk drive, it finds the first piece of the operating system: the bootstrap loader.

The bootstrap loader is a small program that has a single function: It loads the operating system into memory and allows it to begin operation. In the most basic form, the bootstrap loader sets up the small driver programs that interface with and control the various hardware subsystems of the computer. It sets up the divisions of memory that hold the operating system, user information and applications. It establishes the data structures that will hold the myriad signals, flags and semaphores that are used to communicate within and between the subsystems and applications of the computer. Then it turns control of the computer over to the operating system.

The operating system’s tasks, in the most general sense, fall into six categories:

  • Processor management
  • Memory management
  • Device management
  • Storage management
  • Application interface
  • User interface

While there are some who argue that an operating system should do more than these six tasks, and some operating-system vendors do build many more utility programs and auxiliary functions into

their operating systems, these six tasks define the core of nearly all operating systems. Let’s look at the tools the operating system uses to perform each of these functions. Processor Management The heart of managing the processor comes down to two related issues:

  • Ensuring that each process and application receives enough of the processor’s time to function properly.
  • Using as many processor cycles for real work as is possible The basic unit of software that the operating system deals with in scheduling the work done by the processor is either a process or a thread , depending on the operating system. It’s tempting to think of a process as an application, but that gives an incomplete picture of how processes relate to the operating system and hardware. The application you see (word processor or spreadsheet or game) is, indeed, a process, but that application may cause several other processes to begin, for tasks like communications with other devices or other computers. There are also numerous processes that run without giving you direct evidence that they ever exist. A process, then, is software that performs some action and can be controlled by a user, by other applications or by the operating system. It is processes, rather than applications, that the operating system controls and schedules for execution by the CPU. In a single- tasking system, the schedule is straightforward. The operating system allows the application to begin running, suspending the execution only long enough to deal with interrupts and user input. Interrupts are special signals sent by hardware or software to the CPU. It’s as if some part of the computer suddenly raised its hand to ask for the CPU’s attention in a lively meeting. Sometimes the operating system will schedule the priority of processes so that interrupts are masked that is, the operating system will ignore the interrupts from some sources so that a particular job can be finished as quickly as possible. There are some interrupts (such as those from error conditions or problems with memory) that are so important that they can’t be ignored. These non-maskable interrupts (NMIs) must be dealt with immediately, regardless of the other tasks at hand. While interrupts add some complication to the execution of processes in a single-tasking system, the job of the operating system becomes much more complicated in a multi-tasking system. Now, the operating system must arrange the execution of applications so that you believe that there are several things happening at once. This is complicated because the CPU can only do one thing at a time. In order to give the appearance of lots of things happening at the same time, the operating system has to switch between different processes thousands of times a second. Here’s how it happens.

LESSON-

RAM space at no cost. This technique is called virtual memory management.

Disk storage is only one of the memory types that must be managed by the operating system, and is the slowest. Ranked in order of speed, the types of memory in a computer system are:

- High-speed cache - This is fast, a relatively small amount of memory that are available to the CPU through the fastest connections. Cache controllers predict which pieces of data the CPU will need next and pull it from main memory into high- speed cache to speed up system performance. - Main memory - This is the RAM that you see measured in megabytes when you buy a computer. - Secondary memory - This is most often some sort of rotating magnetic storage that keeps applications and data available to be used, and serves as virtual RAM under the control of the operating system. The operating system must balance the needs of the various processes with the availability of the different types of memory, moving data in blocks (called pages ) between available memory as the schedule of processes dictates.

Device Management The path between the operating system and virtually all hardware not on the computer’s motherboard goes through a special program called a driver. Much of a driver’s function is to be the translator between the electrical signals of the hardware subsystems and the high-level programming languages of the operating system and application programs. Drivers take data that the operating system has defined as a file and translate them into streams of bits placed in specific locations on storage devices, or a series of laser pulses in a printer.

Because there are such wide differences in the hardware controlled through drivers, there are differences in the way that the driver programs function, but most are run when the device is required, and function much the same as any other process. The operating system will frequently assign high-priority blocks to drivers so that the hardware resource can be released and readied for further use as quickly as possible.

One reason that drivers are separate from the operating system is so that new functions can be added to the driver and thus to the hardware subsystems - without requiring the operating system itself to be modified, recompiled and redistributed.

Through the development of new hardware device drivers, development often performed or paid for by the manufacturer of the subsystems rather than the publisher of the operating system, input/output capabilities of the overall system can be greatly enhanced.

Managing input and output is largely a matter of managing queues and buffers , special storage facilities that take a stream of bits from a device, perhaps a keyboard or a serial port, hold those bits, and release them to the CPU at a rate slow enough for the CPU to cope with.

This function is especially important when a number of processes are running and taking up processor time. The operating system will instruct a buffer to continue taking input from the device, but to stop sending data to the CPU while the process using the input

is suspended. Then, when the process needing input is made active once again, the operating system will command the buffer to send data. This process allows a keyboard or a modem to deal with external users or computers at a high speed even though there are times when the CPU can’t use input from those sources. Managing all the resources of the computer system is a large part of the operating system’s function and, in the case of real-time operating systems, may be virtually all the functionality required. For other operating systems, though, providing a relatively simple, consistent way for applications and humans to use the power of the hardware is a crucial part of their reason for existing. Interface to the World Application Interface Application program interfaces (APIs) let application programmers use functions of the computer and operating system without having to directly keep track of all the details in the CPU’s operation. Let’s look at the example of creating a hard disk file for holding data to see why this can be important. A programmer writing an application to record data from a scientific instrument might want to allow the scientist to specify the name of the file created. The operating system might provide an API function named MakeFile for creating files. When writing the program, the programmer would insert a line that looks like this: MakeFile [1, %Name, 2] In this example, the instruction tells the operating system to create a file that will allow random access to its data (1), will have a name typed in by the user (%Name), and will be a size that varies depending on how much data is stored in the file (2). Now, let’s look at what the operating system does to turn the instruction into action.

  1. The operating system sends a query to the disk drive to get the location of the first available free storage location.
  2. With that information, the operating system creates an entry in the file system showing the beginning and ending locations of the file, the name of the file, the file type, whether the file has been archived, which users have permission to look at or modify the file, and the date and time of the file’s creation.
  3. The operating system writes information at the beginning of the file that identifies the file, sets up the type of access possible and includes other information that ties the file to the application. In all of this information, the queries to the disk drive and addresses of the beginning and ending point of the file are in formats heavily dependent on the manufacturer and model of the disk drive. Because the programmer has written her program to use the API for disk storage, she doesn’t have to keep up with the instruction codes, data types, and response codes for every possible hard disk and tape drive. The operating system, connected to drivers for the various hardware subsystems, deals with the changing details of the hardware - the programmer must simply write code for the API and trust the operating system to do the rest.

APIs have become one of the most hotly contested areas of the computer industry in recent years. Companies realise that programmers using their API will ultimately translate into the ability to control and profit from a particular part of the industry. This is one of the reasons that so many companies have been willing to provide applications like readers or viewers to the public at no charge. They know consumers will request that programs take advantage of the free readers, and application companies will be ready to pay royalties to allow their software to provide the functions requested by the consumers.

User Interface

A User Interface (UI ) brings structure to the interaction between a user and the computer. In the last decade, almost all development in user interfaces has been in the area of the graphical user interface (GUI), with two models, Apple’s Macintosh and Microsoft’s Windows, receiving most of the attention and gaining most of the market share. There are other user interfaces, some graphical and some not, for other operating systems.

Unix, for example, has user interfaces called shells that present a user interface more flexible and powerful than the standard operating system text-based interface. Programs such as the Korn Shell and the C Shell are text-based interfaces that add important utilities, but their main purpose is to make it easier for the user to manipulate the functions of the operating system.

There are also graphical user interfaces, such as X-Windows and Gnome, which make Unix and Linux more like Windows and Macintosh computers from the user’s point of view.

It’s important to remember that in all of these examples, the user interface is a program or set of programs that sits as a layer above the operating system itself. The same thing is true, with somewhat different mechanisms, of both Windows and Macintosh operating systems. The core operating-system functions, the management of the computer system, lie in the kernel of the operating system. The display manager is separate, though it may be tied tightly to the kernel beneath.

The ties between the operating-system kernel and the user interface, utilities and other software define many of the differences in operating systems today, and will further define them in the future.

Let us take the overview of Additional Operating System Functions

Additional functions exist not for helping the user, but rather for ensuring efficient system operations.

Resource allocation- allocating resources to multiple users or multiple jobs running the same time.

Accounting- keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics.

Protection - ensuring that all access to system resources is controlled.

Command-Interpreter System

Many commands are given to the operating system by control statements which deal with:

process creation and management

I/O handling

secondary-storage management main-memory management file-system access protection networking The program that reads and interprets control statements is called variously: control-card interpreter command-line interpreter shell (in UNIX) Its function is to get and execute the next command statement. Operating System Services Program execution – system capability to load a program into memory and to run it. I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O. File-system manipulation – program capability to read, write, create, and delete files. Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing. Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. List of Additional Operating System Functions Additional functions exist not for helping the user, but rather for ensuring efficient system operations. Resource allocation- allocating resources to multiple users or multiple jobs running at the same time.

  • Accounting- keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics.
  • Protection- nsuring that all access to system resources is controlled. In the next coming lessons we will learn these functions in detail Review Exercise:- 1) Explain briefly the general functions of an Operating **System?








  1. Briefly explain the services of an Operating System?

________________________________________________________________________**

OPERATING SYSTEMS

Objective:

Today I will describe you the Operating Systems Structure Since you all know operating system is a very large and complex software, it must be engineered carefully, if it is to be functioned properly and to be modified easily. It should be developed as a collection of several smaller modules with carefully defined inputs, outputs and functions rather than a single piece of software. Let us now examine different types of operating systems.

1. Simple Structure: This type of structures is not well defined .Such type of operating system are as :

  • Small
  • Simple.
  • Limited systems.
  • Grew beyond their scope. Example 1: MS-DOS was written to provide the most functionality in the least space.
  • not divided into modules
  • Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated. **MS-DOS Layer Structure
  1. Layered Approach:** The operating system architecture based on layered approach is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. Higher level layers uses the functions (operations) and services of only lower-level layers. An Operating System Layer Example of Windows 2000. Advantages:
  • As the system is divided into layers/modules verification and debugging of the system is easy/simple.
  • Easy to find and rectify the errors ,as we can find in which layer the error has occurred.
  • A layer need now the operations implemented by the lower layer, thus hides the existence of certain data structures, operations and hardware. Let us discuss the Difficulties for designing layered approach:
  • The layered approach involves careful definition of the layers, since the higher level layer uses the services of the lower level layer. For Example, the device driver for the secondary memory must be a lower level than memory management routines since memory management requires the ability to use the backing store.
    • This approach tends to be less efficient than others. For example, When a user program executes an I/O operation, it executes a system call that is traped to the I/O Layer, which in turn calls the memory management layer, which in turn calls the CPU- scheduling layer, which is then passed to the hardware. At each layer , the parameters may be modified, data may need to be passed, and so on. Each layer adds overhead to the system call, thus system call takes longer time when compared to a non- layered system. OS/2 Operating System Layer OS/2 is the descendant of MS-DOS adds additional features such as multitasking and dual-mode operation and other addition features. In OS/2 fewer layers with more functionality are designed, providing most of the advantages of modularized code while avoiding the difficult problems of layer definition and interaction. The advantage in this type of operating system is ,direct access to low-level facilities is not allowed, providing the operating system with more control over the hardware and more knowledge of which resources each user program is using. 3. Kernel approach: The kernel is the heart of the operating system. It is the part of operating system which directly makes interface with hardware system. When the system is booted, the kernel is read into the memory. It stays in memory while the system is running .Its main functions are:
    • To provide a mechanism for creation and deletion of processes.
    • To provide process scheduling, memory management and I/ O management.
    • To provide mechanism for synchronization of process so that processes synchronize their actions.
    • To provide mechanism for interprocess communication.
    • The UNIX operating system is based on kernel approach .It consists of two parts: Kernel - System Program :Programs and commands call on the kernel’s services. The kernel, in turn, consults its data tables as it schedules user’s programs, allocates resources to the program, and manages the low-level exchange of data with the computer’s hardware. For example, when a program requests file services, the program gives the kernel a system call. The kernel oversees the accessing of the disk drive where the file resides. The kernel gets the data and transfers it to the buffer. The data is then picked up by the parts of the kernel can be configured to accommodate variations in hardware .The kernel contains a changeable set of device drivers to accommodate numerous devices.

LESSON 4:

Making a system call. An illustration of UNIX kernel built on the system’s hardware core.

With in the kernel, individual segments of programs or routines, carry out the kernel’s work. The routines allocate memory resources, schedule CPU time, and manage access to system resources.

The kernel also monitors the system for error conditions and hardware problems. At higher level, the routines provide programs with entry points to kernel services. All UNIX programs use the kernel’s system call.

4. Virtual Machine: A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. A virtual machine provides an interface identical to the underlying bare hardware. The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.

  • The resources of the physical computer are shared to create the virtual machines.
  • CPU scheduling can create the appearance that users have their own processor.
  • Spooling and a file system can provide virtual card readers and virtual line printers.
  • A normal user time-sharing terminal serves as the virtual machine operator’s console.
  • Protection is excellent, but no sharing possible.
  • Virtual privileged instructions are trapped.
  • Useful for running different OS simultaneously on the same machine.

Virtual System Models From the user’s point of view, virtual machine can be made to appear to very similar to existing real machine or they can be entirely different. An important aspect of this technique is that each user can run operating system of his own choice.

To understand this concept, let us try to understand the difference between conventional multiprogramming system and virtual machine multiprogramming. In conventional multiprogramming processes are allocated a portion of the real machines resources. The same machine resources are distributed among several processes.

In virtual multiprogramming system, a single real machine gives an illusion of several virtual machines, each having its own virtual processor, storage and I/O devices possibly with much larger capacity. Process scheduling can be used to share the CPU and make it appear that user’s have their own processors. Virtual memory organization technique can create illusion of very large memory for program execution. Lets us now cover the advantages and disadvantages of Virtual Machines Advantages :

  • The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines.
  • A virtual-machine system is a perfect vehicle for operating- systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation.
  • The higher degree of separation between independent virtual machine aids in ensuring aids privacy and security. Disadvantages permits no direct sharing of resources.
  • The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine. 5. Client-Server Model: A trend in the modern operating system is to take moving code up into the higher layers even further, and remove as much as possible from the operating system, leaving a minimal kernel. The usual approach is to implement most of the operating system functions in user processes. To request a service, such as reading a block of a file, a user process (now known as client process) sends the request to a server process, which then does the work and sends back the answer. In this model, the kernel does all the communication between the clients and servers by splitting the operating system into parts, each of which only handles:
  • File service
  • Process service
  • Terminal service
  • Memory service. This way, each part becomes small and manageable. Furthermore, because all the servers run as user-mode processes, and not in kernel mode, they do not have direct access to the hardware. As a consequence, if a bug in the file server is triggered, the file service may crash, but this will not usually bring the whole system down.