Venkteshwar Institute Of Technology Indore

Saturday, October 16, 2010

Dynamic Loading

To obtain better memory space utilization, we can use dynamic loading. With the dynamic loading, a routine is not loaded until is it called. All routine are kept on a disk in a relocatable load format.
The main program is loaded into memory and executed. When a routine is needed to call another routine, the calling routine first checks to see whether the other routine has been loaded.
if not, then relocatable linking loader is called to load the desired routine into memory and to update the programs address table to reflect this changes.

Advantages:
I. Unused routine is never loaded
II. It does not need special support from O/S
III. O/S providing library routine to implement dynamic loading

Tuesday, October 12, 2010

CPU Scheduling


Multiprogramming:- it is defined as to have some processes at all the times, to maximize the CPU utilization.

Mono- programming:- for a uniprocessor system, there will never be more than one running process. If there are more than one running processes, the rest will have to wait until the CPU is free or rescheduled.

When a process is executes, it must wait until the completion of I/O request. The CPU would then just sit idle.

In multiprogramming, when processes have to wait, the O/S takes the CPU away from the process and gives the CPU to another process.

CPU-I/O burst cycle:

The success of the CPU Scheduling depends on the followings observed properties of processes.
Processes execution consist of
             I.      A cycle of CPU execution
          II.      I/O wait
Processes alternate back and forth between their two states. Processes execution begins with CPU burst that is followed by I/O burst. Which is followed by another CPU and then another I/O  burst.
            The last CPU burst will end with a system request to terminate execution.

Whenever a CPU becomes idle, the O/S must select one of the process from the ready queue to execute. The short-term scheduler carries the selection process.
Note: ready queue is not necessarily a first in first out (FIFO) queue.

As we consider the various scheduling algorithm, a ready queue may be implemented as
             I.      A FIFO queue
          II.      A priority queue
       III.      A tree
       IV.      Simply an unordered linked list

However, all the processes in the ready queue are linked up waiting for a chance to run on the CPU. The records in the ready are generally PCB’s of the processes.

Types of scheduling:

                           CPU scheduling decision may take place under the following circumstances:
  1. When a process switches from running state to waiting state.
Eg. I/O request, wait for the termination of one of the child.
  1. When a process switches from the running state to the ready state.
Eg. When an interrupt occurs.
  1. When a process switches from the waiting state to ready state.
Eg. Completion of I/O request
  1. When a process terminates.

Scheduling criteria:
                           Different CPU scheduling algorithms have different properties. Which algorithm to use in a particular situation, we must consider the properties of the various algorithms.

CPU utilization:

We want to keep the CPU as busy as possible. CPU utilization ranges from 0 – 100%.
In a real system, it should be 40 – 90%.

Throughput: the number of processes that are completes per unit time called the throughput.

For long processes:  one process per hours.

For short process: 10 processes per seconds.

Turnarround time: the interval from the time of submission of a process to the time of completion is the turnaround time.
Turnarround time is the sum of period spent waiting to get.

             I.      Memory
          II.      Waiting in the ready queue
       III.      Executing on the CPU
       IV.      And I/O

Waiting time: waiting time is the sum of period spends waiting in the ready queue.
Response time: a process can produce some outputs and continue computing new results while previous results are output to the user. Another measure is the time from the submission of a request until the first response is produced is called the response time.

Operating system structure


An OS provides an environment within which programs are executed. The design of a new O/S as a major task.
It is important that the goals of the system be well defined before the design begins.

System components:

We can create a system as large and complex as an only by portioning it into smaller pieces. Each of these pieces should be well- defined portion of the system, with defined inputs, outputs and function.
     Obviously, not all system has the structure but the goal of supporting the types of system components as

1)      Process management
2)      Main Memory management
3)      File management
4)      Secondary storage management
5)      I/O system
6)      Networking
7)      Protection system
8)      Command- Interpreter system

Process Management:
A program does nothing unless its instruction executed by the CPU. A process can be thought as a program in execution.
But when we explore it
             I.      A batch job is a process
          II.      A time-shared user is a process
       III.      A system task, such as pooling output to a printer also is a process.
A process needs certain resources as:
             I.      CPU time
          II.      Memory
       III.      Files and I/O Devices to accomplish the task.
These resources are either given to the process when it is created or allocated to it while it is running. CPU executes one instruction of the process after another, until the process computes. Two processes may be associated with the same program. It is common to have a single program that spawns many processes at it runs. A process is a unit of work in a system. A system consists of a collection of processes.
Some of which:
 
O/S processes: those executes system codes
User processes: executes user codes.

All these processes can potentially executes concurrently.
The operating system is responsible for the following activities in connection with process management.
             I.      Creation and deletion of both user and system process
          II.      Suspension and resumption of processes
       III.      Process synchronization
       IV.      Deadlock Handling
Main Memory Management:

Main memory is a large array of words or bytes ranging in size from hundreds of thousands to number of millions.
                          Each words and bytes has its own address. Main memory is a quickly accessible data shared by CPU and I/O devices.
The central processor reads instruction from main memory during data –fetch cycle and both read and write data from main memory during the data fetch cycle.
The main memory is a large storage device that the CPU is able to address and access directly.

The operating system is responsible for the following activities in connection with main memory management.
             I.      Keep track of which parts of memory are currently being used and whom.
          II.      Decide which processes ti be loaded into memory when memory becomes available.
       III.      Allocate and de allocates memory spaces as needed.
 
File Management:
File management is one of the visible components of an operating system.
Computers can store information on several types of disk physical media as magnetic tape, magnetic disk and optical disk. Each of these media has its own characteristics and physical organization. Each medium is controlled by a device such as disk drive, tape drive with its unique characteristics. These properties includes:

             I.      Capacity
          II.      Data transfer rate
       III.      Access methods( Sequential and Random Access)

The operating system provides the uniform logical view of information storage.

File:- file is collection of related of information defined by its creator. Commonly file represents programs.
A file consists of sequence of bits, bytes, lines or records who’s meaning are defined by their creators.

The operating system is responsible for the following activities in connection with file management.

             I.      The creation and deletion of files
          II.      The creation and deletion of directories
       III.      Manipulating files and directories
       IV.      Mapping of files onto secondary storage
          V.      Backup of files on stable storage media

Secondary storage management:

The main purpose of the computer system is to execute programs. These programs with the data they access must be in the main memory( primary memory) during execution.
But when power off, the computer system must provide sec-storage to back up main memory.

The O/S is responsible for the following activities in connection with the disk management.
             I.      Free- Space management
          II.      Storage allocation
       III.      Disk scheduling 

I/O system management:

One of the purpose of an O/S is to hide the peculiarities of specific H/W device from the user.
The O/S consists of
             I.      A memory management component including buffering, caching and spooling.
          II.      A general device driver interface
       III.      Drivers for specific H/W device

Networking:
A distributed system is a collection of processors that do not share memory, peripherals devices or a clock. Instead each processor has its own local memory and processor can communicate one another through various communication lines.
       The processors in a distributed system are connected through a communication network, which can be configured in a number of different ways.

Protection system:
If a computer system has multiple user (allow the concurrent execution of multiple processes).
Then the various processes must be protected from one another activities. For that purpose, mechanisms are provided to ensure that the files, memory segments, CPU and other resources can be operated on by only those processes that gained proper authorization from the operating system.
                    Protection refers to the mechanism for controlling the access of programs, processes or users to the resources defined by the computer system.

Command- interpreter system:

One of the most important system programs for an operating system is the command interpreter. Which is the interface between the user and the operating system.
                          Some O/S includes the command interpreter in the Kernel.
Other O/S such as Ms-Dos and UNIX, treat the interpreter as a special program that is running when a job initiated or when a user first log on.
Many command are given to the O/S by control statements. When a job is :

             I.      Started in a batch system
          II.      When a user log on to a time- sharing system

A program that reads and interprets control statements is executed automatically.
This program is some time called the control card interpreter or the command line interpreter and is known as shell.

Shell:- its function is quite simple . Get the new command and execute it.
O/S is frequently differentiated in the area of the shell with a user-friendly command interpreter.
One style user-friendly interface is the mouse-based windows as Microsoft windows.
In some of these shells, commands are typed on a keyboard and display on a screen or printing terminal with a enter key signaling that a command is complete and ready to execute.

Eg. UNIX

Monday, October 4, 2010

Evolution Of Operating System part2!!!!!

4. Personal Computer System

As hardware costs have increased, it has become feasible to have a computer system dedicated to a single user.


These types of computer systems are usually referred as a personal computer system. The I/O has changed with panels of switches and card readers replaced with typewriters like keyboard and mouse.

Line printer and cardpunches have to display screens and to small fast printer.

Personal computers appear in 1970s. They are microcomputers that considerably smaller and less expensive than the other systems.

PCs operating system therefore were neither multi user nor multi tasking. However the goal of these OS have changed with time instead of maximizing CPU and peripherals utilization
 

5.Parallel Systems

Most systems to date are single-processor systems  i.e. they have only one main CPU. However there is a trends towards multi processor systems.

Such systems have more than one processor in close communication, sharing the computer bus, the clock and sometime memory and peripherals devices.

These system are referred to as a tightly coupled systems. There are several reasons for building such systems.

Advantages

  1. Increased throughput by increasing the number of processors we get more work done in a shorter period of time.
  2. Less cost multiprocessor systems can also save money
    1. To multiple single systems, because the processor share peripherals and power supplies.
    2. In several programs are to operate on the same set of data, it is cheaper to store those data in one disk and to have all processors share them, rather than to have many computer with local disk and many copies of data.
  3. Increased reliability a functions can be distributed properly among several processors, than the failure of one processor will not halt the system, but rather will only slow it down.
     If we have 10 Processor  and  1 Processor fails Then the rest of the 9 processor must pick up the share of the work of the failed processor.Thus the entire system runs only 10% slower rather than failed together.
Systems that are designed for graceful degradation are also called fault tolerant system.


Types of Multiprocessor System


1.  Symmetric Multiprocessor System

In which each processor runs and identical copy of Os and these copies communicate with each other as needed.

2.  Asymmetric Multiprocessor System

In which each processor assigned a specific task.

A master processor controls the system and the other processors either look to the master for instruction or have predefined task.

This scheme defines a master slave relationship. The master processor schedules and allocates work to the slave processor.

6. Distributed Systems

A recent trend in computer systems is to distribute computation among several processors. In this type of systems, the processors do not share memory or a clock instead each has its own local memory.

The processors communicate with each other through various communication lines, such as high-speed buses or telephone lines.

These systems are usually referred to as a loosely couples systems or distributed system.

Advantages

 1.  Resource sharing (remote access)


If a number of different sites are connected to one another, that a user at one site may be able to use resources of another sites.

2.  Computation speed up

If a particular computation can be partitioned into a number of sub-computations that can run concurrently, then distributed system may allow us to distribute the computation among various sites, to run that computation concurrently.

3. Reliability
If one site fails in a distributed system, the remaining site can potentially continue operating.
   
4.Communication
There are many instances in which programs needs to exchange data with one other. When many sites connected to one another by a communication network, the processes at different site have the opportunity to exchange information.
                              Users may initiate file transfer or communicate with one another via e-mail. A user can send mail to another user at the same site or at a different site.

8.Real Time System
Another form of a special purpose OS is the real time system.
A real time OS has well defined , fixed time constraints. Processing must be done within the defined constraints, or the system will fail.
                                                            A time sharing system, where it is desirable to respond quickly, or to a batch system, where there may be no time constraints at all.
Real time system is used when they’re all rigid time requirements on the operation of a process or the flow of data and is often used as a control device in dedicated application. Sensor brought data and possibly adjusts the controls to modify the sensor input.

Examples:
Scientific experiments, Medical Imaging System, Industrial Control System , Space Experiments.

Evolution of operating system!!

  1. Simple batch system
  2. Multiprogrammed batch system
  3. Time Sharing system
  4. Personal Computer system
  5. Parallel system
  6. Distributed system
  7. Real Time System
1.  Simple batch system:
In early ages of computers operating system was fairly simple. Its main task was to transfer control automatically from one job to the next.
                                   To speed up processing jobs with similar needs were batched together and run through the computer as a group. Thus, the programmers would leave their programs with the operators. The operators would sort programs into batches with similar requirements and run each batch.

The output from the each job would be sent back to the appropriate programmers.

A batch operating system normally reads a stream of separate job. It each with its own control cards that predefines what the job does. When the job is completed its output usually printed on line printer.

The main feature of a batch system is the lack of interaction between the user and the job while the job is executing.

Note

 The delay between the job submission and job completion called turn around time. In this execution environment the CPU is often ideal because of speed of mechanical i/o devices are slower than electronic devices.

Even a slow CPU in the range of micro seconds can executes 1000 instructions per seconds and a fast card reader on the other hand might reads 1200 cards/minutes.

To improve its performance we use the technique spooling.
When a job is executed, the operating system is satisfies its request for card reader input by reading from the disk. Similarly when the job request 

2. Multiprogrammed Batch Systems
 
Spooling provides an important data structure as a job pool.

A pool of jobs on disk allows the operating system to select, which job to run next to increase CPU utilization.

When jobs come in directly on cards or even on magnetic tape, it is not possible to run job in a different order. Jobs must be run sequentially or FCFS method.

In a multiprogramming system, the OS simply switches to and executes another jobs. When that job needs to wait, the CPU switched to another job and so on.

As long as there is always some jobs to execute and the CPU will never be ideal.

Advantages of Multiprammed Batch System

  1. Waiting time is very less.
  2. Efficient use of memory and I/O devices.
  3. Increased CPU utilization.
  4. Higher throughput.
3. Time-Sharing System
Multiprogrammed Batch System provides an environment where the various system resources as CPU, Memory and I/O devices are utilized efficiently.

 Difficulties with the Batch System from the User Point of View

User cannot interact with the job when it is executing, the user must setup the control cards to handle all possible outcomes.

In multiple jobs, subsequent steps may depend on the result of: -

  1. The running of a program may depend on successful completion. It can be difficult to define completely what to do in all cases.
  2. Another difficulty, that programmer cannot modify a program as it executes.

Time Sharing or Multi Tasking is logical extension of multiprogramming. Multiple jobs are executed by the CPU switching between them, but the switches occurs so frequently that the users may interact with each program while it is running.

Time sharing systems were developed to provide interactive use of a computer system at a reasonable cost. A time shared OS uses CPU scheduling and multiprogramming to provide each user with a small portion of a memory.

A program that is loaded into memory and is executing is referred as a process.


Operating system services

An operating system provides an environment for the execution of programs. The O/S provides certain services to program and to the user of those programs.
These O/S services are provided for the convenience of the programmers to make the programming task easier.
 

Program execution:
The system must be able to load a program into memory and to run it. The program must be able to end its execution, either normally or indicating error.

I/O operation:
A running program may require I/O. this I/O may involve a file or an I/O device. For efficiently and protection users usually cannot control I/O device directly. Therefore the O/S must provide some means to do I/O.

File system management:

The file system is of particular interest. It should be obvious that programs need to read and write files. They also need to create and delete files by names.

Communication:

There are many circumstances in which one process needs to exchange information with another process. There are two major ways in which communication can occurs.
             I.      Processes executing on the same computer
          II.      Processes executing on different computer system that are tied together by a computer network.

Communication may be implemented via a shared memory, or by the technique of message passing, in which packets of information are moved between processes by the O/S.

Error Detection:

The o/S constantly needs to be aware of possible errors. Errors may occurs in the:
             I.      CPU
          II.      Memory H/W (memory error, power failure)
       III.      I/O devices (connection failure on a network, lack of paper in the printer)
       IV.      In the user program (illegal memory location, too use of CPU time)

For each types of error, the O/S should take the appropriate action to ensure correct and consistent computing.

Resource Allocation:

When there are multiple users or multiple jobs running at the same time, resources must be allocated to each of them.
The O/S manages many different types of resources.
             I.      Some may have special allocation code.
   Eg. CPU cycle, main memory, file storage
          II.      Some may have more general request
    Eg. I/O devices

O/S has CPU scheduling routines that take into

             I.      Speed of the CPU
          II.      Jobs must be executed
       III.      No of registers available

Accounting:

We want to keep track of which user uses how much and what kinds of computing resources.
This record keeping may be for accounting or simply for accumulating usage statistics.
Usage statistics may be valuable tools for researchers who wish to reconfigure the system to improve computing services.

Protection:
When several disjoints processes executes concurrently it should not be possible for one process to interface with the  others, or with the O/S system itself.
Protection involves ensuring all access to system resources is controlled.
Securities of the system from outsiders is also important. Usually by mean of password to be allowed access to the resources. If a system is to be protected and secure, precaution must be through out it.
 

Operating system

Operating system is a program that acts as an intermediately between a user of a computer and the computer hardware.


Purpose:
The purpose is to provide an environment in which user can execute their program.
  1. Primary goal is to make computer system convenient to use.
  2. To use the computer hardware in effective manner.
Components of Operating system:

A computer system can be divided into four components.
  1. Hardware
  2. Operating system
  3. Application Program
  4. Users 

Hardware: (provides the basic computing resources)

  •              I.      Central Processing Unit (CPU)
              II.      Memory
           III.      I/O Devices


Application Program:
Operating system controls and coordinates the use of H/W among the various application programs for the various users.


             I.      Compiler


          II.      Data base system

       III.      Games and Business Programs



Resources Allocator:
Computer system has many resources


             I.      H/W and S/W

          II.      CPU Time


       III.      Memory Space

       IV.      File Storage Device


          V.      I/O Devices

Operating system acts as the manager of these resources and allocates them to specific program and users to perform specific task.

Control Program:

A control program controls the execution of user program to prevent errors and improper use of the computer.