Sei sulla pagina 1di 192

Handout: Fundamentals of Computer Technology

Version: FCT/Handout/1107/1.0 Date: 08-11-07

Cognizant 500 Glen Pointe Center West Teaneck, NJ 07666 Ph: 201-801-0233 www.cognizant.com

Handout - Fundamentals of Computer Technology

TABLE OF CONTENTS
Introduction ...................................................................................................................................7 About this Document ....................................................................................................................7 Target Audience ...........................................................................................................................7 Objectives .....................................................................................................................................7 Pre-requisite .................................................................................................................................7 Session 1: Introduction to Computer Fundamentals .................................................................8 Learning Objectives ......................................................................................................................8 Computer Generations .................................................................................................................8 A typical Computer System ........................................................................................................11 Computer Types .........................................................................................................................15 What is an Operating System .....................................................................................................15 OS Objectives .............................................................................................................................16 OS Functions ..............................................................................................................................17 Evolution of OS ...........................................................................................................................18 Types of Operating Systems ......................................................................................................22 OS Layers ...................................................................................................................................25 Summary ....................................................................................................................................25 Test your Understanding ............................................................................................................25 Session 2: Introduction to Computer Networking ....................................................................27 Learning Objectives ....................................................................................................................27 Introduction to Computer Networks ............................................................................................27 Why Networking..........................................................................................................................27 Network Goals ............................................................................................................................28 Components of a Computer Network .........................................................................................29 Network Types ............................................................................................................................31 Classification of computer networks ...........................................................................................32 Network Services ........................................................................................................................38 Summary ....................................................................................................................................41 Test your Understanding ............................................................................................................41 Session 3: CPU Structure ............................................................................................................42 Learning Objectives ....................................................................................................................42 Major Components of CPU.........................................................................................................42
U

Page 2 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Overview of CPU Behavior .........................................................................................................43 Instruction Execution ..................................................................................................................44 Instruction types..........................................................................................................................45 Fetching a word from Memory ....................................................................................................45 Storing Word in Memory .............................................................................................................46 Register Transfers ......................................................................................................................46 Arithmetic Logic Unit ...................................................................................................................46 Register Gating ...........................................................................................................................47 Timing of Data Transfers ............................................................................................................47 Control Unit .................................................................................................................................47 Hardwired Control .......................................................................................................................48 Micro programmed Control .........................................................................................................48 Control Sequence .......................................................................................................................49 Microinstructions .........................................................................................................................50 Intel, AMD ...................................................................................................................................50 Summary ....................................................................................................................................51 Test your Understanding ............................................................................................................51 Session 4: Operating Systems Management.............................................................................52 Learning Objectives ....................................................................................................................52 Operating System Components .................................................................................................52 Processes and Process management ........................................................................................54 Process States............................................................................................................................55 Process Control Block (PCB) .....................................................................................................56 Scheduling: A Few Scenarios.....................................................................................................59 Process Scheduling Algorithms ..................................................................................................60 Session 5: Operating Systems Management.............................................................................66 Learning Objectives ....................................................................................................................66 Memory Management .................................................................................................................66 Memory hierarchy .......................................................................................................................67 Memory Organization .................................................................................................................70 Placement Algorithm ..................................................................................................................74 Page Replacement Algorithms ...................................................................................................82 File System Management ...........................................................................................................84 File Operations ...........................................................................................................................86 Summary ....................................................................................................................................96 Session 6: I/O Interfacing ............................................................................................................97

Page 3 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Learning Objectives ....................................................................................................................97 Overview .....................................................................................................................................97 Accessing I/O Devices ................................................................................................................98 Hardware to connect I/O Device to BUS ....................................................................................98 Implementation of I/O operations ...............................................................................................99 Programmed I/O .........................................................................................................................99 Isolated I/O ...............................................................................................................................100 Interrupt Driven I/O .................................................................................................................100 How to achieve better Speed of Execution? ............................................................................101 Direct Memory Access (DMA) ..................................................................................................101 Block diagram of a computer with Input-Output Processor ......................................................103 I/O Management .......................................................................................................................103 MS-DOS ...................................................................................................................................104 Windows Family........................................................................................................................105 Summary ..................................................................................................................................105 Session 7: Network Protocols and Cognizant Network System............................................106 Learning Objectives ..................................................................................................................106 Protocol Definition.....................................................................................................................106 The Open Systems Interface (OSI) Reference Model..............................................................107 The OSI Layers.........................................................................................................................108 The Application Layer ...............................................................................................................110 The Presentation Layer ............................................................................................................111 The Session Layer ....................................................................................................................112 The Transport Layer .................................................................................................................112 The Network Layer ...................................................................................................................117 The Data Link Layer .................................................................................................................119 The Physical Layer ...................................................................................................................121 Introduction to TCP/IP ..............................................................................................................122 The Four Layers of TCP/IP .......................................................................................................123 Transmission Control Protocol .................................................................................................126 Cognizant Network System ......................................................................................................137 Summary ..................................................................................................................................138 Session 8: Internetworking and Network Management..........................................................139 What Is an Internetwork?..........................................................................................................139 Repeaters: ................................................................................................................................140 Bridges......................................................................................................................................141 Types of Bridges .......................................................................................................................143

Page 4 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Transparent Bridge ...................................................................................................................144 Routers .....................................................................................................................................145 Gateways ..................................................................................................................................147 What is a network firewall? .......................................................................................................148 Why would I want a firewall? ....................................................................................................148 What can a firewall protect against?.........................................................................................148 What can't a firewall protect against? .......................................................................................149 What about viruses? .................................................................................................................149 Network Management ..............................................................................................................151 Summary: .................................................................................................................................152 Session 9: Advanced Computing Concepts A Survey ........................................................153 Learning Objective ....................................................................................................................153 Pipelining ..................................................................................................................................153 Effect of operation that takes more than 1 clock cycle .............................................................155 Why cant the pipeline operate at its maximum theoretical speed? .........................................155 Parallelism ................................................................................................................................155 Flynns Classification ................................................................................................................156 Client Server ..........................................................................................................................158 Architecture...............................................................................................................................159 Client Server Model ..................................................................................................................159 Server .......................................................................................................................................160 Server Types ............................................................................................................................160 File Server ................................................................................................................................162 Compute Server........................................................................................................................162 Database Server .......................................................................................................................162 Communication Server .............................................................................................................163 Multiprocessor Organization .....................................................................................................163 Summary ..................................................................................................................................164 Test your Understanding ..........................................................................................................164 Session 10: Case Study UNIX ................................................................................................165 Learning Objectives ..................................................................................................................165 What is UNIX? ..........................................................................................................................165 Types of UNIX ..........................................................................................................................165 Layered Architecture ................................................................................................................166 Kernel .......................................................................................................................................166 UNIX System Calls ...................................................................................................................167 UNIX User Interface .................................................................................................................168

Page 5 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology UNIX Shell ................................................................................................................................168 Basic Form of UNIX Commands ..............................................................................................170 UNIX Process Management .....................................................................................................173 UNIX CPU Scheduling ..............................................................................................................177 UNIX Memory Management .....................................................................................................178 UNIX File System .....................................................................................................................179 UNIX I/O Subsystem ................................................................................................................181 UNIX IPC ..................................................................................................................................182 Network Support in UNIX .........................................................................................................184 Session 11: Case Study WINDOWS XP .................................................................................185 Learning Objectives ..................................................................................................................185 Windows XP .............................................................................................................................185 History.......................................................................................................................................186 Design Principles ......................................................................................................................186 System Components Kernel ................................................................................................186 Kernel Process and Threads ...............................................................................................186 Kernel Scheduling ................................................................................................................187 Executive Object Manager ...................................................................................................187 Executive Virtual Memory Manager .....................................................................................187 Executive Process Manager ................................................................................................188 Executive Local Procedure Call (LPC) Facility ....................................................................188 Executive I/O Manager ........................................................................................................188 Executive Security Reference Monitor .................................................................................188 File System ...............................................................................................................................189 File System Security ............................................................................................................189 Networking ................................................................................................................................189 Summary ..................................................................................................................................190 Test Your Understanding..........................................................................................................190 References ..................................................................................................................................191 Websites ...................................................................................................................................191 Books ........................................................................................................................................191 STUDENT NOTES: ......................................................................................................................192

Page 6 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Introduction

About this Document This module discusses Fundamental concepts of Computer system, Operating System and Networks Target Audience Entry Level Trainees Objectives Get an Insight into the Computer Technologies Obtain Basic Knowledge of Operating Systems Understand Computer Networking Principles Pre-requisite This module requires that the trainee meet the following prerequisites: Basic knowledge of Computer Fundamentals and Digital Electronics Basic Structure of Computer Hardware and Software

Page 7 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 1: Introduction to Computer Fundamentals

Learning Objectives After completing this chapter, you will be able to: List various Generations of Computers Explain a typical Computer System Differentiate Types of Computers Define an Operating System Identify Operating Systems available today Computer Generations The Computer Evolution over the period of time has resulted in development of various generations and devices. Different technologies have been used for manufacturing the computer hardware. Based on the component technology, computers are classified into five generations. Each computer generation is characterized by a major technological development that fundamentally changed the way computers operate, architectural structure, resulting in increasingly smaller, cheaper, more powerful and more efficient and reliable devices. The study of these aspects, helps one to distinguish between past and the present dimensions of the computer.

First Generation Computers (1937-1953) These computers were pure hardware machines which contained no Operating System. Programming was done in the machine language which differs from one computer to another. The user deals with several switches in the front panel to start, run or halt the computer. The internal status of the computer is displayed on several lights on the front panel. Invariably only a designer or programmer could operate the computer due to the complexities involved. These machines used electronic switches, in the form of vacuum tubes, instead of electromechanical relays. In principle, the electronic switches would be more reliable, since they would have no moving parts that would wear out, but the technology was still new at that time and the vacuum tubes were comparable to relays in reliability. Electronic components had one major benefit, they could "open" and "close" about 1,000 times faster than mechanical switches. The earliest attempt to build an electronic computer was by J.V. Atanasoff, a Professor of Physics and Mathematics at Iowa State, in 1937. Atanasoff set out to build a machine that would help his graduate students solve systems of partial differential equations.

Page 8 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology By 1941, he and his graduate student Clifford Berry had succeeded in building a machine that could solve 29 simultaneous equations with 29 unknowns. However, the machine was not programmable, and was more of an electronic calculator. Electronic Numerical Integrator and Calculator(ENIAC) was the first general purpose electronic computer. It was an enormous machine weighing about 30 tons and containing more than 18,000 vacuum tubes.

Second Generation Computers (1954-1962) Transistor Invention by Bell Labs was a boon to second generation computers. Smaller in size and also consumes less power. Several companies such as IBM, NCR, RCA etc. quickly introduced transistor technology which also improved reliability of computers. Instead of wiring circuits, photo printing was used to build Printed Circuit Boards (PCB). Both computer production and maintenance of computers became easier. The second generation saw several important developments at all levels of computer system design, from the technology used to build the basic circuits to the programming languages used to develop scientific applications Electronic switches in this era were based on discrete diodes and transistors technology with a switching time of approximately 0.3 microseconds. The first machines to be built with this technology include TRADIC (TRAnsistor DIgital Computer) at Bell Laboratories in 1954 and TX-0 at MIT's Lincoln Laboratory. Memory technology was based on magnetic cores, which could be accessed in random order, as opposed to mercury delay lines, in which data was stored as an acoustic wave that passed sequentially through the medium and could be accessed only when the data moved by the I/O interface. Important innovations in Computer Architecture were index registers for controlling loops and floating point units for calculations based on real numbers. Floating-point operations were performed by libraries of software routines in early computers, but were done in hardware in second generation machines.

Third Generation Computers (1963-1972) Integrated Circuit(IC) chip Invention is a great event for electronics field giving rise to microelectronics. IC has multiple advantages over discrete components: smaller size, higher speed, lower hardware cost, improved reliability etc. Digital computer design became more attractive and interesting. The use of computers in a continuous processing and manufacturing sectors such as petroleum refining and electrical power distribution became popular. The computer families by leading companies such as IBM, UNIVAC, HP,ICL and DEC dominated the computer industry. The third generation brought huge gains in computational power: Integrated Circuits, or ICs (semiconductor devices with several transistors built into one physical component), semiconductor memories instead of magnetic cores, microprogramming for efficiently designing complex processors, pipelining and other forms of parallel processing techniques.
Page 9 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Operating System software allowed efficient sharing of a computer system by several user programs. The first ICs were based on Small-Scale Integration (SSI) circuits, which had around 10 devices per circuit (or "chip"), and evolved to the use of Medium-Scale Integrated (MSI) circuits, which had up to 100 devices per chip. Multilayered printed circuits were developed and core memory was replaced by faster, solid state memories. Computer designers began to take advantage of parallelism by using multiple functional units, overlapping CPU and I/O operations, and pipelining (internal parallelism) in both the instruction stream and the data stream. In 1964, Seymour Cray developed the CDC 6600, which was the first architecture to use functional parallelism. By using 10 separate functional units that could operate simultaneously and 32 independent memory banks, the CDC 6600 was able to attain a computation rate of 1 million floating point operations per second (1 MFlops).

Fourth Generation Computers (1972- 1984) Computers built after 1972, called Fourth Generation computers were based on LSI (Large Scale Integration) of circuits (such as microprocessors) - typically 500 or more transistors on a chip. Later developments included VLSI (Very Large Scale Integration) integrated circuits typically 10,000 transistors. Modern circuits may now contain millions of components. This has led to very small, yet incredibly powerful computers. The fourth generation is generally viewed as running right up until the present, since, although computing power has increased, the basic technology has remained virtually the same. By the late 1990s many people began to suspect that this technology was reaching its limit, further miniaturization could only achieve so much. 1 GB RAM chips have circuitry so small that it can be measured in terms of atoms. Such small circuits pose many technical problems like the increase in temperature and radiation.

Fifth Generation Computers (1984-1990) The use of VLSI and artificial intelligence concept is used in this generation of computers. Expert systems, pattern recognition, voice recognition, signature capturing and recognition, microprocessor controlled robots etc. are some of the sophisticated developments in the field of computers. They will be able to take commands in a audio visual way and carry out instructions. Many of the operations which require low human intelligence will be performed by these computers. The development of the next generation of computer systems is characterized mainly by the acceptance of parallel processing. Until this time, parallelism was limited to pipelining and vector processing, or at most to a few processors sharing jobs.

Page 10 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The fifth generation saw the introduction of machines with hundreds of processors that could all be working on different parts of a single program. The scale of integration in semiconductors continued at an incredible pace - by 1990, it was possible to build chips with a million components - and semiconductor memories became standard on all computers. Other new developments were the widespread use of Computer Networks and the increasing use of single-user workstations. Large scale parallel processing was employed in commercial products. A typical Computer System We will see a real life situation. In a college, Principal is the person who instructs the others to do their corresponding work. But he will not do all the work by himself. The fig. shows the structure of above. Government or Management

Principal

Teaching& Non Teaching Staff

Student Fig 1.1: College Management Hierarchy

In the above structure, principal is instructed by the management or government. Without any knowledge of the management or government he does not take any action. Principal has to depend upon the management or government. But principal has to instruct the staff working under him to carryout the administrative activity in a satisfactory manner. The staff members can interact with the students and vice-versa.

Page 11 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology From the above example we know what the work of principal is. Now we will compare this with the computer system. A Computer system may be divided into four major components 1. Hardware( Principal ) 2. Operating System (Management) 3. Application Programs ( Teaching & Non- Teaching Staff ) 4. Users (Students)

User 1

User 2

User 3

...

User n

Compiler

Assembler

Text Editor

Database System

Application Programs

Operating System

Computer Hardware

Fig 1.2: Abstract View of the Components of a Computer System

The computer is an electronic machine with built-in intelligence to execute the instructions. A Computer System is an arrangement of hardware and software. The term hardware generally refers to the electronic circuits in the computer. The main hardware modules are keyboard, CRT monitor, Disk Drive, Printer, and other peripherals. In practice, the term hardware is used for all physical items in a computer including mechanical, electrical and electronic assemblies and components. The Electrical components are Motors, power supplies, Transformers, Relays, Fans, PCBs, Wires, and Cables. The Mechanical components are Switches, Panels, Covers, Chassis, Nuts and Screws. The Electronic components are Resistors, Capacitors, Coils, Diodes, Transistors, ICs, Crystals, LED, Speakers, and CRT. Fig 1.3 Shows Components of a Typical Computer System

Page 12 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 1.3: Components of a Typical Computer System

Any program is software. The software is developed to solve a problem and it controls the hardware when the program is executed. The hardware can be seen visually whereas the software is a logical action plan that is not visually noticeable. Computer Software is classified into two types: Application and System Software. An application program is a program solving users problems. Typical examples are: Payroll program, Inventory control program, tax calculator, class room scheduler, library management software, train reservation software, billing software and game programs. A system program is a program which helps in efficient utilization of the system by other programs and the users. It is generally developed for a given type of computer and it is not concerned with specific application or user. Operating system and compiler are examples of system software.

Page 13 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

M a CPU i n M e Cache m o Bus Interface Unit r y

Secondary Memory

Video Monitor

Keyboard

Communication Network

I/O Devices IO expansion

Hard Disk Control

Video Control

Keyboard Control

Network Control

slots

I/O (local) bus Peripheral I/O Interface control unit

System Bus

Fig 1.4: A Typical Personal Computer System

Another way of looking into a typical personal computer is as shown Fig 1.4. At the core of this computer is a single-chip microprocessor such as the Pentium Dual Core or AMD. The microprocessors internal (micro) architecture usually contains a number of speedup features not found in its earlier version. A system bus connects the microprocessor to a main memory based on semiconductor DRAM technology and to an I/O subsystem. The widely used I/O bus (peripheral bus) used in computers of all sizes, provides a shared data path between the Central Processing Unit (CPU) and peripheral controllers, such as network, display, SCSI and RAID cards.

A separate I/O bus, such as the industry standard PCI Express (Peripheral Component Interconnect Express) local bus, connects the I/O devices and their controllers. The I/O bus is linked to the system bus via a special bus-to-bus control unit sometimes referred to as a Bridge. The I/O devices of a personal computer include the traditional keyboard, a TFT-based or flat-panel video monitor, USB and disk drive units for the hard and flexible (floppy) disk storage devices that constitute secondary memory. More recent additions to the I/O devices include drive units for DVD (Digital Versatile Disk), which have extremely high capacity and allow sound and video images to be stored and retrieved efficiently. Other common audiovisual I/O devices in personal computers are microphones, loudspeakers, LCD projectors, video scanners, and webcam which are referred to as multimedia equipments.

Page 14 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Computer Types Mainframe: Mainframes are computers used mainly by large organizations for critical applications, typically bulk data processing such as census, industry/consumer statistics, ERP, financial transaction processing. They require large power and storage capacity.

Desktop: Is a personal computer made for use on a desk in an office or home. Desktop systems are normally set up in a permanent location. Most desktops offer more power, storage and versatility for less cost than their portable counter parts. Desktops are currently the most affordable computers; Nearly all desktop computers are modular, with components that can easily be replaced or upgraded.

Portable: Is a computer that is designed to be moved from one place to another. Also called notebooks/laptops - are portable computers that integrate the display, keyboard, a pointing device or trackball, processor, memory and hard disk drive all in a battery-operated package slightly larger than an average hardcover book.

Workstation: A desktop computer that has a more powerful processor, additional memory and enhanced capabilities for performing a special group of tasks, such as 3D Graphics or game development.

Supercomputer: This type of computer usually costs hundreds of thousands or even millions of dollars. Although some supercomputers are single computer systems, most are comprised of multiple high performance computers working in parallel as a single system. Supercomputers are used for the large-scale numerical calculations required in applications such as weather forecasting and aircraft design and simulation. The best-known supercomputers are built by Cray Supercomputers. What is an Operating System An Operating System is a software program or set of programs that acts as a central control program for the computer. It mediates access between physical devices (such as keyboard, mouse, monitor, disk drive or network connection) and application programs (such as word processor, World-Wide Web browser or electronic mail client).

An operating system (sometimes abbreviated as "OS") is the program that, after being initially loaded into the computer by a boot program, manages all the other programs in a computer. The other programs are called applications or application programs. The application programs make use of the operating system by making requests for services through a defined Application Program Interface (API).

Page 15 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A set of routines, protocols, and tools for building software applications, which provides all the building blocks for the programmer to put together. Most operating environments, such as MSWindows, provide an API so that programmers can write applications consistent with the operating environment. Although APIs are designed for programmers, they are ultimately good for users as their similar interfaces make it easier for users to learn new programs.

In addition, users can interact directly with the operating system through a user interface such as a command language or a graphical user interface (GUI). The basic resources of a computer system are provided by its hardware, software and data. The operating system provides the means for the proper use of these resources in the operation of the computer system. It simply provides an environment within which other programs can do useful work. We can view an operating system as a resource allocator. A computer system has many resources (hardware and software) that may be required to solve a problem: CPU time, memory space, files storage space, input/output devices etc.

The operating system acts as the manager of these resources and allocates them to specific programs and users, as necessary for their tasks. An operating system is a control program i.e, it acts as a controller. This program controls the execution of user programs to prevent errors and improper use of the computer. OS Objectives The primary goal of an operating system is convenience for the user. A secondary goal is the efficient operation of a computer system. This goal is particularly important for large, shared multiuser systems. It is known that sometimes these two goals, convenience and efficiency, are contradictory.

Fig 1.5: Operating System Interfaces

Page 16 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

OS Functions A computers operating system (OS) is a group of programs designed to serve two basic purposes: To control the allocation and use of the computing systems resources among the various users and tasks, and. To provide an interface between the computer hardware and the programmer that simplifies and makes feasible the creation, coding, debugging, and maintenance of application programs.

An Operating System do the following: Facilitate creation and modification of program and data files through an editor program, Provide access to compilers to translate programs from high-level languages to machine language, Provide a loader program to move the complied program code to the computers memory for execution, Provide routines that handle the intricate details of I/O programming, Assure that when there are several active processes in the computer, each will get fair and non interfering access to the central processing unit for execution, Take care of storage and device allocation, Provide for long term storage of user information in the form of files, and Permit system resources to be shared among users when appropriate, and be protected from unauthorized or mischievous intervention as necessary.

An operating system performs these services for applications: In a multitasking operating system where multiple programs can be running at the same time, the operating system determines which applications should run in what order and how much time should be allowed for each application before giving another application a turn. It manages the sharing of internal memory among multiple applications. It handles input and output to and from attached hardware devices, such as hard disks, printers, and dial-up ports. It sends messages to each application or interactive user (or to a system operator) about the status of operation and any errors that may have occurred. On computers that can provide parallel processing, an operating system can manage how to divide the program so that it runs on more than one processor at a time.

All major computer platforms (hardware and software) require and sometimes include an operating system. Linux, Windows 2000, VMS, OS/400, AIX, and z/OS are all examples of operating systems.

Page 17 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Evolution of OS The History of OS is linked with the development of various computer generations. By tracing that evolution we can identify the common elements of operating systems, and see how, and why they evolved as they are now. Operating systems and computer architecture have a great deal of influence on each other. To facilitate the use of the hardware, operating systems were designed, developed and simplified.

Since operating systems have historically been closely tied to the architecture of the computers on which they run. The mapping of operating systems to computer generations is admittedly crude, but it does provide some structure where there would otherwise be none. Because the history of computer operating systems parallels that of computer hardware, it can be generally divided into five distinct time periods, called generations, that are characterized by hardware component technology, software development, and mode of delivery of computer services. The Zeroth Generation The term Zeroth Generation is used to refer to the period of development of computing, which predated the commercial production and sale of computer equipment. In particular, this period witnessed the emergence of the first electronic digital computers on the Atanasoff-Berry Computer (ABC), designed by John Atanasoff in 1940; the Mark I, built by Howard Aiken and a group of IBM engineers at Harvard in 1944; and the Electronic Numerical Integrator And Computer (ENIAC), designed and constructed at the University of Pennsylvania by Wallace Eckert and John Mauchly. Perhaps the most significant of these early computers was the Electronic Discrete Variable Automatic Computer(EDVAC), developed in 1944-46 by John von Neumann, Arthur Burks, and Herman Goldstine, since it was the first to fully implement the idea of the stored program and serial execution of instructions. The development of EDVAC set the stage for the evolution of commercial computing and operating system software. The hardware component technology of this period was electronic vacuum tubes. The actual operation of these early computers took place without be benefit of an operating system. Early programs were written in machine language and each contained code for initiating operation of the computer itself.

The First Generation, 1951-1956 The first generation marked the beginning of commercial computing, including the introduction of Eckert and Mauchlys UNIVersal Automatic Computer I (UNIVAC I) in early 1951, and a bit later, The IBM 701 which was also known as the Defense Calculator. Operation continued without the benefit of an operating system for a time. Application programs were run one at a time, and were translated with absolute computer addresses that bound them to be loaded and run from these pre assigned storage addresses set by the translator, obtaining their data from specific physical I/O device.

Page 18 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology There was no provision for moving a program to a different location in storage for any reason. Similarly, a program bound to specific devices could not be run at all if any of these devices were busy or broken down. The inefficiencies inherent in the above methods of operation led to the development of the mono programmed operating system, which eliminated some of the human intervention in running a job and provided programmers with a number of desirable functions. The OS consisted of a permanently resident kernel in main storage, and a job scheduler and a number of utility programs kept in secondary storage. User application programs were preceded by control or specification cards (in those days, computer program were submitted on data cards) which informed the OS of what system resources (software resources such as compilers and loaders and hardware resources such as tape drives and printer) were needed to run a particular application. The systems were designed to be operated as batch processing system. These systems continued to operate under the control of a human operator who initiated operation by mounting a magnetic tape that contained the operating system executable code onto a boot device, and then pushing the IPL (initial program load) or boot button to initiate the bootstrap loading of the operating system. Once the system was loaded, the operator entered the date and time, and then initiated the operation of the job scheduler program which read and interpreted the control statements, secured the needed resources, executed the first user program, recorded timing and accounting information, and then went back to begin processing of another user program, and so on, as long as there were programs waiting in the input queue to be executed. At the same time, the development of programming languages was moving away from the basic machine languages; first to assembly language, and later to procedure oriented languages, the most significant being the development of FORTRAN by John W. Backus in 1956. Several problems remained, however. The most obvious was the inefficient use of system resources, which was most evident when the CPU waited while the relatively slower, mechanical I/O devices were reading or writing program data. In addition, system protection was a problem because the operating system kernel was not protected from being overwritten by an erroneous application program. Moreover, other user programs in the queue were not protected from destruction by executing programs.

The second Generation, 1956-1964 (Batch Operating Systems): The second generation of computer hardware was most notably characterized by transistors replacing vacuum tubes as the hardware component technology. In addition, some very important changes in hardware and software architectures occurred during this period. For the most part, computer systems remained card and tape-oriented systems. Significant use of random access devices, that is, disks, did not appear until towards the end of the second generation. Program processing was, for the most part, provided by large centralized computers operated under mono programmed batch processing operating systems.

Page 19 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The most significant innovations addressed the problem of excessive central processor delay due to waiting for input/output operations. Recall that programs were executed by processing the machine instructions in a strictly sequential order. As a result, the CPU, with its high speed electronic component, was often forced to wait for completion of I/O operations which involved mechanical devices (card readers and tape drives) that were order of magnitude slower. This problem led to the introduction of the data channel, an integral and specialpurpose computer with its own instruction set, registers, and control unit designed to process input/output operations asynchronously from the operation of the computers main CPU, near the end of the first generation, and its widespread adoption in the second generation. The data channel allowed some I/O to be buffered. That is, a programs input data could be read ahead from data cards or tape into a special block of memory called a buffer. Then, when the users program came to an input statement, the data could be transferred from the buffer locations at the faster main memory access speed rather than the slower I/O device speed. Similarly, a programs output could be written in another buffer and later moved from the buffer to the printer, tape, or cardpunch. What made this all work was the data channels ability to work asynchronously and concurrently with the main processor. Thus, the slower mechanical I/O could be happening concurrently with main program processing. This process was called I/O overlap. The data channel was controlled by a channel program set up by the operating system I/O control routines and initiated by a special instruction executed by the CPU. Then, the channel independently processed data to or from the buffer. This provided communication from the CPU to the data channel to initiate an I/O operation. It remained for the channel to communicate to the CPU such events as data errors and the completion of a transmission. At first, this communication was handled by polling-the CPU stopped its work periodically and polled the channel to determine if there was any massage. Polling was obviously inefficient (imagine stopping your work periodically to go to the post office to see if an expected letter has arrived) and led to another significant innovation of the second generation - the interrupt. The data, channel was now able to interrupt the CPU with a message- usually I/O complete. In fact, the interrupt idea was later extended from I/O to allow signaling of number of exceptional conditions such as arithmetic overflow, division by zero and time-run-out. Of course, interval clocks were added in conjunction with the latter, and thus operating system came to have a way of regaining control from an exceptionally long or indefinitely looping program. Towards the end of this period, as random access devices became available, tapeoriented operating systems began to be replaced by disk-oriented systems. With the more sophisticated disk hardware and the operating system supporting a greater portion of the programmers work, the computer system that users saw was more and more removed from the actual hardware - users saw a virtual machine.

Page 20 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The second generation was a period of intense operating system development. Also it was the period for sequential batch processing. But the sequential processing of one job at a time remained a significant limitation. Thus, there continued to be low CPU utilization for I/O bound jobs and low I/O device utilization for CPU bound jobs. This was a major concern, since computers were still very large (room-size) and expensive machines. Researchers began to experiment with multiprogramming and multiprocessing in their computing services called the time-sharing system. A noteworthy example is the Compatible Time Sharing System (CTSS), developed at MIT during the early 1960s.

The Third Generation, 1964-1979 (Multiprogramming and Time Sharing Systems): The third generation officially began in April 1964 with IBMs announcement of its System/360 family of computers. Hardware technology began to use integrated circuits (ICs), which yielded significant advantages in both speed and economy. Operating system development continued with the introduction and widespread adoption of multiprogramming. These systems worked by introducing two new systems programs, a system reader to move input jobs from cards to disk, and a system writer to move job output from disk to printer, tape, or cards. Operation of spooling system was, as before, transparent to the computer user who perceived input as coming directly from the cards and output going directly to the printer. The idea of taking fuller advantage of the computers data channel, I/O capabilities continued to develop. That is, designers recognized that I/O needed only to be initiated by a CPU instruction - the actual I/O data transmission could take place under control of separate and asynchronously operating channel program. Thus, by switching control of the CPU between the currently executing user program, the system reader program, and the system writer program, it was possible to keep the slower mechanical I/O device running and minimize the amount of time the CPU spent waiting for I/O completion. The net result was an increase in system throughput and resource utilization, to the benefit of both user and providers of computer services. This concurrent operation of three programs (more properly, apparent concurrent operation, since systems had only one CPU, and could, therefore executes just one instruction at time) required that additional features and complexity be added to the operating system.

The Fourth Generation, 1980 - 1994(Personal Computers and Workstations): The fourth generation is characterized by the appearance of the personal computer and the workstation. Miniaturization of electronic circuits and components continued and large-scale integration (LSI), the component technology of the third generation, was replaced by very large scale integration (VLSI), which characterizes the fourth generation. VLSI with its capacity for containing thousands of transistors on a small chip, made possible the development of desktop computers with capabilities exceeding those that filled entire rooms and floors of building just twenty years earlier.

Page 21 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip. What in the first generation filled an entire room could now fit in the palm of the hand. The Intel 4004 chip, developed in 1971, located all the components of the computer from the central processing unit and memory to input/output controls - on a single chip. In 1981 IBM introduced its first computer for the home user, and in 1984 Apple introduced the Macintosh. Microprocessors also moved out of the realm of desktop computers and into many areas of life as more and more everyday products began to use microprocessors. As these small computers became more powerful, they could be linked together to form networks, which eventually led to the development of the Internet. Fourth generation computers also saw the development of GUIs, the mouse and handheld devices.

Fifth Generation - Present and Beyond: Artificial Intelligence Fifth generation computing devices, based on artificial intelligence, are still in development, though there are some applications, such as voice recognition, that are being used today. The use of parallel processing and superconductors is helping to make artificial intelligence a reality. Quantum computation and molecular and nanotechnology will radically change the face of computers in years to come. The goal of fifth-generation computing is to develop devices that respond to natural language input and are capable of learning and self-organization. Types of Operating Systems Modern computer operating systems may be classified into three groups, which are distinguished by the nature of interaction that takes place between the computer user and his or her program during its processing. The three groups are called batch, time-shared and real time operating systems.

In a batch processing operating system environment, users submit jobs to a central place where these jobs are collected into a batch, and subsequently placed on an input queue at the computer where they will be run. In this case, the user has no interaction with the job during its processing, and the computers response time is the turnaround time-the time from submission of the job until execution is complete, and the results are ready for return to the person who submitted the job.

Another mode for delivering computing services is provided by time sharing operating systems. In this environment a computer provides computing services to several or many users concurrently on-line. Here, the various users are sharing the central processor, the memory, and other resources of the computer system in a manner facilitated, controlled, and monitored by the operating system. The user, in this environment, has nearly full interaction with the program during its execution, and the computers response time may be expected to be no more than a few second.

Page 22 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The third classes of operating systems, real time operating systems, are designed to service those applications where response time is of the essence in order to prevent error, misrepresentation or even disaster. Examples of real time operating systems are those, which handle airlines reservations, machine tool control, and monitoring of a nuclear power station. The systems, in this case, are designed to be interrupted by external signal that require the immediate attention of the computer system.

In fact, many computer operating systems are hybrids, providing for more than one of these types of computing services simultaneously. It is especially common to have a background batch system running in conjunction with one of the other two on the same computer. A number of other definitions are important to gaining an understanding of operating systems:

A multiprogramming operating system is a system that allows more than one active user program (or part of user program) to be stored in main memory simultaneously. Thus, it is evident that a time-sharing system is a multiprogramming system, but note that a multiprogramming system is not necessarily a time-sharing system. A batch or real time operating system could, and indeed usually does, have more than one active user program simultaneously in main storage. Another important, and all too similar, term is multiprocessing. A multiprocessing system is a computer hardware configuration that includes more than one independent processing unit. The term multiprocessing is generally used to refer to large computer hardware complexes found in major scientific or commercial applications.

A networked computing system is a collection of physically interconnected computers. The operating system of each of the interconnected computers must contain, in addition to its own stand-alone functionality, provisions for handing communication and transfer of program and data among the other computers with which it is connected.

A distributed computing system consists of a number of computers that are connected and managed so that they automatically share the job processing load among the constituent computers, or separate the job load as appropriate particularly configured processors. Such a system requires an operating system, which in addition to the typical stand-alone functionality provides coordination of the operations and information flow among the component computers.

The networked and distributed computing environments and their respective operating systems are designed with more complex functional capabilities. In a network operating system the users are aware of the existence of multiple computers, and can log in to remote machines and copy files from one machine to another. Each machine runs its own local operating system and has its own user (or users).

A distributed operating system, in contrast, is one that appears to its users as a traditional uniprocessor system, even though it is actually composed of multiple processors. In a true distributed system, users should not be aware of where their programs are being run or where their files are located; that should all be handled automatically and efficiently by the operating system.

Page 23 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Network operating systems are not fundamentally different from single processor operating systems. They obviously need a network interface controller and some low-level software to drive it, as well as programs to achieve remote login and remote files access, but these additions do not change the essential structure of the operating systems.

What OSs Are Available Today The list of different types of operating systems and a few examples of Operating Systems that fall into each of the categories. Many computer Operating Systems will fall into more then one of the below categories given below.

GUI - Short for Graphical User Interface, a GUI Operating System contains graphics and icons and is commonly navigated using a computer mouse. Below are some examples of GUI Operating Systems. System 7.x Windows 98 Windows CE Multi-user - A multi-user Operating System allows for multiple users to use the same computer at the same time and/or different times. Below are some examples of multi-user Operating Systems. Linux UNIX Windows 2000 VMS MVS

Multiprocessing - An Operating System capable of supporting and utilizing more than one computer processor. Below are some examples of multiprocessing Operating Systems. Linux UNIX Windows 2000

Multitasking - An Operating systems that is capable of allowing multiple software processes to be run at the same time. Below are some examples of multitasking Operating Systems. UNIX Windows 2000

Multithreading - Operating systems that allow different parts of a software program to run concurrently. Operating systems that would fall into this category are: Linux UNIX Windows 2000

Page 24 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Networking OS: Windows 2000 Novell Netware OS Layers An operating system provides the environment within which programs are executed. To construct such an environment, the system is partitioned into small modules with a well-defined interface. The design of a new operating system is a major task. It is very important that the goals of the system be well defined before the design begins. The type of system desired is the foundation for choices between various algorithms and strategies that will be necessary. The important modules for an operating system are listed below. Process Management Memory Management Secondary Storage Management I/O System File Management Protection System Networking Command Interpreter System

Obviously, not all systems have the same structure. Summary Computers have been classified into five generations The various components of a typical computer system The Computer types are determined based on size, speed and cost. The Definition of an OS, Objectives, Functions, Evolution, Types, Layers A few examples of Operating Systems that fall into each of the categories. Test your Understanding 1. Which component, if missing, will keep the Personal Computer from not functioning? a. Scanner b. Printer c. Camera d. Processor 2. Todays fastest computers are called: a. C.P.U. b. Mega computers c. Supercomputers d. Terminals

Page 25 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology 3. What is multitasking and Multiprogramming? 4. Why Operating System is called a resource manager? 5. Which of the following is not an Operating System? a. Linux b. Solaris c. MVS (Multiple Virtual Storage) d. Sun OS

Answer: 1. d 2. c 5. c

Page 26 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 2: Introduction to Computer Networking

Learning Objectives After completing this session, you will be able to Explain computer networks Describe the need for a computer network Identify the classification of computer networks Differentiate network topologies List network services Introduction to Computer Networks Networks are changing the way we do business and the way we live. Business decisions have to be made ever more quickly, and the decision makers require immediate access to accurate information. But before we ask how quickly we can get hooked up, we need to know how networks operate, what types of technology are available and which design best fits which set of needs. When a company adds a new division, the technology has to be flexible enough to reflect changing configurations. Is a particular design robust enough to handle the growth? Understanding what it does and when to use each type of technology is essential for providing the right system in todays dynamically changing information management. Why Networking Computer networking is the scientific and engineering discipline concerned with communication between computer systems. Such communicating computer systems constitute a computer network and these networks generally involve at least two devices capable of being networked with at least one usually being a computer. The devices can be separated by a few meters (e.g. via Bluetooth) or thousands of kilometers (e.g. via the Internet). The public Internet is a world-wide computer network, that is, a network that interconnects millions of computing devices throughout the world. Most of these computing devices are traditional desktop PCs, UNIX based workstations, and so called servers that store and transmit information such as Web (WWW) pages and e-mail messages. Increasingly, non-traditional computing devices such as Web TVs, mobile computers, pagers and toasters are being connected to the Internet. In the internet jargon, all of these devices are called hosts or end systems.

A network is a set of devices (often referred to as nodes) connected by links. A node can be a computer, printer, or any other device capable of sending and/or receiving data generated by other nodes on the network. The links connecting the devices are often called communication channels. A computer network is two or more computers connected together using a telecommunication system for the purpose of communicating and sharing resources.

Page 27 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Network Goals If we connect all PCs in a network, each PC can share information from other PCs. In effect, this signifies what is known as information sharing. A company with many factories may have a computer at each location to keep track of inventories, monitor productivity, and do the local payroll. Initially, each of these computers may have worked in isolation from others. But at some point, management might have decided to connect them to be able to extract and correlate information about the entire company.

In Cognizant HR department, one person looks after the resumes of the employees, another takes care of leaves availed (balance) by the employees, a third person may administer the HR policies. They would all have to take printouts for various purposes. In case, the computers are not connected, each of them would need a separate printer. This would be expensive and probably it would take some time for the company to provide a separate printer to every machine. This would lead to delay in work. This problem can be overcome; if all the machines are connected in a network in which case, there will be only one printer required which can cater to everybodys needs. This is what is known as Resource Sharing. This is a slightly more general form of information sharing and the goal is to make all programs, data and equipment available to anyone on the network without regard to the physical location of the resource and the user. In other words, the mere fact that a user happens to be 1000 km away from his data should not prevent him from using the data as if they were local. This goal may be summarized by saying that it is an attempt to end the tyranny of geography.

The Finance department takes 2-3 days to process the salaries of the employees, as the number of employees is as large as 80-90 thousand. This is mainly because the Finance department uses only one machine to do the entire task of payroll processing as only this machine has the database of employees. If we can make this database available to more machines this would result in faster generation of pay slips. A database, which can be accessed by a number of machines, is called a central database and this aspect of network is called Load Sharing.

Another advantage of network is to provide high reliability by having alternative sources of supply. For example, all files could be replicated on two or three machines, so if one of them is unavailable (due to hardware failure), the other copies could be used. In addition, the presence of multiple CPUs means that if one goes down, the others may be able to take over its work, although at reduced performance. For military, banking, air traffic control, and many other applications, the ability to continue operating in the face of hardware problem is of great importance.

Another advantage of a network is that it is cost effective. Small computers have a much better Price/Performance ratio than large ones. Mainframes are roughly a factor of ten faster than the fastest single chip microprocessor, but they cost a thousand times more.

This imbalance has compelled many systems designers to build systems consisting of powerful personal computers, one per user, with data kept on one or more shared file server machines.

Page 28 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology So, we can list down the benefits of network as: Information sharing Resource sharing Load sharing High reliability Cost effective Components of a Computer Network Many of the components of which an average computer network is composed are individual computers, which are generally either workstations or servers.

Types of Workstations There are many types of workstations that may be incorporated into a particular network, some of which have high-end displays, multiple CPUs, large amounts of RAM, large amounts of hard drive storage space, or other enhancements required for special data processing tasks, graphics, or other resource intensive applications.

Types of Servers The following is a list of some of the more common types of servers and their purpose. File Server - Stores various types of files and distributes them to other clients on the network. Print server - Controls and manages one or more printers and accepts print jobs from other network clients, and performing most or all of the other functions that a workstation would perform to accomplish a printing task if the printer were connected directly to the workstation's printer port. Mail Server - Stores, sends, receives, routes, and performs other email related operations for other clients on the network. Fax Server - Stores, sends, receives, routes, and performs other functions necessary for the proper transmission, reception, and distribution of faxes. Telephony Server - Performs telephony related functions such as answering calls automatically, performing the functions of an interactive voice response system, storing and serving voice mail, routing calls between the Public Switched Telephone Network (PSTN) and the network or the Internet (e.g., Voice-over IP (VoIP) gateway), etc. Proxy Server - Performs some type of function on behalf of other clients on the network to increase the performance of certain operations (e.g., prefetching and caching documents or other data that is requested very frequently) or as a security precaution to isolate network clients from external threats. Remote Access Server (RAS) - Monitors modem lines or other network communications channels for requests to connect to the network from a remote location, answers the incoming telephone call or acknowledges the network request, and performs the necessary security checks and other procedures necessary to log a user onto the network.

Page 29 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Application Server - Performs the data processing or business logic portion of a client application, accepting instructions for what operations to perform from a workstation and serving the results back to the workstation, while the workstation performs the user interface or GUI portion of the processing (i.e., the presentation logic) that is required for the application to work properly. Web Server - Stores HTML documents, images, text files, scripts, and other Web related data (collectively known as content), and distributes this content to other clients on the network on request. Backup Server - Has network backup software installed and have large amounts of hard drive storage or other forms of storage (tape, etc.) available to it to be used for the purpose of insuring that data loss does not occur in the network.

Printers Many printers are capable of acting as part of a computer network without any other device, such as a print server, to act as an intermediary between the printer and the device that is requesting a print job to be completed.

Dumb Terminals Many networks use dumb terminals instead of workstations either for data entry and display purposes or in some cases where the application runs entirely on the server. Is a computer terminal that has limited functionality?

Other Devices There are many other types of devices that may be used to build a network, many of which require an understanding of more advanced computer networking concepts before they are able to be easily understood (e.g., hubs, routers, bridges, switches, hardware firewalls, etc.).

A Simple Network A simple computer network may be constructed from two computers by adding a network adapter (Network Interface Controller (NIC)) to each computer and then connecting them together with a special cable called a crossover cable. This type of network is useful for transferring information between two computers that are not normally connected to each other by a permanent network connection or for small home networking applications.

Practical Networks Practical networks generally consist of more than two interconnected computers and generally require special devices in addition to the Network Interface Controller that each computer needs to be equipped with.

Page 30 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Network Types Below is a list of the more common types of computer networks, although there are other types that are not listed.

Local Area Network (LAN) A network that is limited to a relatively small spatial area such as a room, a single building, a ship, or an aircraft. For administrative purposes, large LANs are generally divided into smaller logical segments called workgroups. A workgroup is a group of computers that share a common set of resources within a LAN. Campus Area Network (CAN) A network that connects two or more LANs but that is limited to a specific (possibly private) geographical area such as a college campus, industrial complex, or a military base. Note: A CAN is generally limited to an area that is smaller than a Metropolitan Area Network (MAN).

Metropolitan Area Network (MAN) A network that connects two or more LANs or CANs together, but that does not extend beyond the boundaries of the immediate town, city, or metropolitan area.

Wide Area Network (WAN) A network that covers a broad geographical area (i.e., any network whose communications links cross metropolitan, regional, or national boundaries) or, less formally, a network that uses routers and public communications links.

Types of WANs: Centralized: A centralized WAN consists of a central computer that is connected to dumb terminals and / or other types of terminal devices. Distributed: A distributed WAN consists of two or more computers in different locations and may also include connections to dumb terminals and other types of terminal devices.

Internet work Two or more networks or network segments connected using devices that operate at layer 3 (the 'network' layer) of the OSI Basic Reference Model(a layered abstract description for communication and computer network protocol design) , such as a router or layer 3 switch.

Note: Any interconnection among or between public, private, commercial, industrial, or governmental networks may also be defined as an internet work.

Page 31 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Internet: A specific internet work, consisting of a worldwide interconnection of governmental, academic, public, and private networks based upon the Advanced Research Projects Agency Network (ARPANET) developed by ARPA of the U.S. Department of Defense also known as the World Wide Web (WWW) or the 'Internet' with a capital 'I' to distinguish it from other generic internet works.

Intranet A network or internet work that is limited in scope to a single organization or entity or a network or internet work that is limited in scope to a single organization or entity and which uses one kind network protocol called Transmission Control Protocol/Internet Protocol(TCP/IP) protocol suite, Hyper Text Transfer Protocol (HTTP), File Transfer Protocol (FTP), and other network protocols and software commonly used on the Internet. Note: Intranets may also be categorized as a Local Area Network(LAN), Campus Area Network(CAN), Metropolitan Area Network(MAN), Wide Area Network(WAN), or other type of network.

Extranet A network or internet work that is limited in scope to a single organization or entity but which also has limited connections to the networks of one or more other usually, but not necessarily, trusted organizations or entities (e.g., a company's customers may be provided access to some part of its intranet creating an extranet while at the same time the customers may not be considered 'trusted' from a security standpoint).

Note: Technically, an extranet may also be categorized as a CAN, MAN, WAN, or other type of network, although, by definition, an extranet cannot consist of a single LAN, since an extranet must have at least one connection with an outside network.

It is interesting to note that Intranets and extranets may or may not have connections to the Internet, but if they are connected to the Internet, the intranet or extranet is normally protected from being accessed from the Internet without proper authorization, and the Internet itself is not considered to be a part of the intranet or extranet, although the Internet may serve as a portal for access to portions of an extranet. Classification of computer networks

By network layer Computer networks may be classified according to the network layer at which they operate according to some basic reference models that are considered to be standards in the industry such as the seven layer OSI reference model and the five layer TCP/IP model.

Page 32 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology By scale Computer networks may be classified according to the scale or extent of reach of the network, for example as a Personal area network (PAN), Local Area Network, Wireless local area network (WLAN), Campus area network (CAN), Metropolitan area network (MAN), or Wide area network (WAN).

Note: WLAN is also known as PAN (Personal Area Networking) with wireless connection technologies such as Bluetooth (which has a limited range of approximately 15 meters).

By connection method Computer networks may be classified according to the technology that is used to connect the individual devices in the network such as HomePNA, Power line communication, Ethernet, or WiFi.

By functional relationship Computer networks may be classified according to the functional relationships which exist between the elements of the network, for example Active Networking, Client-server and Peer-to-peer (Workgroup) architectures.

By network topology Computer networks may be classified according to the network topology upon which the network is based, such as Bus network, Star network, Ring network, Mesh network, Star-bus network, Tree topology network, etc. We will study different network topologies in detail.

Bus Network A bus network is a network architecture in which a set of clients are connected via a shared communications line, called a bus. There are several common instances of the bus architecture, including one in the motherboard of most computers, and those in some versions of Ethernet networks.

Bus networks are the simplest way to connect multiple clients, but often have problems when two clients want to transmit at the same time on the same bus. Thus systems which use bus network architectures normally have some scheme of collision handling or collision avoidance for communication on the bus, quite often using Carrier Sense Multiple Access or the presence of a bus master which controls access to the shared bus resource.

A true bus network is passive the computers on the bus simply listen for a signal; they are not responsible for moving the signal along. However, many active architectures can also be described as a "bus", as they provide the same logical functions as a passive bus; for example, switched Ethernet can still be regarded as a logical bus network, if not a physical one. Indeed, the hardware may be abstracted away completely in the case of a software bus.

Page 33 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology With the dominance of switched Ethernet over passive Ethernet, passive bus networks are uncommon in wired networks. However, almost all current wireless networks can be viewed as examples of passive bus networks, with radio propagation serving as the shared passive medium.

Nodes/Computers

Bus Fig 2.1: Bus Network

Advantages Easy to implement and extend Well suited for temporary networks (quick setup) Initially less expensive than other topologies

Disadvantages Difficult to administer / troubleshoot. Limited cable length and number of stations. If there is a problem with the cable, the entire network goes down. Maintenance costs may be higher in the long run. Performance degrades as additional computers are added or on heavy traffic. Low security (all computers on the bus can see all data transmissions). One virus in the network will affect all of them (but not as badly as a star or ring network). Proper termination is required.(loop must be in closed path). Entire network shuts down if there is a break in the main cable If many computers are attached, the amount of data flowing causes the network to slow down.

Star network Node

Central Station/hub/Computer

Fig 2.2: Star Network Layout

Page 34 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Star networks are one of the most common computer network topologies. In its simplest form, a star network consists of one central switch, hub or computer which acts as a router to transmit messages. If the central node is passive, the originating node must be able to tolerate the reception of an echo of its own transmission, delayed by the two-way transmission time (i.e. to and from the central node) plus any delay generated in the central node. An active star network has an active central node that usually has the means to prevent echo-related problems. The star topology reduces the chance of network failure by connecting all of the systems to a central node. When applied to a bus-based network, this central hub rebroadcasts all transmissions received from any peripheral node to all peripheral nodes on the network, sometimes including the originating node. All peripheral nodes may thus communicate with all others by transmitting to, and receiving from, the central node only. The failure of a transmission line linking any peripheral node to the central node will result in the isolation of that peripheral node from all others, but the rest of the systems will be unaffected. Strictly speaking only networks that use switches have a true star topology. If the network uses a hub, the network topology has the physical appearance of a star, but is actually a bus.

Advantages Good performance Easy to set up and to expand. Any non-centralized failure will have very little effect on the network, whereas on a ring network it would all fail with one fault

Disadvantages Expensive to install Extra hardware required

Ring network

Fig 2.3: Ring network layout

A ring network is a topology of computer networks where each node is connected to two other nodes, so as to create a ring. Ring networks tend to be inefficient when compared to Star networks because data must travel through less no. of points before reaching its destination. For example, if a given ring network has eight computers on it, to get from computer one to computer four, data must travel from computer one, through computers two and three, and to its destination at computer four. It could also go from computer one through eight, seven, six, and five until reaching four, but this method is slower because it travels through more computers. Ring networks also

Page 35 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology carry the disadvantage that if one of the nodes in the network breaks down then the entire network will break down with it as it requires a full circle in order to function. The token ring network is a ring topology only at the logical level; it runs on a physical star network, using central devices called MSAUs or MAUs. Advantages Data is quickly transferred without a bottle neck. (very fast, all data traffic is in the same direction) The transmission of data is relatively simple as packets travel in one direction only. Adding additional nodes has very little impact on bandwidth It prevents network collisions because of the media access method or architecture required. Disadvantages Data packets must pass through every computer between the sender and recipient therefore this makes it slower. If any of the nodes fail then the ring is broken and data cannot be transmitted successfully. It is difficult to troubleshoot the ring. Because all stations are wired together, to add a station you must shut down the network temporarily. In order for all computers to communicate with each other, all computers must be turned on. Total dependence upon the one cable.

Mesh networking

Fig 2.4: Mesh network layout Mesh networking is a way to route data, voice and instructions between nodes. It allows for continuous connections and reconfiguration around broken or blocked paths by "hopping" from node to node until the destination is reached. A mesh network whose nodes are all connected to each other is a fully connected network. Mobile ad-hoc networking (MANET), featured in many consumer devices, is a subsection of mesh networking. Mesh networks are self-healing: the network can still operate even when a node breaks down or a connection goes bad. As a result, a very reliable network is formed. This concept is applicable to wireless networks, wired networks, and software interaction.

Page 36 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A mesh network is a networking technique which allows inexpensive peer network nodes to supply back haul services to other nodes in the same network. It effectively extends a network by sharing access to higher cost network infrastructure.

Mesh networks differ from other networks in that the component parts can all connect to each other via multiple hops, and they generally are not mobile.

An MIT project developing Children's Machines for under-privileged schools in developing nations plans to use mesh networking to create a robust and inexpensive infrastructure for the students who will receive the laptops. The instantaneous connections made by the laptops are claimed by the project to reduce the need for an external infrastructure such as the internet to reach all areas, because a connected node could share the connection with nodes nearby. A technology similar to the one used in the Children's Machines is available for use on netgear/x86/Meraki nodes. In Cambridge, UK, on the 3rd June 2006, mesh networking was used at the "Strawberry Fair" to run mobile live television, radio and internet services to an estimated 80,000 people.

Local Area Network (LAN) LAN is a computer network covering a local area, like a home, office or small group of buildings such as a college. A LAN at its simplest consists of two or more computers connected through cables and a Network Operating Software (NOS), which is responsible for all the computers to talk to each other through the cables. The computers can spread across in the same building or the nearby buildings, hence the name local area network.

One of the main drawbacks of a LAN is its physical limitation. It is restricted to inside a floor or at the most a building. Another disadvantage is that a particular LAN technology may only work with specific computers. A NIC (Network Interface Card) may not be compatible to all types of LANs. Also, LAN performance determines cost: higher the performance required, higher would be the cost. This is obvious, because the hardware that transmits data faster costs more money.

Metropolitan Area Network (MAN) MANs are large computer networks usually spanning a campus or a city. They typically use wireless infrastructure or optical fiber connections to link their sites. Two or more LANs in the same metropolitan area connected together are called MANs. Using high-speed (1.544 Mbps to 155 Mbps) transmission, MANs connect smaller networks within a campus, a city, and/or neighboring suburbs. For instance, a university or a college may have a MAN that joins together many of their local area networks (LANs) situated around the site of a fraction of a square kilometer. Then from their MAN they could have several Wide Area Network (WAN) links to other universities or the Internet. MAN links between LANs have been built without cables using either microwave, radio, or infra-red free-space optical communication links.

Wide Area Network (WAN) WANs are used to connect Local Area Networks (LANs) together, so that users and computers in one location can communicate with users and computers in other locations. Many WANs are built for one particular organization and are private. Others, built by Internet Service Providers (ISP), provide connections from an organization's LAN to the Internet.Usually, LANs are connected through phone companys data transmission services. A WAN provides other LAN users in distant
Page 37 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology locations with the same information and services that are available to the local LAN users. As Cognizant has several offices across the country and they need to be linked together. Then, we need to connect all the individual LANs of this company in a WAN. If you maintain a central database or other application like shared documents that all personnel should use, you are required to set up a WAN, especially if you want to expand your offices into other cities.

There are several WAN types possible. A very basic WAN can be two computers communicating between each other over a Modem connection. A more complicated one may consist of hundreds of offices connected with high capacity digital circuits. Generally, a WAN takes up a form in between these two extremes.

The main advantage of a WAN is its wide span, geographically. Many incompatible LANs are linked in a WAN, thus making different LANs being able to talk to each other. It recovers the physical limitation of the LAN. It can cater to the common user needs in different widespread locations. Managing the resources becomes more effective. The resources are utilized properly. Actually, the concept of a WAN came into existence for the desirability of a single network and WAN was the foundation of the Internet. This is different from Personal Area Networks (PANs), Metropolitan Area Networks (MANs) or Local Area Networks (LANs) that are usually limited to a room, building or campus. The best example of a WAN is the Internet. Network Services The basic LAN services include sharing of directories and files, printers. LAN technologies also allow access to other common resources like modems and faxes. Most important of them are File Serving, Print Sharing, or Mail Serving. We will have a brief look at these services.

File Services: It is the heart of the LAN. It has applications that the users need and the files that are being used by all or some of the users (i.e., shared). It is generally divided into two distinct parts; one is their own directories or shared directories and other being restricted for administrative purposes, such as the security directories or system files. There can be more than one file server, and is generally the case. The users may or may not have access permission to all of them.

Print Services: These are the servers that have a printer or more than one printer being attached to them. In a LAN environment, a computer prints to a network printer over the LAN cabling. A print server accepts the print jobs in the order they were sent and stores the files. This is known as spooling a job. The print jobs are kept in a place called the Print Queue. The queue is typically located in a file server and is used to stage the print jobs prior to printing. Since a computer can transmit data faster than a printer is capable of putting this information on paper, a staging area is required, in case someone tries to print while the printer is busy printing some other print job. If this case occurs, the second print job will be retained in the print queue until the first print job is completed. The print server provides the processing power required to poll the queue and determines if there is a job pending to be printed. If one is found, the job is sent out of the print servers LPT port to the printer.

Page 38 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Application Services: An application server is a software that runs on a NOS and provides direct connectivity to a software program. Application servers usually require that a portion of the software be running on both the server and the workstation at the same time. For example, Lotus Notes is a kind of application server. It includes a server portion maintaining the data files and a workstation portion, which is used to access and manipulate information stored in the Lotus Notes server. Message Services: Announce a call or meeting with a quick message to a colleague or coworkers computer screen and get a quick reply. The messaging facility is also customizable. Each user can define their own group to simplify sending messages to several users. Broadcasting an important message to a select group or everyone is possible.

Database Services: Access to remote data is possible because of Computer Networks. Distributed computer networks consist of computers connected in such a way that any system can potentially communicate with any other system. The platform for distributed systems has been the enterprise network linking workgroups, departments, branches, and divisions of an organization. Data is not located in one server, but in many servers. These servers might be at geographically diverse areas, connected by WAN links. Remote Access to LAN: Another important service in LAN is the remote access of the LAN resources. You can access a LAN (by a modem) from a remote location to share files or even perform administrative tasks. The concept of remote access has long been an integral part of LAN, but with recent advancement of speed of modems and phone company services, such as ISDN, the remote access functionally has largely improved.

Today, a remote user can log into the LAN and perform virtually all types of transactions as if he/she was actually sitting in the office.

Security Features The most important part about a LAN is its security. As all resources are available to everyone in the LAN, careful measures should be taken to secure it. To maintain a secure system, users have to prove their identity at least a couple of times. There are various authentication procedures for a secure LAN.

Username: In this method, the system has a secure list of users already fed in. When a user types in his/her name, the system checks the list names. If the name is already there, the user is given access to the LAN resources. There are many resources, such as security directories, operating system files, employee database, which are very sensitive and needed to be very secured. The username authentication method can also be set for these particular files.

Username and Password: This is even a more secure model than the previous one. In this model, the user is required to enter a username and password combination. Then the same procedure is followed as in the above model.

Peer-to-Peer Network A LAN typically consists of several computers connected to one another, usually located in close proximity such as a computer lab. LANs are the most common form of networks found in most small businesses and schools. A LAN is often created for several computers to share an
Page 39 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology intermittently used resource such as a laser printer. In earlier days of networking, most LANs used peer-to-peer networking to facilitate communication. A peer-to-peer network is built without the use of a central server, a computer used as the central storage unit for data. Each peer computer can share its resources with the other computers on the network independently. Today, LANs often include central server computers. Special software protocols, such as Microsoft NetBEUI, and Apples Local Talk, are used for establishing communication across a peer-to-peer network. Also known as a P2P network, a peer-to-peer network is a network that does not have a central computer or dedicated server, in other words all computers are independent. This type of network is the type of network you would most likely find in home networks or small networks comprised of a dozen or less computers.

Advantages: Low cost as expensive software and hardware are not required. Easy to implement Resource sharing controlled by users No need of a dedicated network administrator

Disadvantages: Low level of security Heavy load on computers because of increased communication traffic Resource sharing Resource sharing controlled by users Size of network limited to approx. 10 Constant attack by people with a variety of motives.

Client-Server Network In more complex networks client/server networking is usually employed. A centralized computer is used to facilitate the sharing of data and hardware with other computers on the network. These central computers are called file servers. The computers using the file server are called clients. Most client/server networks are the type of networks you would find in a corporate or business environment.

Advantages: Strong central security Central file storage Resource sharing controlled by administrators Easy management of large number of users

Disadvantages: High cost of server hardware and software Need for a dedicated and well trained network administrator

Page 40 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Summary Computer networking provides communication tools to allow computers to share information and abilities Networks can be of the following forms: LAN, MAN and WAN The common network services offered by servers are: o File Services o Print Services o Message Services o Application Services o Database Services Test your Understanding 1. What are the advantages of computer networks? a. Efficient management of resources b. Reduced costs c. Sharing of applications d. All of the above 2. A tree topology is a variation of ________ topology a. mesh b. star c. bus d. ring

Answers: 1. d 2. c

Page 41 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 3: CPU Structure

Learning Objectives After completing this module, you will be able to: Explain the major components of CPU Define Registers, ALU and Control Unit Major Components of CPU A central processing unit (CPU), simply processor, is the component in a digital computer that interprets computer program instructions and processes data. A CPU that is manufactured as a single integrated circuit is usually known as a microprocessor.

The phrase "central processing unit" is a description of a certain class of logic machines that can execute computer programs. The form, design and implementation of CPUs have changed dramatically since the earliest examples, but their fundamental operation has remained same.

Register set

Control

Arithmetic logic Unit (ALU)

Fig 3.1: Major Components of CPU The major components of the CPU are depicted in Fig 3.1, while Table 3.1 describes the purpose of the various special purpose registers

Page 42 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Table 3.1 List of special purpose registers for the basic computer Register symbol MDR MAR AC IR PC TEMP INPR OUTR Register name Memory Data Register Memory Address Register Accumulator Instruction Register Program Counter Temporary Register Input Register Output Register Function Holds memory operand Holds address for memory Processor register Holds instruction code Holds address of the instruction Holds Temporary data Holds Input data Holds output data

Overview of CPU Behavior Central Processing Unit

PC Address lines Memory lines Data lines MDR

CPU bus Instruction Decoder

MAR IR

R0 Y R(n-1)

ALU control lines

Add Sub

AL U

Carry-in

TEMP

XOR

Fig 3.2: Interaction between components of CPU

Fig 3.2 shows the components that are likely to interact in the process of executing an instruction. Depending on the instruction, at any given time, one of the ALU controls, like Add, Sub would be made active.

Page 43 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Instruction Execution Begin

No Are there instructions waiting? Yes Fetch the next instruction

Execute the instruction

No Are there interrupts waiting?

Yes

Transfer to interrupthandling program

Fig 3.3: Behavior Flow of CPU

Fig 3.3 describes the typical flow of the ways by which the CPU behaves. The phases of the instruction execution are as follows. Fetch the instruction from memory. The contents of the memory location pointed by PC are stored in IR IR [[PC]] The instruction is decoded The content of the PC will be incremented so as to point to the next instruction [PC] [PC] + x The operands are fetched from memory. The specified operation is performed. The result is stored

Page 44 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Instruction types Data transfer instructions: Transfers the data from one location to another without changing the contents o o o o o o Register - Register Register - Memory / Memory Register Memory - Memory Arithmetic instruction: Operates on numeric data Logical instruction: Performs Boolean operations Shift instructions: Shifts to the right or left

Data Manipulation instructions: Performs arithmetic, logic and shift operations

Program Control instructions: Changes the sequence of instructions o Branch, Jump instructions: Conditional / Unconditional I/O instructions: Transfers information between CPU or Memory to and from I/O devices Fetching a word from Memory For fetching a word from Memory, CPU transfers address of the required word to MAR MAR is connected to Address lines of Memory Address is transferred to Memory CPU has to specify the type of operation: READ/ WRITE. Here it is a READ operation CPU waits until Memory unit signals the completion of READ operation MFC (Memory Function Completed) Signal becomes ACTIVE, as soon as the operation is through. DATA is then available on Data Lines The DATA will be loaded into MDR

Example 3.1 describes the various steps involved in the process of fetching a data word pointed to, by register R1.

Example 3.1 R1 -: Address of the Memory location R2 -: Data fetched from Memory Step 1: MAR [R1] Step 2: Read Step 3: Wait for MFC signal (WMFC) Step 4: [R2] [MDR] The duration of step 3 depends on the speed of memory Time for READ from memory is more than the time for performing single operation within the CPU Functions, which do not need MAR, MDR can be carried out during WAIT period e.g. PC can be incremented

Page 45 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Storing Word in Memory Storing Word in Memory The address of the data to be written is loaded into MAR The data is loaded into MDR Write command is issued Wait for MFC signal Steps 1 and 2 can be carried out simultaneously for Multiple Bus Structure only

Example 3.2 describes the various steps involved in the process of writing a data word pointed to, by register R1.

Example 3.2 R1: - Memory address of the data R2: - Data to be stored in Memory Step 1 MAR [R1] Step 2 MDR [R2] Step 3 Write Step 4 Wait MFC Register Transfers To enable data transfer between various blocks connected to BUS, Input &Output gating is required. Transfer of data from R1 to R4 needs the following action. o o R1out = 1, Content of R1 will be on Bus R4in = 1, this Loads Data from Bus to R4

Arithmetic Logic Unit Performs the required micro operations (operations that are executed in a clock tick) for executing the instructions. Performs arithmetic and logical functions The function performed by ALU depends on signal applied to ALU control lines Can be realized with combinational circuits Does not have internal storage To add 2 numbers, both the numbers have to be available at the ALU simultaneously

Page 46 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Example 3.3 talks about the micro-steps involved in adding the contents of the registers R1 and R2 and placing the sum in the register R3.

Example 3.3 R1out, Yin R2out, Add Z in Z out, R3in

In example 3.3, Register Y contains 1 number The other number is gated onto the BUS Add-line is set to 1, to specify the add operation The SUM of the two numbers is stored in the Temporary Register Z Register Gating Electronic Switches are connected to gates of the Register Functions like Mechanical On/Off switches If the switch is in the ON state, data is transferred from Register to Bus If the switch is in the OFF state, the register output is electrically disconnected from the Bus The output of register-switch circuit can be in one of the 3 States - 1, 0, open circuit; this register is also known as Tristate switch The separate control input is used to enable the Gate O/P to drive the bus to 0, 1 or electrically disconnected state (Open circuit) Timing of Data Transfers Finite delay is encountered for the gate to open and for the data to travel along the Bus to ALU Propagation Delay through ALU Adder circuit For the result to be properly stored in register Z, data must be maintained on the bus for some time (Hold time) Control Unit Control unit fetches the instructions from the memory and converts them into a sequence of control signals to implement a sequence of register-transfer operations. Control Unit Design Approaches are: o o Hardwired Control that leads to RISC (Reduced Instruction Set Computer) architecture Micro programmed Control leading to CISC (Complex Instruction Set Computer) architecture

Page 47 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Hardwired Control The control logic is implemented with gates, flip-flops, decoders and other digital circuits It requires changes in the wiring among the various components if the design is to be changed or modified, which is hard in general The goal is to minimize the number of components used and maximize the speed of operation It can be optimized to produce a fast mode of operation

Hardwired Control Unit Status Signals Sequential logic circuit Control Signals

Instruction Register Fig 3.4: Schematic diagram of a Hardwired Control Unit

Fig 3.4 describes the scheme of operation of a Hardwired Control Unit. Based on the status of the CPU and the instruction to be executed, appropriate control signals are made ACTIVE. Micro programmed Control It is built around a storage unit called control memory, where all the control signals are stored in a program like format The microprograms are designed to implement or emulate the behaviour of a given instruction set Each instruction causes the corresponding microprogram to be fetched and its control information extracted in a manner that resembles fetching and execution of a program from the main memory Control signals are organized into formatted words (micro instructions) Design changes can be easily implemented just by changing the contents of the control memory

Drawbacks: Costly due to the presence of the control memory and its access circuitry, Slower due to the extra time required to fetch micro instructions from the control memory

Page 48 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Fig 3.5 shows the Schematic diagram of a Microprogrammed control unit

Status signals

Address Logic

Control memory

Microinstruction Register Instruction register Decoder Control signals

Fig 3.5: Schematic Diagram of a Microprogrammed Control Unit Control Sequence The seven steps that are involved in the execution of an instruction like (R1) (R1) + ((R3)) by a Microprogrammed Control unit is shown below. In each step, more than one microperation can be enabled. Table 3.2 describes the control sequence in the form of their respective microinstructions.

Table 3.2 Control Sequence in the form of their respective microperations Step 1 2 3 4 5 6 7 Action PCout, MARin, Read, Clear Y, Set carry-in to ALU, Add, Zin Zout, PC in, WMFC MDRout, IRin R3out, MARin, Read R1out, Yin, WMFC MDRout, Add, Zin Zout, R1in, End

Page 49 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Microinstructions

Clear Y

Microinstruc tion 1 2 3 4 5 6 7 Intel, AMD

Cary-in

MDRout

WMFC 0 1 0 0 1 0 0

MARin

Read

PCout

R3out

RIout

PCin

Add

0 1 0 0 0 0 0

1 0 0 0 0 0 0

1 0 0 1 0 0 0

1 0 0 1 0 0 0

0 0 1 0 0 1 0

0 0 1 0 0 0 0

0 0 0 0 1 0 0

1 0 0 0 0 0 0

1 0 0 0 0 0 0

1 0 0 0 0 1 0

1 0 0 0 0 1 0

0 1 0 0 0 0 1

0 0 0 0 1 0 0

0 0 0 0 0 0 1

0 0 0 1 0 0 0

0 0 0 0 0 0 1

This generational and chronological list of Intel microprocessors attempts to present all of Intel's processors (Ps) from the pioneering 4-bit (1971) to the present high-end offerings, the 64-bit Itanium 2 (2002) and Intel Core 2 and Xeon 5100 and 7100 series processors (2006).

The Xeon is Intel's brand name for its server-class PC microprocessors intended for multipleprocessor machines. The brand has been maintained over several generations of processors. Xeon chips generally have more cache and support larger multiprocessor configurations than their desktop counterparts.

Many CPU instructions specify some operation, like add, multiply, or compare, to be carried out on an operanddata the processor often stores in registers (temporary internal holding locations), but may also fetch from cache or main memory. Different types of instructions may vary in length. Current CPUs, like the Pentium 4 and Athlon64, decode variable-length x86 instructions into one or a few simpler, fixed-length internal instructions called micro-ops, which are not accessible outside the CPU.

Although compatible microprocessors must produce identical results for identical instructions, internal designs and operation may be entirely different. For example, the AMD Athlon 64, unlike the Pentium 4, initially decodes an instruction into one or more intermediate macro-ops (complex instructions require several macro-ops), which are ultimately converted into one or more microops. Internal architecture may even differ within CPU families and in succeeding generations of highly compatible processor families, such as the Intel 386, 486, and Pentium. Later generations often add instruction-set enhancements such as MMX (Multimedia Extensions) and SSE (Streaming Single-Instruction, Multiple-Data Extensions) in the case of Intel processors. AMD64, which extended the AMD x86 architecture to enable 64-bit instructions and addressing, is another example.

Page 50 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

End

Zout

IRin

RIin

Yin

Zin

Handout - Fundamentals of Computer Technology Summary The Central Processing Unit (CPU) performs the actual processing of data. The data to be processed is obtained, via the system bus, from the main memory. Results from the CPU are then sent back to main memory via the system bus. In addition to computation, the CPU controls and co-ordinates the operation of the other major components. The CPU has two main components, namely: o The Control Unit -- controls the fetching of instructions from the main memory and the subsequent execution of these instructions. Among other tasks carried out are the control of input and output devices and the passing of data to the Arithmetic/Logical Unit for computation. The Arithmetic/Logical Unit (ALU) -- carries out arithmetic operations on integer (whole number) and real (with an r-nary point, decimal point) operands. It can also perform simple logical tests for EQUALITY(= =),GREATER THAN (>), and less than (<) between operands.

Test your Understanding 1. CPU cannot perform which of the following task? a. Perform arithmetic operations b. Generate control signals c. Generate Interrupt d. Supervise I/O Operations 2. Which of the following is not a component of CPU? a. MAR b. ALU c. PC d. DMA 3. The internal register that contains the current instruction being executed by the ALU is: a. PC b. IR c. MAR d. MBR

Answers: 1. c 2. d 3. b

Page 51 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 4: Operating Systems Management

Learning Objectives After completing this session, you will be able to: Analyze different OS components Describe Process, Process states and Process Control Blocks Explain the different Scheduling Algorithms Operating System Components The operating system provides an abstraction of the computers resources to simplify the programmers job of creating application programs. An operating system provides the environment within which programs are executed. To construct such an environment, the system is partitioned into small modules with a well-defined interface. Every OS can be created module by module. Each and every module has its own input, output and functions and all OS need not have the same structure. Many modern operating systems share the same goal of supporting the following system components.

Process Management The operating system is responsible for the following activities in connection with processes managed. The creation and deletion of both user and system processes The suspension or resumption of processes. The provision of mechanisms for process synchronization The provision of mechanisms for process communication The provision of mechanisms for deadlock handling.

Main Memory Management Primary memory or main memory is a large array of words or bytes. Each word or byte has its own address. Main memory provides storage that can be accessed directly by the CPU. It means that for a program to be executed, it must be in the main memory. The major activities of an operating system in regard to memory management are: Keep track of which part of memory are currently being used and by which users process. Decide which processes are loaded into memory when memory space becomes available. Allocate and de-allocate memory space as needed

File Management

Page 52 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A file is a collection of related information defined by its creator. Computer can store files on the disk (secondary storage), which provide long-term storage. Some examples of storage media are magnetic tape, magnetic disk and optical disk. Each of these media has its own properties like speed, capacity, data transfer rate and access methods. A file system is normally organized into directories to ease their use. The directories may contain files and other subdirectories. The five major activities of an operating system in regard to file management are: The creation and deletion of files The creation and deletion of directories The support of primitives for manipulating files and directories The mapping of files onto secondary storage The backup of files on stable storage media

Input /Output System Management I/O subsystem hides the peculiarities of specific hardware devices from the user. Only the device driver knows the peculiarities of the specific device to which it is assigned.

Secondary Storage Management: Generally, systems have several levels of storage, including primary storage, secondary storage and cache storage. Instructions and data must be placed in primary storage or cache to be referenced by a running program. Because main memory is too small to accommodate all data and programs, and its data are lost when power is lost, the computer system must provide secondary storage to backup main memory. Secondary storage consists of tapes, disks and other media to hold information that will eventually be accessed in primary storage (primary, secondary, cache) is ordinarily divided into bytes or words consisting of a fixed number of bytes. Each location in storage has an address; this set of all addresses available to a program is called an address space. The three major activities of an operating system in regards to secondary storage management are: Managing the free space available on the secondary storage device Allocation of storage space when new files have to be written Scheduling the requests for memory access

Networking A distributed system is a collection of processors that do not share memory, peripheral devices or a clock. The processors communicate with one another through communication lines called network. The communication-network design must consider routing and connection strategies and the problems of contention and security.

Protection System If a computer system has multiple users and allows the concurrent execution of multiple processes, then the various processes must be protected from one anothers activities. Protection refers to mechanism for controlling the access of programs, processes, or users of the resources defined by a computer system.

Page 53 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Processes and Process management A process is the basic computational element in a modern computer system, and process management refers to the full spectrum of OS services to support the orderly administration of a collection of processes. A detailed consideration of the process management is the natural place to begin the study of OS details.

A process is a program in execution. In this module we shall explain how a process comes into existence and how processes are managed. A process in execution needs resources like processing resource, memory and IO resources. Current machines allow several processes to share resources. In reality, one processor is shared amongst many processes. A system like a file server may even support processes from multiple users. And yet the owner of every process gets an illusion that the server (read processor) is available to their process without any interruption. This requires clever management and allocation of the processor as a resource. In this module we shall study the basic processor sharing mechanism amongst processes.

What is a Process? As we know a process is a program in execution. To understand the importance of this definition, lets imagine that we have written a program called my_prog.c in C. On execution, this program may read in some data and output some data. Note that when a program is written and a file is prepared, it is still a script. It has no dynamics of its own i.e., it cannot cause any input processing or output to happen. Once we compile, and still later when we run this program, the intended operations take place. In other words, a program is a text script with no dynamic behavior. When a program is in execution, the script is acted upon. It can result in engaging a processor for some processing and it can also engage in I/O operations. It is for this reason a process is differentiated from program. While the program is a text script, a program in execution is a process.

In other words, To begin with let us define what a process is and in which way a process differs from a program. A process is an executable entity its a program in execution. When we compile a C language program we get an a.out file which is an executable file. When we seek to run this file we see the program in execution. Every process has its instruction sequence. Clearly, therefore, at any point in time there is a current instruction in execution.

A program counter determines helps to identify the next instruction in the sequence. So process must have an inherent program counter. Referring back to the C language program its a text file. A program by it self is a passive entity and has no dynamic behavior of its own till we create the corresponding process. On the other hand, a process has a dynamic behavior and is an active entity. Processes get created, may have to be suspended awaiting an event like completing a certain I/O. A process terminates when the task it is defined for is completed. During the life time of a process it may seek memory dynamically. In fact, the malloc instruction in C precisely does that. In any case, from the stand point of OS a process should be memory resident and, therefore, needs to be stored in specific area within the main memory. Processes during their life time may also seek to use I/O devices. For instance, an output may have to appear on a monitor or a printed output may be needed. In other words, process management requires not only making the processor available for execution but, in addition, allocates main memory, files and IO. The process management component then requires coordination with the main memory management, secondary memory management, as well as, files and I/O.

Page 54 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Process States The process state consist of everything necessary to resume the process execution if it is somehow put aside temporarily. The process state or context of a process consists of at least following: Code for the program. Program's static data. Program's dynamic data. Program's procedure call stack. Contents of general purpose register. Contents of program counter (PC) Contents of program status word (PSW). Operating Systems resource in use.

Five state model The five states of a process are as follows New State: The process being created. Ready State: A process is said to be ready if it use a CPU if one were available. A ready state process is runnable but temporarily stopped running to let another process run. Blocked (or waiting) State: A process is said to be blocked if it is waiting for some event to happen such that as an I/O completion before it can proceed. Note that a process is unable to run until some external event happens. Running State: A process is said to be running if it has the CPU, that is, process actually using the CPU at that particular instant. Exit state: The process has finished execution. The state transition diagram is shown in figure 4.1

Fig. 4.1: Five State Model Process blocks for an event, appears when a process discovers that it cannot continue. In order to get into blocked state, some systems must execute a system call block. In other systems, when a process reads from a pipe or special file and there is no input available, the process is automatically blocked.

Page 55 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Dispatcher picks either the same or another process for execution. Scheduler picks another process, when the scheduler decides that the running process has run long enough, and it is time to let another process have some CPU time. Scheduler picks the same process when all other processes have had their share and it is time for the first process to run again.

Process moves from blocked to ready when the external event for which it was waiting happens. If no other process is running at that instant, same process will start running. Otherwise it may have to wait in ready state for a little while until the CPU is available.

Another state is included into this five state model is called suspended state. This state says about whether process is there in the main memory or not. This is included to increase the multiprogramming level. When the process is blocked it can be suspended till it get the event complete.

Using the process model, it becomes easier to think about what is going on inside the system. There are many processes like user processes, disk processes, terminal processes, and so on, which may be blocked when they are waiting for some thing happen. When the disk block has been read or the character typed, the process waiting for it is unblock and is ready to run again. The process model, an integral part of a operating system, can be summarized as follows. The lowest level of the operating system is the scheduler with a number of processes on top of it. The scheduler does all the process handling, such as starting and stopping processes. Process Control Block (PCB) To implement the process model, the operating system maintains a table, an array of structures, called the process table. Each entry identifies a process with information such as process state, its program counter, stack pointer, memory allocation, the status of its open files, its accounting and scheduling information.

A Process Control Block (PCB, also called Task Control Block) is a data structure in the operating system kernel representing the state of a given process. Each process is identified with its own process control block, PCB, These are:

Implementations differ, but in general a PCB will include, directly or indirectly: The identifier of the process (a process identifier, or PID) Process state, which may be new, ready, running, waiting or halted; Register values for the process including, notably, The Program Counter value for the process The address space for the process. Memory management information, which include base and bounds registers or page table; I/O status information, composed I/O requests, I/O devices allocated to this process, a list of open files and so on; Process accounting information, such as when the process was last run, how much CPU time it has accumulated, etcetera.

Page 56 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology During a context switch, the running process is stopped and another process is given a chance to run. The kernel must stop the execution of the running process, copy out the values in hardware registers to its PCB, and update the hardware registers with the values of the new process. A PCB structure is shown in Fig. 4.2

Pointer State Process number Program counter Registers Memory limits List of open files

Figure: 4.2: Process Control Block Structure

In another words, it must contain everything about the process that must be saved when the process is switched from the running state to the ready state so that it can be restarted later as if it had never been stopped. The switching between two processes is illustrated by Fig. 4.3.

Associated with each I/O device is a location near the bottom of memory called the interrupt vector. It contains the address of the interrupt service procedure. Suppose a user process j is running when a network interrupt occurs. The program counter, program status word, and possibly one or more registers are pushed onto the stack by the interrupt hardware. The CPU then jumps to the address specified in the network interrupt vector. The network interrupts service procedure starts out by saving all the registers in the process table entry for the current process. The current process number and a pointer to its entry are kept in global variables, so they can be founded quickly. The information deposited by the interrupt is removed from the stack, and the stack pointer is set to a temporary stack used by the process handler.

Now the network process can be started; it is changed from blocked to ready, and the scheduler is called. Normally, different processes have different priorities. If the network process is now the highest priority runnable process, it will be scheduled to run. If the process that was interrupted is just as important or more so, then it will be scheduled to run again, and the network process will have to wait a little while.

Page 57 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Process A Executing
save register

Process B

Idle
reload register

Idle
save register

Executing

Idle
reload register

Executing
Figure: 4.3: Process switching

A process may create several new processes during its time of execution. The creating process is called parent process, while the new processes are called children processes. There are different possibilities concerning creating new processes: Execution: the parent process continues to execute concurrently with its children processes or it waits until all of its children processes have terminated (sequential). Sharing: either the parent and children processes share all resources (likes memory or files) or the children processes share only a subset of their parent's resources or the parent and children processes share no resources in common.

A parent process can terminate the execution of one of its children for one of these reasons: The child process has exceeded its usage of the resources it has been allocated. In order to do this, a mechanism must be available to allow the parent process to inspect the state of its children processes. The task assigned to the child process is no longer required.

We distinguish between independent process and cooperating process. A process is independent if it cannot affect or be affected by other processes executing in the system. This type of processes has following features: Its state is not shared in any way by any other process. Its execution is deterministic, i.e. the results of execution depend only on the input values.

Page 58 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Its execution is reproducible, i.e., the results of execution will always be the same for the same input. Its execution can be stopped and restarted without any negative effect. In contrast to independent processes, cooperating processes can affect or be affected by other processes executing in the system. They are characterized by: Their states are shared by other processes; Its execution is not deterministic, i.e., the results of execution depend on relative execution sequence and can not be predicted in advance; Its execution is irreproducible, i.e., the results of execution are not always the same for the same input. Scheduling: A Few Scenarios The OS maintains the data for processes in various queues. The OS keeps the process identifications in each queue. These queues advance based on some policy. These are usually referred to as scheduling policies. To understand the nature of OS's scheduling policies, let us examine a few situations we experience in daily life. When we wish to buy a railway ticket at the ticket window, the queue is processed using a ``all customers are equal policy '' i.e. first-come-firstserved (FCFS). However, in a photocopy shop, customers with bulk copy requirements are often asked to wait. Some times their jobs are interrupted in favor of shorter jobs. The operators prefer to quickly service short job requests. This way they service a large number of customers quickly. The maximum waiting time for most of the customers is reduced considerably. This kind of scheduling is called shortest job first policy. In a university department, the secretary to the chairman of department always preempts any one's job to attend to the chairman's copy requests. Such a pre-emption is irrespective of the size of the job (or even its usefulness some times). The policy simply is priority based scheduling. The chairman has the highest priority. We also come across situations, typically in driving license offices and other bureaus, where applications are received till a certain time in the day (say 11:00 a.m.). All such applications are then taken as a batch. These are processed in the office and the out come is announced for all at the same time (say 2:00 p.m.). Next batch of applications are received the following day and that batch is processed next. This kind of scheduling is termed batch processing. In the context of processes we also need to understand preemptive and non-preemptive operations. Non-preemptive operations usually proceed towards completion uninterrupted. In a non preemptive operation a process may suspend its operations temporarily or completely on its own. A process may suspend its operation for IO or terminate on completion. Note neither of these suspensions is forced upon it externally. On the other hand in a preemptive scheduling a suspension may be enforced by an OS. This may be to attend to an interrupt or because the process may have consumed its allocated time slot and OS must start execution of some other process.

Process Scheduling

Basic concepts The assignment of physical processors to processes allows processors to accomplish work. The problem of determining when processors should be assigned and to which processes is called processor scheduling or CPU scheduling. When more than one process is runnable, the operating system must decide which one first. The part of the operating system concerned with this decision is called the scheduler, and algorithm it uses is called the scheduling algorithm.

Page 59 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Objectives of scheduling Many objectives must be considered in the design of a scheduling discipline. In particular, a scheduler should consider fairness, efficiency, response time, turnaround time, throughput, etc., Some of these goals depends on the system one is using for example batch system, interactive system or real-time system, etc. but there are also some goals that are desirable in all systems.

Types of Scheduler The different types of scheduler dealing with the different states of the process are Long term scheduler dealing with ready process Medium-term scheduler dealing with secondary storage Short-term scheduler dealing with dispatch a process for execution

Fig. 4.4: Types of Scheduler Process Scheduling Algorithms

Preemptive Vs Non-preemptive Scheduling The Scheduling algorithms can be divided into two categories with respect to how they deal with clock interrupts.

Page 60 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Non-preemptive Scheduling A scheduling discipline is nonpreemptive if, once a process has been given the CPU; the CPU cannot be taken away from that process. Following are some characteristics of nonpreemptive scheduling 1. In nonpreemptive system, short jobs are made to wait by longer jobs but the overall treatment of all processes is fair. 2. In nonpreemptive system, response times are more predictable because incoming high priority jobs can not displace waiting jobs. 3. In nonpreemptive scheduling, a scheduler executes jobs in the following two situations. a. When a process switches from running state to the waiting state. b. When a process terminates.

Preemptive Scheduling A scheduling discipline is preemptive if, once a process has been given the CPU can taken away. The strategy of allowing processes that are logically runnable to be temporarily suspended is called Preemptive Scheduling and it is contrast to the "run to completion" method. Types of scheduling algorithms FCFS Scheduling Round Robin Scheduling SJF Scheduling SRT Scheduling Priority Scheduling Multilevel Queue Scheduling Multilevel Feedback Queue Scheduling

First-Come-First-Served The simplest scheduling algorithm is the First-Come-First-Served (FCFS) algorithm, i.e., the process, which requests the CPU, first is allocated the CPU first. Other names of this algorithm are: First-In-First-Out (FIFO) Run-to-Completion Run-Until-Done The FCFS algorithm is simply realized with a FIFO queue. It functions as follows. When a process enters the ready queue, its process control block PCB is linked into the tail of the queue. As soon as the CPU is free, it is allocated to the process located at the head of the ready queue. The running process is then removed from the ready queue.

Round-robin Round-robin scheduling is preemptive algorithm. Each process is assigned a time interval, called its quantum, which it is allowed to run. If the process is still running at the end of the quantum, the CPU is preempted, and given to another process. If the process has blocked or finished before the quantum has elapsed, the CPU switching is done.

Page 61 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The interesting issue with round-robin scheduling is the selection of the quantum length. Switching from one process to another requires certain amount of time for doing the administration, such as saving and loading registers and memory maps, updating various tables and lists etc. This amount of time is called process switch time or context switch time. Suppose this time takes 5 msec. The quantum is set to 20 msec, i.e. after doing 20 msec of useful work, the CPU will have to spend 5 msec on context switching. 20% of the CPU time will be wasted for administrative overhead. If the quantum is set to 500 msec for example, the wasted time will be less than 1%. But imagine what happens if ten interactive users hit the carriage return key at roughly the same time. Ten processes will be put on the list of runnable processes. If the CPU is idle, the first process will start immediately, the second one after 500 msec, and so on. The last one have to wait 5 sec before getting a chance to start, assuming all others use their full quanta. Setting the quantum too short causes too many process switches and decreases the CPU utilization. But setting it to long may cause poor response time.

Shortest-Job-First (SJF) Other name of this algorithm is Shortest-Process-Next (SPN).

Shortest-Job-First (SJF) is a non-preemptive discipline in which waiting job (or process) with the smallest estimated run-time-to-completion is run next. In other words, when CPU is available, it is assigned to the process that has smallest next CPU burst. The SJF scheduling is especially appropriate for batch jobs for which the run times are known in advance. Since the SJF scheduling algorithm gives the minimum average time for a given set of processes, it is probably optimal.

The SJF algorithm favors short jobs (or processors) at the expense of longer ones. The obvious problem with SJF scheme is that it requires precise knowledge of how long a job or process will run, and this information is not usually available.

The best SJF algorithm can do is to rely on user estimates of run times. In the production environment where the same jobs run regularly, it may be possible to provide reasonable estimate of run time, based on the past performance of the process. But in the development environment users rarely know how their program will execute.

Like FCFS, SJF is non preemptive therefore, it is not useful in timesharing environment in which reasonable response time must be guaranteed.

Priority algorithm Priority can be associated with each process depending on how urgently a process should execute. The CPU is then allocated to the process with the highest priority. Equal priority processes are scheduled by the FCFS algorithm.

Page 62 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Priorities can be defined either internally or externally. Internally defined priorities use some measurable quantity or quantities to compute the priority of a process, for example: time limits, memory requirements, the number of open files etc. External priorities are set by criteria that are external to the operating system, such as the type and the amount of funds being paid for computer use and other external, often political factors.

One of the critical problems with priority scheduling algorithms is the indefinite blocking or starvation. A process that is ready to run but lacking the CPU can be considered blocked, waiting for the CPU. A priority-scheduling algorithm can leave some low-priority processes waiting indefinite for the CPU. In a heavy loaded computer system, a steady stream of high-priority processes can prevent a low-priority process from ever getting the CPU.

Another solution to the problem of indefinite blockage of low-priority processes is aging. Aging is the technique of gradually increasing the priority of the processes that wait in the system for a long time. For example, if 0 is the lowest and 127 is the highest priority, we could increment a waiting process's priority by 1 every 15 minutes. Even a process with an initial priority of 0 would have the highest priority in the system and would execute. All the priority algorithms mentioned above are non-preemptive scheduling algorithms, i.e., once the CPU has been allocated to a process, it can keep the CPU until it releases it, either by terminating or by requesting I/O devices. Non-preemptive scheduling algorithms will simply put the new process at the head of the ready queue. For example, FCFS is intrinsically non-preemptive. A preemptive priority scheduling algorithm will preempt the CPU if the priority of the newly arrived process is higher than the priority of the currently running process. When a process arrives at the ready queue, its priority is compared with the priority of the currently running process. Due to the preemptive scheduling algorithm, the new process will execute only if its priority is higher than the priority of the running process.

Multilevel queue scheduling algorithm A multilevel queue scheduling algorithm partitions the ready queue in several separate queues. In a multilevel queue scheduling processes are permanently assigned to one queue. The processes are permanently assigned to one another, based on some property of the process, such as Memory size Process priority Process type Algorithm chooses the process from the occupied queue that has the highest priority, and run that process either Preemptive or Non-preemptively Each queue has its own scheduling algorithm or policy.

Page 63 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Possibility I If each queue has absolute priority over lower-priority queues then no process in the queue could run unless the queue for the highest-priority processes were all empty.

For example, in the above figure no process in the batch queue could run unless the queues for system processes, interactive processes, and interactive editing processes will all empty.

Possibility II If there is a time slice between the queues then each queue gets a certain amount of CPU times, which it can then schedule among the processes in its queue. For instance; 80% of the CPU time to foreground queue using RR. 20% of the CPU time to background queue using FCFS. Since processes do not move between queue so, this policy has the advantage of low scheduling overhead, but it is inflexible.

Multilevel Feedback Queues In multilevel queue scheduling we assign a process to a queue and it remains in that queue until the process is allowed access to the CPU. That is, processes do not move between queues. This is a reasonable scheme as batch processes do not suddenly change to an interactive process and vice versa. However, there may be instances when it is advantageous to move process between queues. Multilevel feedback queue scheduling allows us to do this.

Consider processes with different CPU burst characteristics. If a process uses too much of the CPU it will be moved to a lower priority queue. This will leave I/O bound and (fast) interactive processes in the higher priority queue(s).

Assume we have three queues (Q0, Q1 and Q2). Q0 is the highest priority queue and Q2 is the lowest priority queue. The scheduler first executes process in Q0 and only considers Q1 and Q2 when Q0 is empty. Whilst running processes in Q1, if a new process arrived in Q0, then the currently running process is preempted so that the Q0 process can be serviced.

Any job arriving is put into Q0. When it runs, it does so with a quantum of 8ms (say). If the process does not complete, it is preempted and placed at the end of the Q1 queue. This queue (Q1) has a time quantum of 16ms associated with it. Any processes not finishing in this time are demoted to Q2, with these processes being executed on a FCFS basis.

The above description means that any jobs that require less than 8ms of the CPU are serviced very quickly. Any processes that require between 8ms and 24ms are also serviced fairly quickly. Any jobs that need more than 24ms are executed with any spare CPU capacity once Q0 and Q1 processes have been serviced.

Page 64 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology In implementing a multilevel feedback queue there are various parameters that define the scheduler. The number of queues The scheduling algorithm for each queue The method used to demote processes to lower priority queues The method used to promote processes to a higher priority queue (presumably by some form of aging) The method used to determine which queue a process will enter

Page 65 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 5: Operating Systems Management

Learning Objectives After completing this session, you will be able to: Identify how operating systems perform memory allocations to different processes Identify how the OS manages Files and Directories using File System Memory Management

Need for memory Management For the execution of user programs, the program together with the data required by the programs must be available in the main memory so that the CPU can reference them directly. The organization and management of the main memory/primary memory or real memory of a computer system has been one of the most important factors, which have influenced operating systems design. The primary memory unit is basically a part of the executable memory and is sometimes called the executable memory, since the CPU can fetch instructions from primary/main memory only. Data can be loaded into ALU registers from main memory or stored from the registers into the primary memory. When data and programs are to be executed, they are loaded in primary memory. The memory of a computer system includes all the resources of the computer used for storing information. Secondary memory or secondary storage is a long-term importunate memory, which stores information in storage media such as most commonly used disks drives, drum, and tape drives which provide massive inexpensive capacity for the abundance of programs and data that must be kept readily available for processing. Main or the primary memory has faster access time compared to secondary memory, though it is volatile in nature. As the main memory has a limited storage space, one way is to keep the programs and information in primary memory only while the CPU is using them and to write the information back on to secondary memory soon after it has been used or updated/changed. The schemes employed for organizing and managing a computers storage are discussed in this module. There is always the possibility to build memories that can be accessed at CPU speeds. Registers are such a memory. However, these memories are very expensive, so modern CPUs typically contain fewer registers.

Memory management strategies have evolved with operating systems and hardware technology. Operating system responsibilities in memory management include memory allocation and deallocation efficient utilization of memory and protection of memory areas allocated to a program or process from interference by other programs or processes. There are three aspects to memory management in an operating system such as: Allocation of primary memory at initiation of a program or a process Allocations in response to requests during execution of a program or process Map the process address space into allocated portion of the primary memory Minimize access times using a cost-effective amount of primary memory The memory management unit is responsible for allocating main memory to processes, which belongs to different users of the program, and to protect the memory allocated to each process
Page 66 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology from undesired access by other process. The memory manager should manage the sharing of primary memory and minimize memory access time. It administers the use of the primary memory, including the automatic movement of programs and data back-and-forth between the primary and secondary memories. Memory hierarchy The main memory is usually located on chips inside the system unit. There are has two kinds of memory: random-access memory (RAM) and read-only memory (ROM).

The instructions that the computer gets and the data the processes are kept in RAM during computer works. RAM is not a permanent storage place for information. It is active only when computer is on. If computer is switched off, the information is deleted from RAM. ROM is the memory where information is only read. When the computer is turned off, information is not deleted from ROM. Writing information to ROM is made by vendor. The size of the main memory is measured in megabytes.

The external memory is disk. Unlike information stored in RAM, information stored on a disk is not deleted when the computer is turned off. Information stored on the disks is moved in and out of RAM. The amount of space on a disk is measured in Giga bytes. There are two kinds of disks: hard disk and floppy disk. The main memory and the floppy disk have less storage capacity than the hard disk. The hard disk can write and read information to and from the main memory much faster than a floppy disk. The access speed of main memory is also much faster than a hard disk. Disk-based systems provide the primary on-line storage of information, both program and data. Most programs, like assemblers, sort routines, editors, formatters, and so on, are stored on a disk until loaded into memory, and then use the disk as both the source and destination of the information for their processing. Hence, the proper management of disk storage is of central importance to a computer system.

In a larger sense, however, disks systems are only one of many possible storage systems: registers caches, main memory, disks, and tapes and so on. Each storage system provides the basic functions of storing a piece of data, holding the data until it is retrieved at a later time. The main differences between the various storage systems are their speed, cost, size, and volatility.

We can see a wide variety of storage in a computer system, which can be organized in a hierarchy (Fig.4.5) according to their speed or their cost. The higher levels are expensive, but very fast. As we move down the hierarchy, the cost per bit decreases, while the access time increases and the amount of storage at each level increases. This is reasonable, since if a given storage system was both fatter and cheaper than another, with other properties being the same, there would be no reason to use the slower, more expensive memory.

The design of a computer memory system attempts to balance these factors: using only as much expensive memory as absolutely necessary while trying to provide as much cheap memory as possible. Demand paging is an example of such a system design: a limited amount of expensive, fast main memory is used to provide fast access to a much larger virtual memory which is actually stored on cheaper, slower secondary memory. Main memory can be viewed as a fast cache for secondary memory.

Page 67 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Caching is an important principle of computer systems, both in hardware and software. Cache memory is high speed memory, which interfaces between the processor and main memory. Information is normally stored in some storage system (like main memory). As it is used, it is copied into a faster storage system (the cache) on a temporary basis. When a particular piece of information is needed, we first check if it is in the cache. If it is, we use the information directly from the cache. If not, we use the information from the main storage system, putting a copy in the cache in the hope that it will be needed again.

Since caches have limited size, cache management is an important design problem. Careful selection of cache size and a replacement policy can mean that 80 to 90 percent of all accesses are in the cache, resulting in very high performance.

Cache is placed closer to the processor than the main memory. It is smaller and faster than the main memory. It acts as attraction memory: contains the value of main memory locations which were recently accessed (Temporal Locality). The transfer between caches and main memory is performed in units called cache blocks/lines. Caches contain also the value of memory locations which are close to locations which were recently accessed (Spatial Locality). Mapping between memory and cache is (mostly) static.

Extending this view, internal programmable registers, such as index registers and accumulators, are a high-speed cache for main memory. The programmer (or compiler) implements the register allocation and replacement algorithms to decide what information to keep in registers, and what to keep in main memory. The movement of information between levels of a storage hierarchy may be either explicit or implicit as depicted

Registers

Cache

Main Memory

Secondary memory

Fig: 4.5: Storage hierarchy

Memory management A programs machine language code must be in the computers main memory in order to execute. Assuring that at least the portion of code to be executed is in memory when a processor is assigned to a process is the job of the memory manager of the operating system. This task is complicated by two other aspects as modern computing systems.

Page 68 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The first is multiprogramming. From its definition, we know that multiprogramming mean that several (at least two) processes can be active within the system during any particular time inval. But these multiple active processes result from various jobs entering and leaving the system in an unpredictable manner. Pieces, or blocks, of memory are allocated to these processes when they enter the system, and are subsequently freed when the process leaves the system. Therefore, at any given moment, the computers memory, viewed as a whole, consists of a part of blocks, some allocated to processes active at that moment, and others free and available to a new process which may, at any time, enter the system.

In general, then, programs designed to execute in this multiprogramming environment must be compiled so that they can execute from any block of storage available at the time of the programs execution. Such program is called relocatable programs, and the idea of placing them into any currently available block of storage is called relocation.

The second aspect of modern computing systems affecting memory management is the need to allow the programmer to use a range of program addresses, which may be larger, perhaps significantly larger than the range of memory locations actually available. That is, we want to provide the programmer with a virtual memory, with characteristics (especially size) different from actual memory, and provide it in a way that is invisible to the programmer. This is accomplished by extending the actual memory with secondary memory such as disk. Providing an efficiently operating virtual memory is another task for the memory management facility.

The logical address space is the set of addresses seen by the user (or user process). The physical address space is the set of addresses in physical memory (RAM). The two address spaces need not be the same size and usually arent in most modern systems. In systems with virtual memory, the logical address space is typically much larger than the physical address space. A mapping is a correspondence between a range of virtual addresses and some memory (or a memory-mapped object). The physical location of the memory will be managed by the virtual memory system.

Logical Address Space

Physical Address Space

Logical Address

Address mapping

Physical Address

Fig. 4.6: Address Mapping

Page 69 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Memory Organization The main memory is allocated to the process as when it request for execution. The way how the memory is allocated to the process are Single contiguous memory allocation Partitioned allocation o o Static Partitioning Dynamic Partitioning

The process of partitioning the memory is called as memory organization. There are various ways of dividing the memory into number of partitions, and each partition is allocated to a process while execution. This facilitates the multiprogramming, but before multiprogramming a single process is placed in the memory using single contiguous allocation.

Single Contiguous allocation If we only allow a single process in memory at a time we can make life simple for ourselves. In addition, if we only allow one process to run at any one time then we can make life very simple. That is, the processor does not permit multi-programming and only one process is allowed to be in memory at a time. Using this model we do not have to worry about swapping processes out to disc when we run out of memory. Nor do we have to worry about keeping processes separate in memory.

All we have to do is load a process into memory, execute it and then unload it before loading the next process. However, even this simple scheme has its problems. We have not yet considered the data that the program will operate upon. We are also assuming that a process is self contained in that it has everything within it that allows it to function. This assumes that it has a driver for each device it needs to communicate with. This is both wasteful and unrealistic. We are also forgetting about the operating system routines. The OS can be considered another process and so we have two processes running which means we have left behind our ideal where we can consider that the memory is only being used by one process.

Partitioned Allocation Multi Programming improves CPU Utilization. In a multiprogramming system, memory is divided into a number of fixed size or variable sized partitions or regions which are allocated to running processes. For example: a process needs m words of memory may run in a partition of n words where n m. The variable size partition scheme may result in a situation where available memory is not contiguous, but fragmented into many scattered blocks. We distinguish between internal fragmentation and external fragmentation. The difference (n m) is called internal fragmentation, memory which is internal to a partition but is not being used. If a partition is unused and available, but too small to be used by any waiting process, then it is accounted for external fragmentation. These memory fragments can not be used.

Page 70 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Protection and Sharing: Multiprogramming introduces one essential problem of protection. Not only that the operating system must be protected from user programs/processes but each user process should also be protected from maliciously accessing the areas of other processes. In system that uses base register for relocation, a common approach is to use limit (bound) register for protection. The primary function of a limit register is to detect attempts to access memory location beyond the boundary assigned by the operating system. When a process is scheduled, the limit register is loaded with the highest virtual address in a program. Memory access of a running program is first compared with the contents of the limit register. If it exceeds the limit register, no permission is given to the user process. In this way, any attempt to access a memory location beyond the boundary is trapped.

In addition to protection, a good memory management mechanism must also provide for controlled sharing of data and code between cooperating processes. One traditional approach to sharing is to place data and code in a dedicated common partition. However, any attempt by a participating process to access memory outside of its own participation is normally regarded as a protection violation. In systems with protection keys, this obstacle may be circumvented by changing the keys of all shared blocks upon every process switch in order to grant access rights to currently running process.

Static Partitioned Allocation One method is to divide the memory into fixed sized partitions. The basic approach here is to divide memory into several fixed size partitions where each partition will accommodate only one program for execution. The number of programs (i.e. degree of multiprogramming) residing in memory will be bound by the number of partition. When a program terminates, that partition is free for another program waiting in a queue. When a job arrives, it can be put into an input queue for the smallest partition large enough to hold it. Since the partitions are fixed in this scheme, any space in a partition not used by a job is lost. The unused space within the allocated partition is called as internal fragmentation.

Fixed partitioning imposes several restrictions: No single program/process may exceed the size of the largest partition in a given system. It does not support a system having dynamically data structure such as stack, queue, heap etc. It limits the degree of multiprogramming, which in turn may reduce the effectiveness of short-term scheduling.

In fixed partition the numbers of partitions are fixed but the sizes may either be fixed or varying. The Fig. 4.7 shows an example for the equal sized and unequal sized partition in fixed partitioning.

Page 71 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 4.7: Example of Fixed partition memory of 64 MB memory

Placement algorithm Equal-size partitions o Because all partitions are of equal size, it does not matter which partition is used Unequal-size partitions o o o Can assign each process to the smallest partition within which it will fit Queue for each partition Processes are assigned in such a way as to minimize wasted memory within a partition

Page 72 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The Fig. 4.8 shows the memory assignment for fixed partition

Fig. 4.8: Memory assignment for fixed partitions

Dynamic Partitioned Allocation The main problem with fixed size partition is the wastage of memory by programs that are smaller than their partitions (i.e. internal fragmentation). A different memory management approach known as dynamic partitions (also called variable partition) which creates partitions dynamically to meet the requirements of each requesting process. When a process terminates or becomes swappedout, the memory manager can return the vacated space to the pool of free memory areas from which partition allocations are made. Compared to fixed partitions, in dynamic partitions, neither the size nor the number of dynamically allocated partition need be limited at any other time. Memory manager continues creating and allocating partitions to requesting processes until all physical memory is exhausted or maximum allowable degree of multiprogramming is reached. The main difference between the fixed partition and variable partitions is that the number, location and size of partitions vary dynamically in the latter as processes are created and terminated, whereas they are fixed in the former. The flexibility of not being tied to a fixed number of partitions that may be too large or too small for requesting processes, improves memory utilization but it also complicates the process of allocation and de-allocation of memory. In variable partition, operating system keeps track of which parts of memory are available and which are allocated. The effect of dynamic partitioning is shown in the following figure, Fig. 4.9

Page 73 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 4.9: Effect of dynamic partitioning Example: Assume that we have 64MB main memory available in which 8MB is occupied by operating system program. The process 1 of 20MB enters and it creates the first partition of size 20 MB. The process 2 of size 14MB enters and create second partition of size 14 MB, similarly third by process 3 of its size as 18 MB. There is no wastage of memory as internal fragmentation. The remaining 4MB was left unused. The process 4 is waiting in a queue since only 4M was free it is waiting for 8MB. Once a process 2 released it uses that free space by creating two partition in turn. The unused holes are called external fragmentation. Placement Algorithm Once partitions are defined, operating system keeps track of status (whether allocated or free) of memory partitions. This is done through a data structure called partition description table. Using this PDT the OS allocates the partition for the incoming process.

The common strategies to allocate free partitions to ready processes are: Best-fit algorithm o Chooses the block that is closest in size to the request o Worst performer overall o Since smallest block is found for process, the smallest amount of fragmentation is left o Memory compaction must be done more often

Page 74 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology First-fit algorithm o o o Scans memory form the beginning and chooses the first available block that is large enough Fastest May have many process loaded in the front end of memory that must be searched over when trying to find a free block

Next-fit o Scans memory from the location of the last placement o More often allocate a block of memory at the end of memory where the largest block is found o The largest block of memory is broken up into smaller blocks o Compaction is required to obtain a large block at the end of memory Worst-fit o o o o o Allocate the largest hole It must also search entire list It produces the largest leftover hole The largest block of memory is broken up into smaller blocks Compaction is required to obtain a large block at the end of memory

The following figure, Fig. 4.10 shows the allocation example in dynamic partitioning.

Fig. 4.10: Example of memory configuration before and after allocation of 16MB block

Page 75 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Advantages One advantage with variable partition is that memory utilization is generally better than fixed size partitions, since partitions are created accordingly to the size of process. Protection and sharing in static and dynamic partitions are quite similar, because of same hardware requirement except for some additional consideration due to compaction of memory during dynamic partitioning.

One advantage of dynamic partitioning is to support processes whose memory requirement increases during their execution. In that case operating system creates a larger partition and moves a process into it. If there is an adjacent free area it simply expands it. Disadvantages Dynamic memory management requires lots of operating system space, time, complex memory management algorithm and bookkeeping operations. Paged Memory Physical memory is divided into fixed size blocks called frames. Logical memory is also divided into blocks of the same, fixed size called pages. When a program is to be executed, its pages are loaded into any available memory frames from the disk. The disk is also divided into fixed size, which is the same size as the memory frames. The page table or page map table is created when the process is allocated to the main memory.

Fig. 4.11: Assignment of process pages to free frames

Fig. 4.12: Page Table for the process allocated in main memory

Page 76 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The above figures, Fig. 4.11 and Fig. 4.12 show the allocation of process to paged memory and the PMT created for the same.

The logical address consists of two parts page number and an offset. The address translation is as follows: Extract the page number Using this as an index to PMT find the frame number Combine the frame number and offset to find the physical address

Fig 4.13 Address Translation for the paging system

The Fig. 4.13: shows the address translation for the paging system.

Segmented Memory Management The process is divided into number of segments. All segments of all programs do not have to be of the same length. There is a maximum segment length. When a process is allocated in main memory a segment table is created which consist of base and bound for each segments. Addressing consist of two parts - a segment number and an offset. Since segments are not equal, segmentation is similar to dynamic partitioning. The address translation is as follows: Extract the segment number Use that as an index and find base and the bound for the segment from SMT Compare the offset with the bound Add base and the offset to calculate the physical address

Page 77 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The address translation for an logical address is shown in the following figure, Fig. 4.14

Fig. 4.14: Address Translation for a logical address

Virtual memory management With a batch system, fixed partitioning of memory is simple and effective. With timesharing systems and graphically oriented personal computers, the situation is different. Sometimes there is not enough main memory to hold all the currently active processes, so excess processes must be kept on disk and brought in to run dynamically.

Wherever a new process is ready to be loaded into memory and if no partition is free, swapping of processes between main memory and secondary storage is done. Swapping helps in CPU utilization by replacing suspend able processes but residing into main memory with ready to execute processes from secondary storages. When the scheduler admits a new process (of high priority) for which no partition is free, a memory manager is invoked to make a partition free to accommodate the process. The memory manager performs this task by swapping out low priority processes suspended for a comparatively long time in order to load and execute the higher priority process. When the higher priority process is terminated, the lower priority process can be swapped back and continued. Swapping requires secondary storage device such as fast disk to store the suspended processes from main memory. One problem with swapping process is that it takes a long time to access process from the secondary storage device. The overhead must be considered when deciding whether to swap a process in order to make room for another process.

The other strategy, called virtual memory, allows programs to run even when they are only partially in main memory. Most modern Operating systems use this concept and swapping is now used in conjunction with Virtual Memory.

Page 78 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology In general, real user programs don't need to be completely in system memory while they execute. For example: programs often have code to handle unusual error events, which very rarely occur in practice. This code is almost never executed. Even in those cases where the entire program is needed, it's not necessary for all parts of the program to be in memory at the same time. Executing a program that is partially in memory can have many benefits, not only for users but also for the system: A program is no longer limited by the size of physical memory that is available. Writing a program in a large virtual address space is more convenient. Because each user may take less physical memory, more user can be run at the same time. The CPU utilization and the system throughput may increase. Less I/O operation would be needed to load users into memory, so each user could run faster. Virtual memory management allows the execution of processes that are partially in system memory. So programming with very large virtual memory is possible Most modern computers have special hardware called a memory management unit (MMU). This unit sits between the CPU and the memory unit. On any computer , there exists a set of memory addresses that programs can produce. These program generated addresses are called virtual addresses and form the virtual address space. Whenever the CPU wants to access memory (whether it is to load an instruction or load or store data), it sends the desired memory address to the MMU, which translates it to another address before passing it on the memory unit. The Memory Management Unit maps these virtual addresses to the physical ones.

The virtual address space is divided up into units called pages. The corresponding units in physical memory are called page frames. The pages and page frames are always the same size. The address generated by the CPU, after any indexing or other addressing-mode arithmetic, is called a virtual address, and the address it gets translated to by the MMU is called a physical address.

Fig. 4.15: Virtual Address Translation

Normally, the translation is done at the granularity of a page. Each page is a power of 2 bytes long, usually between 1024 and 8192 bytes. If virtual address p is mapped to physical address f (where p is a multiple of the page size), then address p+o is mapped to physical address f+o for any offset o less than the page size. In other words, each page is mapped to a contiguous region of physical memory called a page frame.

Page 79 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The MMU allows a contiguous region of virtual memory to be mapped to page frames scattered around physical memory making life much easier for the OS when allocating memory. Much more importantly, however, it allows infrequently-used pages to be stored on disk. Here's how it works: The tables used by the MMU have a valid bit for each page in the virtual address space. If this bit is set, the translation of virtual addresses on a page proceeds as normal. If it is clear, any attempt by the CPU to access an address on the page generates an interrupt called a page fault trap. The OS has an interrupt handler for page faults, just as it has a handler for any other kind of interrupt. It is the job of this handler to get the requested page into memory.

Fig. 4.16: Transfer from disk to Page Frames

Conceptually, the MMU contains a page table, which is simply an array of entries indexed by page number. Each entry contains some flags (such as the valid bit mentioned earlier) and a frame number. The physical address is formed by concatenating the frame number with the offset, which are the low-order bits of the virtual address.

Fig. 4.17: Physical Address Calculation

Page 80 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 4.18: Paging Hardware

There are two problems with this conceptual view. First, the lookup in the page table has to be fast, since it is done on every single memory reference--at least once per instruction executed (to fetch the instruction itself) and often two or more times per instruction. Thus the lookup is always done by special-purpose hardware. Even with special hardware, if the page table is stored in memory, the table lookup makes each memory reference generated by the CPU cause two references to memory. Since in modern computers, the speed of memory is often the bottleneck (processors are getting so fast that they spend much of their time waiting for memory), virtual memory could make programs run twice as slowly as they would without it.

What is a Page Fault? A virtual address space is implemented using a combination of physical memory, backing storage, and memory management data structures known as page tables. The operation known as paging is a transition, and refers to the relocation of the contents of memory between physical memory and backing storage, or from the memory allocated to a process to one of the various system-defined pools of pages of physical memory, or from one of these pools to a process, or from one of these pools to backing storage.

Examples of events that trigger page faults include references to any portion of virtual address space that is not currently valid, meaning that there is currently no physical memory associated with the virtual memory. Depending on tracking information in the page tables, resolving this page fault may require acquiring and initializing a page of physical memory from a list of free pages, acquiring the previous contents from a cache of modified pages, or acquiring a free physical page and reloading the previous contents of the virtual page from the backing storage area. The page tables track the translation of virtual address space into the associated physical memory, or to the contents of the memory page in the backing storage area. A page fault is an event that is triggered when a page is to be moved. ("Traps" and "faults" are basic reporting mechanisms. A "trap" occurs at the end of the processing of an instruction, while a "fault" occurs during the processing of an instruction. An AST is based on a trap. A page fault occurs during the processing of an instruction, and means that the instruction must be restarted once the paging completes and the virtual memory is valid.)

Page 81 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Page Replacement Algorithms The algorithms to follow when there exists more page frames than can fit in memory. Which page should be replaced? Local replacement - Replace a page of the faulting process Global replacement - Possibly replace the page of another process

FIFO (First-in, first-out) Keep the page frames in an ordinary queue, moving a frame to the tail of the queue when it loaded with a new page, and always choose the frame at the head of the queue for replacement. In other words, use the frame whose page has been in memory the longest. While this algorithm may seem at first glance to be reasonable, it is actually about as bad as you can get. The problem is that a page that has been memory for a long time could equally likely be ``hot'' (frequently used) or ``cold'' (unused), but FIFO treats them the same way. In fact FIFO is no better than, and may indeed be worse than

RAND (Random) Simply pick a random frame. This algorithm is also pretty bad.

OPT (Optimum) Pick the frame whose page will not be used for the longest time in the future. If there is a page in memory that will never be used again, it's frame is obviously the best choice for replacement. Otherwise, if (for example) page A will be next referenced 8 million instructions in the future and page B will be referenced 6 million instructions in the future, choose page A. This algorithm is sometimes called Belady's MIN algorithm after its inventor. It can be shown that OPT is the best possible algorithm, in the sense that for any reference string (sequence of page numbers touched by a process), OPT gives the smallest number of page faults. Unfortunately, OPT, like SJF processor scheduling, is not implementable because it requires knowledge of the future. It's only use is as a theoretical limit.

LRU (Least Recently Used) Pick the frame whose page has not been referenced for the longest time. The idea behind this algorithm is that page references are not random. Processes tend to have a few hot pages that they reference over and over again. A page that has been recently referenced is likely to be referenced again in the near future. Thus LRU is likely to approximate OPT. LRU is actually quite a good algorithm. There are two ways of finding the least recently used page frame. One is to maintain a list. Every time a page is referenced, it is moved to the head of the list. When a page fault occurs, the least-recently used frame is the one at the tail of the list. Unfortunately, this approach requires a list operation on every single memory reference, and even though it is a pretty simple list operation, doing it on every reference is completely out of the question, even if it were done in hardware. An alternative approach is to maintain a counter or timer, and on every reference store the counter into a table entry associated with the referenced frame. On a page fault, search through the table for the smallest entry. This approach requires a search through the whole table on each page fault, but since page faults are expected to tens of thousands of times less frequent than memory references, that's ok. A clever variant on this scheme is to maintain an n by n array of bits, initialized to 0, where n is the number of page frames. On a reference to page

Page 82 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology k, first set all the bits in row k to 1 and then set all bits in column k to zero. It turns out that if row k has the smallest value (when treated as a binary number), then frame k is the least recently used.

Unfortunately, all of these techniques require hardware support and nobody makes hardware that supports them. Thus LRU, in its pure form, is just about as impractical as OPT. Fortunately, it is possible to get a good enough approximation to LRU (which is probably why nobody makes hardware to support true LRU).

NRU (Not Recently Used) There is a form of support that is almost universally provided by the hardware: Each page table entry has a referenced bit that is set to 1 by the hardware whenever the entry is used in a translation. The hardware never clears this bit to zero, but the OS software can clear it whenever it wants. With NRU, the OS arranges for periodic timer interrupts (say once every millisecond) and on each ``tick,'' it goes through the page table and clears all the referenced bits. On a page fault, the OS prefers frames whose referenced bits are still clear, since they contain pages that have not been referenced since the last timer interrupt. The problem with this technique is that the granularity is too coarse. If the last timer interrupt was recent, all the bits will be clear and there will be no information to distinguished frames from each other.

SLRU (Sampled LRU) This algorithm is similar to NRU, but before the referenced bit for a frame is cleared it is saved in a counter associated with the frame and maintained in software by the OS. One approach is to add the bit to the counter. The frame with the lowest counter value will be the one that was referenced in the smallest number of recent ``ticks''. This variant is called NFU (Not Frequently Used). A better approach is to shift the bit into the counter (from the left). The frame that hasn't been reference for the largest number of ``ticks'' will be associated with the counter that has the largest number of leading zeros. Thus we can approximate the least-recently used frame by selecting the frame corresponding to the smallest value (in binary). (That will select the frame unreferenced for the largest number of ticks, and break ties in favor of the frame longest unreferenced before that). This only approximates LRU for two reasons: It only records whether a page was referenced during a tick, not when in the tick it was referenced, and it only remembers the most recent n ticks, where n is the number of bits in the counter. We can get as close an approximation to true LRU as we like, at the cost of increasing the overhead, by making the ticks short and the counters very long.

Second Chance When a page fault occurs, look at the page frames one at a time, in order of their physical addresses. If the referenced bit is clear, choose the frame for replacement, and return. If the referenced bit is set, give the frame a ``second chance'' by clearing its referenced bit and going on to the next frame (wrapping around to frame zero at the end of memory). Eventually, a frame with a zero referenced bit must be found, since at worst, the search will return to where it started. Each time this algorithm is called, it starts searching where it last left off. This algorithm is usually called CLOCK because the frames can be visualized as being around the rim of an (analogue) clock, with the current location indicated by the second hand.

Page 83 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

File System Management Overview of Files File system is a service, which supports an abstract representation of the secondary storage supported by the operating system. Files are basically named unit of storage defined by the operating system. The storage is the same regardless of the underlying hardware. It is defined as a sequence of bits, bytes or records. File systems are implemented primarily on disks. Although other media are used, most of the ideas about implementing file systems were developed with disks in mind. File system provides access on permanent media to named files. Files can be stored on storage media like hard disks, removable hard drives such as floppy drive, zip drive, read-only medium like CDROM, tape etc. Files store data and programs. The operating system implements the abstract concept of a file by managing mass storage devices, such as tapes and disks. Also files are normally organized into directories to ease their use, so we look at a variety of directory structures. Finally, when multiple users have access to files, it may be desirable to control by whom and in what ways files may be accessed. This control is known as file protection.

File management is one of the most visible services of an operating system. Computers can store information in several different physical forms; magnetic tape, disk, and are the most common forms. Each of these devices has its own characteristics and physical organization.

File management system is considered part of the operating system Manages a trusted, shared resource Bridges the gap between: o low-level disk organization (an array of blocks), and the user's views (a stream or collection of records)

Also includes tools outside the kernel; E.g. formatting, recovery, defrag, consistency, and backup utilities. Objectives for a File Management System; o o o o o o o o Provide a convenient naming system for files Provide uniform I/O support for a variety of storage device types Provide a standardized set of I/O interface routines Guarantee that the data in the file are valid Optimize performance Minimize or eliminate the potential for lost or destroyed data Provide I/O support and access control for multiple users Support system administration (e.g., backups)

For convenient use of the computer system, the operating system provides a uniform logical view of information storage. The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, the file. Files are mapped by the operating system onto physical devices. Consequently, a file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. Data files may be numeric, alphabetic or alphanumeric. Files may be free form, such as text files, or may be rigidly formatted. In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by its creator and user. It is a very general concept.

Page 84 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A file is named and is referred to by its name. It has certain other properties such as its type, the time of its creation, the name (or account number) of its creator, its length, and so on. File system must provide a convenient naming scheme Textual Names May have restrictions o Only certain characters, E.g. no `/' characters o Limited length o Only certain format, E.g DOS, 8 + 3 Case (in)sensitive Names may obey conventions (.c files or C files) o o Interpreted by tools (UNIX) Interpreted by operating system (Windows)

One major consideration is how much of this structure should be known and supported by the operating system. If an operating system knows the structure of a file, it can then operate on the file in reasonable ways. For example, a common mistake occurs when a user tries to print the binary object form of a program. This attempt normally produces garbage, but can be prevented if the operating system has been told that the file is a binary object program.

Often when the user attempts to execute an object program whose source file has been modified (edited) since the object file was produced, the source file will be recompiled automatically. This function ensures that the user always runs an up-to-date object file. Otherwise, the user could waste a significant amount of time executing the old object file. Notice that in order for this function to be possible, the operating system must be able to identify the source file from the object file, check the time that each file was last modified or created, and determine the language of the source program (in order to use the correct compiler).

There are disadvantages to having the operating system know the structure of a file. One problem is the resulting size of the operating system. If the operating system defined fourteen different file structures, it must then contain the code to support these file structures correctly. In addition, every file must be definable as one of the file types supported by the operating system. Severe problems may result from new applications that require information structured in ways not supported by the operating system.

Files are usually kept on disks. Disk systems typically have a well-defined block size determined by the size of a sector. All disk I/O is in units of one block (physical record), and all blocks are the same size. It is unlikely that the physical record size will exactly match the length of the desired logical record. Logical records may even vary in length packing a number of logical records into physical blocks is a common solution to this problem. The operating system often defined all files to be simply a stream of bytes. Each byte is individually addressable by its offset from the beginning (or end) of the file. In this case, the logical record is one byte. The file system automatically packs and unpacks bytes into physical disk blocks as necessary.

Page 85 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Knowledge of the logical record size, physical block size and packing technique determine how many logical records are packed into each physical block. The packing can be done either by the users application program or by the operating system.

In either case, the file may be considered to be a sequence of blocks. All of the basic I/O function operates in terms of blocks. The conversion from logical records to physical blocks is relatively simple software problem.

Notice that allocating disk space in blocks means that, in general, some portion of the last block of each file may be wasted. If each block is 512 bytes, then a file of 1949 bytes would be allocated 4 blocks (2048bytes); the last 99 bytes would be wasted. The wasted bytes allocated to keep everything in units of blocks (instead of bytes) are internal fragmentation. All file systems suffer from internal fragmentation. In general, large block sizes cause more internal fragmentation. File Operations A file is an abstract data type. To define a file properly, we need to consider the operations, which can be performed on files. System calls are provided to create, write, read, rewind, and delete files. To understand how file systems are supported, let us look at these file operations in more detail. For convenience, assume the file system is disk-based. Let us consider what the operating system must do for each of the five basic file operations. It should then be easy to see how similar operations, such as renaming a file, would be implemented. Creating a file. Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, an entry for the new file must be made in the directory. The directory entry records the name of the file and its location in the file system. Writing a file. To write a file, a system call is made specifying both the name of the file and the information to be written to the file. Given the name of the file, the system searches the directory to find the location of the file. The directory entry will need to store a pointer to the current end of the file. Using this pointer, the address of the next block can be computed and the information can be written. The write pointer must be updated. In this way successive writes can be used to write a sequence of block to the file. Reading a File. To read from a file, a system call specifies the name of the file and where (in memory) the next block of the file should be put. Again, the directory is searched for the associated directory entry. And again, the directory will need a pointer to the next block to be read. Once that block is read, the pointer is updated. Access/modification: When the information from the file is used, it should be accessed and read to main memory. After being used, memory contents should be written back to disk. Two main access methods are: o Sequential access o Direct (Random) access Reposition: Set current file position to a specified value. This operation does not require the actual I/O but might be restricted by access method. Deleting: Find the proper directory entry. Release all the file space and erase the entry. Truncating: Saves all attributes of the file, but resets the size to zero.

Page 86 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Appending, Renaming, Copy: Can be constructed from create, truncate, read/write and delete operation or implemented independently. Open/Close: Some systems allow using file by more then one user. In this case it is demanded, that file would be opened/closed explicitly. Open operations would put the entry into local process file table and check global file table for correspondent entry. If the entry was found, open counter would be incremented by one, else new entry would be created. Close operations would decrement open counter of correspondent entry in the global table. If counter becomes zero, the entry will be deleted from the global table. In general, a file is either being read or written, thus although it would be possible to have two pointers, a read pointer and a write pointer, most systems have only one, a current file position. Both the read and write operations use this same pointer, saving space in the directory entry, and reducing the system complexity. Rewind a file. Rewinding a file need not involve any actual I/O rather the directory is searched for the appropriate entry, and the current file position is simply reset to the gaining of the file. Delete a file. To delete a file, we search the directory for the named file. Having found the associated directory entry, we release all file space (so it can be reused by other files) and invalidate the directory entry.

It is known that all of the operations mentioned involve searching the directory for the entry associated with the named file. The directory entry contains all of the important information needed to operate on the file. To avoid this constant searching, many systems will open a file when it first becomes actively used. The operating system keeps a small table containing information about all open files. When a file operation is requested, only this small table is searched, not the entire directory. When the file is no longer actively used, it is closed and removed from the table of open files.

Some systems implicitly open a file when the first reference is made to it. The file is automatically closed when the job or program that opened the file terminates. Most systems, however, require that a file be opened explicitly by the programmer with a system call (open) before it can be used. The open operation takes a file name and searches the directory, copying the directory entry into the table of open files. The (open) system call will typically return a pointer to the entry in the table of open files. This pointer, not the actual file name, is used in all I/O operations, avoiding any further searching.

The nine operations described above are certainly the minimal required file operations. More commonly, we will also want to edit the file and modify its contents. A common modification is appending new information to the end of an existing file. We may want to create a copy of a file, or copy it to an I/O device, such as a printer or a display. Since files are named objects, we may want to rename an existing file.

Page 87 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology File Access Files store information. This information must be accessed and read into computer memory before it is used. There are several ways the information in the file can be accessed. Some systems provide only one access method for files, and so the concept is less important. On other systems, such as those of IBM, many different access methods are supported, and choosing the right one for a particular application is a major design problem.

The information stored in a file can be accessed in a variety of methods: Sequential access o in order, one record after another o read all bytes/records from the beginning o cannot jump around, could rewind or back up o convenient when medium was mag tape Random (Direct) access o o o bytes/records read in any order skipping the previous records essential for data base systems read can be Move file pointer (seek), then read or Each read specifies the file pointer Keyed; in any order, but with particular value(s); e.g., hash table or dictionary. TLB lookup is one example of a keyed search

Other access methods, such as indexed, can be built on top of the above basic techniques.

Sequential Access Information in the file is processed in order, one record after the other. This is by far the most common mode of access of files. For example, editor programs usually access files in this fashion. The read operation on a file automatically advances the file pointer. Similarly a write appends the new information to the end of the file, and advances the file pointer to the new end. Such a file can be rewound, and on some systems, a program may be able to skip forward or back n records, for some integer n (perhaps only for n = 1). This scheme is known as sequential access to a file. Sequential access is based upon a tape model of a file.

Direct Access An alternative access method is direct access, which is based upon a disk model of a file. For direct access, the file is viewed as a numbered sequence of blocks or records. A direct access file allows arbitrary blocks to be read or written. Thus we may read block 14, then read block 53, and then write block 7. There are no restrictions on the order of reading or writing for a direct access file.

Direct access files are of great use for immediate access to large amounts of information. They are often used in accessing large databases. When a query concerning a particular subject arrives, we compute which block contains the answer and then read that block directly to provide the desired information.

Page 88 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The file operations must be modified to include the block number as a parameter. Thus we have to read block n, where n is the block number, rather than read the next, and write block n rather than write the next. An alternative approach is to retain read next and write next, as with sequential access, and to add an operation, position file to n, where n is the block number. Then to perform a read block n, we would position to block n and then read next.

The block number provided by the user to the operating system is normally a relative block number. A relative block number is an index relative to the beginning of the file. Thus the first relative block of the file is 0, the next...is 1, and so on, even though the actual absolute disk address of the block may be 14703 for the first block, and 14704 for the second. The use of relative block numbers allows the operating system to decide where the file should be placed, and prevents the user from accessing portions of the file system that may not be part of his file. Some systems start their relative block number at 0; others start at 1.

Not all operating systems support both sequential and direct access for files. Some systems allow only that a file is defined as sequential or direct when it is created; such a file can only be accessed in a manner consistent with its declaration.

Other Access Methods Other access method can be built on top of a direct access method. These additional methods generally involve the construction of an index for the file. The index, like an index in the back of a book, contains pointers to the various blocks. To find an entry in the file the index is consulted first.

With large files the index file itself may become too large to be kept in memory. One solution is then to create an index for the index file. The primary index file would contain pointers to secondary index files which then point to the actual data items. Files are represented by entries in a device directory or volume table of concerns. The device directory records information, such as name, location, size, and type, for all files on that device.

A device directory may be sufficient for a single-user system with limited storage space. As the amount of storage and the number of users increase, however, it becomes increasingly difficult for the users to organize and keep track of all of the files on the file system. A directory structure provides a mechanism for organizing the many files in the file system. It may span device boundaries and include several different disk units. In this way, the user need be concerned only with the logical directory and file structure, and can completely ignore the problems of physically allocating space for files.

In fact, many systems actually have two separate directory structures: the device directory and the file directories. The device directory is stored on each physical device and describes all files on that device. The device directory entry mainly concentrates on describing the physical properties of the files: where it is, how long it is, how it is allocated, and so on. The file directories are a logical organization of the files on all devices. The file directory entry concentrates on logical properties of each name: file, file type, owing user, accounting information, protection access code, and so on. A file directory entry may simply point to the device directory entry to provide physical properties or may duplicate this information. Our main interest now is with the file directory structure; device directories should be well understood.

Page 89 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The particular information kept for each file in the directory varies from operating system to operating system. The following is a list of some of the information, which may be kept in a directory entry. Not all systems keep all this information, of course. File name. The symbolic file name. File type. For those systems that support different types. Location. A pointer to the device and location on that device of the file. Size - The current size of the file (in bytes, words of blocks) and the maximum all owner size. Current Position - A pointer to the current read or write position in the file. Protection. Access control information of the number of processes that are currently using (have opened) this file. Time, date and process identification. This information may be kept for (a) creation, (b) last modification, and (c) last use. These can be useful for protection and usage monitoring.

It may take from 16 to over 100 bytes to record this information for the each file. In a system with a large number of files, the size of the directory itself may be hundreds of thousands of bytes. thus the device directory may need to be stored on the device and brought into memory piecemeal, as needed. More specifically, when a file is open, the directory information about this file is brought into main memory. This information remains there until the file is closed.

If we think of the directory as a symbol table that translates file names into their directory entries, it becomes apparent that the directory itself can be organized in many ways. We want to be able to insert entries, delete entries, search for a named entry and list all the entries in the directory. Next we consider what data structure is used for the directory.

A linear list of directory entries requires a linear search to find a particular entry. This is simple to program but time consuming in execution. To create a new file, we must firt search the directory to be sure that no existing file has the same name. Then we can add a new entry at the end of the directory. To delete a file, we search the directory for the named file, then release the space allocated to it. To reuse the directory entry, we can do one of several things. We can mark it unused (a special name such as an all-blank name, or a used/unused bit in each entry), or attach it to a list of free directory entries. A third alternative is to copy the last entry in the directory in the freed location and decrease the length of the directory. A linked list can also be used to decrease the time to delete a file.

The real disadvantage of a linear list of directory entries is the linear search to find a file. A sorted list allows a binary search, and decreases the average search time. However, the search algorithm is more complex to program. In addition, the list must be kept sorted. This requirement may complicate creating and deleting files, since we may have to move substantial amounts of directory information to maintain a sorted directory. (Notice, however, that if we want to be able to produce a list of all files in a directory sorted by file name, we do not have to sort before listing). A linked binary tree might help here.

Page 90 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Directories Many different file directory structures have been proposed, and are in use. The directory is essentially a symbol table. The operating system takes the symbolic file name and finds the named file. We examine some directory structures here in figures. Fig. 4.19, 4.20, 4.21

Fig. 4.19: Single level Directory Systems

Fig. 4.20: Two-level Directory Systems

Fig. 4.21: Hierarchical Directory systems

Many different file directory structures have been proposed, and are in use. The directory is essentially a symbol table. The operating system takes the symbolic file name and finds the named file. We examine some directory structures here.

Page 91 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Directory Structure Organization When considering a particular directory structure, we need to keep in mind the operations, which are to be performed on a directory. Search. We need to be able to search a directory structure to find the entry for a particular file. Since files have symbolic names, and similar names may indicate a relationship between the files, we may want to be able to find all files that match a particular pattern. Create File. New files need to be created and added to the directory. Delete File. When a file is no longer needed, we want to remove it from the directory. List Directory. We need to be able to list the files in a directory and the contents of the directory entry for each file in the list. Backup. For reliability, it is generally a good idea to save the contents and structure of the file system at regular intervals. This often consists of copying all files to magnetic tape. This provides a backup copy in use. In this case, the file can be copied to tape and the disk space of that file released for reuse by another file.

The implementation of Directory is given below:

Linear List (Unsorted) Linear List of filenames with pointers to data blocks Search of each entry may involve going through the whole list. Create file methods: search the list of the file with the same name, if not found, add new entry to the end of the list or insert it to the first unused entry spot. Delete file: search list for the named file, add all the space of the file to the free space list, make some step, that allow reusing the entry. Possible steps of reusing an entry: give an entry special name, associate used bit with each entry, copy the last entry to the freed spot and keep track of list size, keep list of free directory entries, use the linked list implementation for the list. Advantages: Simplicity and Universality. Disadvantages: Traversing the whole directory list takes a lot of disk reads which makes search very slow

Sorted Linear List List of filenames sorted in alphabetical order with pointers to datablock Search takes only logarithmical number of entry checks Create file method: find the proper position of the new entry, reposition the rest of the list, insert new entry to the proper position. Delete file method: find the entry and release the files space, shift the rest of the list back at one entry. Advantages: Faster search and Universality. Disadvantages: Many write operations are involved to create/delete a file. Linked list cannot be used for simplifying delete/create operation.

Page 92 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Balanced Tree or Tree-like structure Search in average takes only logarithmical time. Create/Delete methods in average take logarithmical number of repositioning. Advantages: Faster method implementation might be better for certain logical directory structures. Disadvantages: Sophisticated, possible source of errors. Programming overheads and does not represent Graph logical structure for the directory in a reasonable way.

Hash Table Entries are stored in the linear list. Hast function is used to map the filename into entry lndex. To search, create or delete a file need to just convert the name into index, using hash function. Need some mechanism to resolve collisions. Advantages: All methods implementation is fast and simple and Universal. Disadvantages: Resizing issue.

Space allocation techniques for files and directories The most important characteristic of the disk secondary storage are: Disk is divided on fixed size blocks All I/O transfers between memory and disk are performed in units of blocks Any information is allocated and stored on the disk in blocks. Information, stored on disk can be modified on place. Disk supports both sequential and random access. To get any particular block from disk is just the matter of time.

These characteristics more or less define how files are implemented on the low level. Any file on the low level can be viewed as the collection of blocks. To access/modify any particular information in the file we need to read corresponding block from this collection into memory and offset correspondingly. The general issue with any file implementation is internal fragmentation. But there are some issues such as reliability, access rate, effective space usage, convenience, which can be treated differently. Depending on addressing, the major types of file allocation (which defines the implementation): Contiguous Allocation Linked Allocation File Allocation Table Index Allocation

Page 93 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Contiguous Allocation Uses the ideas of contiguous multiple partition memory allocation with allocation unit equal to one block Each file occupies contiguous set of blocks on the disk Disk addresses define the linear ordering of blocks on the disk All information about file location property is implemented through file starting block and file size in blocks To create the file of specified size, the disk hole that is good enough for the file should be found using the chosen algorithm for finding the hole. Then correspondent entry should be made in directory. To access information in the file need to find number B of the block on which this information resides and access the disk block number starting block + B. Supports sequential and random access equally efficiently. Problems: Effectiveness of space usage: finding the free space for the file, external fragmentation, and pre-allocation for the file leads to internal fragmentation. Convenience: need to specify the file size upfront, which is not trivial task for user, if file size is not specified properly difficult to resize. Two ways to deal with resizing issue o Rely on user declaration of the size. If file exceeds declared size terminates modification and let user to reallocate bigger size. This way is also the least convenient. Let the system relocate file into bigger hole, when the original hole is overgrown.

Linked Allocation File is implemented as linked list of blocks Directory entry contains the head and tail block numbers Each block contains the number of next block. Last block contains invalid number. To create a new file just create directory entry with negative head and tail block numbers. Write causes a free block to be found and added to the tail of the list with changing tail block number in directory. To read need read blocks from the head to desired block in order No external fragmentation No resizing issues. Problems: Unequally supports sequential and random access. Random is much slower. Space required for pointers. This problem can be decreased through allocating and accessing files by clusters. If one block is corrupted all the rest blocks of file are inaccessible. This also leads for ineffectively used space. Possibility to be linked to wrong block due to read error can damage big part of file system that doesnt belong to this particular file.

Page 94 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology File Allocation Table (FAT) Variation of linked allocation Section of the disk at the beginning of each partition is reserved for FAT. FAT has one entry for each disk block and is indexed by block number If the block number B belongs to the file, then B-th entry to the FAT is number of next block in the file. If the block number B is not used by the file, the B-th entry to the FAT is 0 If the block number B is the last block of the file, the B-th entry to the FAT is end_of_file, which is specially defined by the OS number

Problems If FAT is not cached, slows the sequential access Reliability

Advantage Locality of addresses improved. This eases the reliability control and improves random access rate Incorporate the free space management data in the same table.

Indexed Allocation Similar to paging memory allocation Blocks are allocated to the file from wherever free disk space is found Each file has additional index block, the number of index block is contained by directory entry. Index block implements location property. Index block contains number of blocks allocated to the file in order of allocation.

Advantage: No external fragmentation and equal support for sequential and random access

Page 95 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Summary Primary functions of an OS are: o o o o Memory Management Process Management Device Management File and Information Management

A process is a program in execution A process life cycle runs through the states New, Ready, Running, Blocked, Completed in a deterministic manner. Processes are allocated to the CPU as per some standard non-preemptive and preemptive algorithms. Single contiguous memory allocation is used for small operating system with no special requirement for hardware and software. Partitioned memory allocation is of two types, Static Partitioning and Dynamic Partitioning. A file system, also referred to as a file management system or file system, is exactly what its name implies - the mechanism that an operating system or program uses to organize and keep track of files. File system provides the access methods for accessing files, maintains directory structures, and does the directory implementation.

Page 96 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 6: I/O Interfacing

Learning Objectives After completing this module, you will be able to: Understand Hardware I/O, Programmed I/O, Memory Mapped I/O Understand Direct Memory Access Understand how computer I/O devices work Overview In previous sessions, we discussed about hardware and software features of processors, memories. We also discussed the means by which a computer communicates with external devices, including the hardware and software facilities. This session presents the characteristics of some commonly used computer peripherals and how they are connected in a computer system

The name peripheral refers to any external device connected to a computer. In this context, the computer consists only of the processor and its memory. Computer peripherals can be divided into two categories. The first category contains devices that perform input and output operations, such as the keyboard, mouse, printer and video display. The second category contains devices intended primarily for secondary storage of data, with primary storage being provided by the main memory of the computer. Some mass storage devices, in particular magnetic disks, are used for on-line storage of data. In others, such as optical disks, floppy disks, and magnetic tapes, the storage medium can be removed from the drive unit for transferring data from one computer system to another. For example, the device most often used for distributing software is the CDROM or DVD.

Today, among the most important computer peripherals are devices that provide connection to the Internet. Much of the tremendous growth in the computer field in recent years is a result of the synergy between computers and communications, and the emergence of many innovative applications on the World Wide Web. These developments have touched every aspect of our lives, from business to entertainment and education.

I/O hardware consists of mechanical and electronic components. A mechanical component is the device, while the electronic component is the device controller.

Connection of I/O bus to input output devices

Page 97 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

I/O bus
Processor

Data Address Control

Interface

Interface

Interface

Interface

Keyboard and display terminal

Printer

Magnetic disc

Magnetic tape

Fig 5.1: I/O Bus and I/O devices

Fig 5.1 shows the way the I/O devices and the CPU are connected to the I/O Bus. Accessing I/O Devices Most modern computers use single bus arrangement for connecting I/O devices to CPU & Memory Bus consists of a set of 3 lines -: Address, Data, and Control Processor places a particular address on address lines Device which recognizes the address responds to the commands on Control lines Processor requests for either Read / Write (i.e., Input / Output) The data will be placed on the Data lines Any machine instruction that can access memory can be used to transfer data to or from I/O devices Hardware to connect I/O Device to BUS Interface Circuit: o o o o Address Decoder Control Circuits Data registers Status registers

The Registers in I/O Interface Status Registers like SIN, SOUT Data Registers like Data-IN, Data-OUT

Page 98 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Implementation of I/O operations Programmed I/O Interrupt Driven I/O Direct Memory access (DMA) I/O Processor (IOP) Programmed I/O Here Processor repeatedly checks the status flag to achieve synchronization between CPU and I/O devices. Useful in small low-speed computers or in systems that are dedicated to monitor a device continuously. Inefficient as the CPU wastes time in checking the flag instead of doing some other useful processing task. CPU, memory and I/O devices usually communicate via the system register An I/O device is connected to the bus via I/O ports which from CPUs perspective is an addressable data register The address line of the system bus used to select memory locations can also be used to select IO devices Modes of addressing: o o Memory-mapped I/O: single address space for memory locations and I/O devices Isolated I/O: address space for I/O is isolated from the memory address space

Memory Mapped I/O

Data Address READ WRITE

Main memory

CPU

I/O port 1

I/O port 2

I/O port 3

I/O device A

I/O device B

Fig 5.2: Memory Mapped I/O

Page 99 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A part of main memory address space is assigned to the I/O ports The same address and data lines are used as shown in Fig 5.2 Used in Motorola 680X0 series Isolated I/O The main memory and I/O lines are separate as shown in Fig 5.3 Used in Intel 80X86 series Data
Address READ M WRITE M READ IO WRITE IO

Main memory

CPU

I/O port 1

I/O port 2

I/O port 3

I/O device A

I/O device B

Fig 5.3: Isolated I/O Interrupt Driven I/O In programmed I/O, CPU busily waits for the I/O module for transmission and reception of data. Alternatively, the CPU can issue I/O command to a module and can perform some other task. When I/O Device is ready, it sends an INTERRUPT signal to the processor. One of the Bus Control lines is dedicated for interrupt request Using Interrupts, WAIT period of the CPU is eliminated Example 5.1 Consider a task, which requires computations to be performed and results to be printed on Line printer This is followed by more computations and output Program consists of 2 routines COMPUTE & PRINT The printer accepts only one line at a time PRINT routine should send 1 line of text at a time and wait for getting it printed The above simple approach is time consuming, as CPU has to wait for long time If it is possible to overlap printing & computation, i.e. to execute COMPUTE routine while printing is in progress, faster overall speed of execution can be achieved

Page 100 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology How to achieve better Speed of Execution? First, COMPUTE routine is executed to produce n lines of output PRINT routine is executed to send first line of text to printer PRINT routine is temporarily suspended Execution of COMPUTE routine can continue After completion of printing of current line, Printer sends an Interrupt Signal to the CPU In response, CPU stops execution of COMPUTE routine CPU transfers control to PRINT routine PRINT routine sends next line to Printer Direct Memory Access (DMA) So far, We have discussed the data transfer between Processor & I/O devices For I/O transfer, Processor determines the status of I/O devices To do this o Processor either polls a status flag in I/O Interface device (or) o CPU waits for the device to send Interrupt signal Considerable overhead is incurred in the above I/O transfer processing To transfer large blocks of data at high Speed, between EXTERNAL devices & Main Memory, DMA approach can be used The continuous intervention by Processor can be drastically reduced DMA controller allows data transfer between I/O device and Memory DMA controller acts as a Processor CPU controls the operation of DMA controller To initiate the transfer of blocks of words, the processor sends the following data to controller o The starting address of the memory block where data are available (for read) or where data are to be stored (for write) o The word count, which is the number of words in the memory block o Control to specify the mode of transfer such as read or write o A control to start the DMA transfer After receiving information, DMA controller proceeds to perform the requested transfer After entire transfer of word block, DMA controller sends an Interrupt signal to Processor

Registers in a DMA Interface The first register stores the starting address. Second register stores Word count Third register contains status and control flags

Page 101 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Status & Control Flags R/W bit determines the direction of data transfer o R/W bit = 1, READ operation o R/W bit = 0, WRITE operation Done Flag -: It will be 1, when controller finishes data transfer IE (Interrupt Enable flag): When set to 1, this flag causes the controller to raise an Interrupt after data transfer IRQ -: (Interrupt Request) IRQ bit will be 1, when it has requested an interrupt

Role of Operating System in DMA transfer I/O operations are always performed by the Operating System of the computer in response to a request from an application program Operating system initiates the DMA operation for the current program Operating system starts the execution of another program After transfer, DMA controller sends Interrupt signal to the Processor Operating system, puts the suspended program in Runnable state so that, it will be selected NEXT for I/O transfer

BUS ARBITER DMA controller & Processor should not use the same BUS at a time to access Main Memory Different DMA controllers used for various I/O devices should not use same BUS to access Main Memory To solve the above conflicts, a special circuit called BUS ARBITER is used Bus Arbiter co-ordinates the activities of all devices requesting Memory Transfers Input-Output Processor (IOP) Processor with direct memory access capability that communicates with I/O devices Unlike the DMA controller that must be setup entirely by the CPU, IOP can fetch and execute its own instructions IOP instructions are specially designed to facilitate I/O transfer IOP can also perform other processing tasks, such as arithmetic, logic, branching and code translation

Page 102 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Block diagram of a computer with Input-Output Processor Central processing unit (CPU) Peripheral Devices

Memory Unit

Memory bus

PD

PD

PD

PD

Input-Output Processor (IOP) I/O bus

Fig 5.4: Block Diagram of a Computer with IOP I/O Management In UNIX, I/O devices are treated as special files. For example, printers and disks are files. When a process starts, three special files are automatically opened: standard input, standard output, and standard error. The standard input file is the keyboard, while the standard output file and standard error file is the VDU.

Each I/O device is assigned a path name, usually /dev. For example, a line printer would be stored as /dev/lp.

You can access the special files in UNIX in the same way as you access other files. You do not need special commands to access them. For example, the following command copies or prints the file that you specify in <filename> to the printer.

Cp<filename> /dev/lp

Since I/O devices are treated as files in UNIX, you can apply permissions, such as the read or write permissions on the files. For example, a user who has the read permission for a file on the hard disk can only view its contents, while a user with the read and write permissions can view it and modify its contents. Similarly, in the context of an I/O device, you can grant or deny various access to a device, such as printer.

Page 103 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The special files in UNIX are divided into two categories, block special files and character special files. Block special files, such as hard disks, enable you to individually address and access the data stored on each block of the device. Character special files, such as printers, enable you to read and write data on the device as a character stream.

UNIX implements I/O using a collection of device drivers, in which each driver typically controls one device. The drivers are linked to the operating system when the kernel is generated. The kernel is the core of the operating system and manages the memory, files and devices MS-DOS Similar to UNIX, MS-DOS treats its devices as files. It supports both character special and block special files for input and output. When a process starts, five files are opened: standard input, standard output, standard error, serial port and the printer.

To copy or display a file to the VDU (also called a console), you can use the command:

Copy file con

This command copies the contents of the file to the console.

In DOS, you can add a device, such as a tape drive or a digital musical instrument, to the computer. To add the device, you can install the device driver whenever you want. This is in contrast to UNIX, where the device drivers are compiled in the kernel and cannot be installed once the compilation is done.

Each device driver in DOS is written in programming language, such as C. The code in the driver performs the I/O operation. The driver is compiled as a .com or a .exe file. A driver file can also be given the extension .sys to distinguish it from other files. Some of the driver files and their functions are listed in the following table.

Table 5.1: The Driver Files and their functions Driver File DISPLAY.SYS MOUSE.SYS PRINTER.SYS RAMDRIVE.SYS contains the mouse driver contains the printer driver that supports a foreign language contains the RAM disk driver for the extended memory Function contains the console driver that supports a foreign language

To install the device, you need to specify the path of the device driver file in a DOS system file called config.sys. The config.sys system file loads the device driver and the device can then be used in the computer

Page 104 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Windows Family In windows 95 and windows 98 series, devices are installed on a computer using the plug-and-play feature. Plug-and-play is a set of specifications that enables you to plug in a device, and play it without configuring the device manually. The OS automatically configures itself so that it can attach devices such as the VDU and the printer. Windows 2000 and XP supports the above feature. Summary Most modern computers use single bus arrangement for connecting I/O devices to CPU & Memory Bus consists of set of 3 lines -: Address, Data, and Control I/O operations are implemented through Programmed I/O, interrupts, DMA and I/O Processor

Page 105 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 7: Network Protocols and Cognizant Network System

Learning Objectives After completing this session, you will be able to understand Network Protocols OSI Reference model TCP/IP Protocol Definition The protocol defines a common set of rules and signals that computers on the network use to communicate. One of the most popular protocols for LANs is called Ethernet. Another popular LAN protocol for PCs is the IBM token-ring network. A Computer network must provide general, cost effective, fair, and robust connectivity among a large number of computers. As if this werent enough, networks do not remain fixed at any single point in time, but must evolve to accommodate changes in both the underlying technologies upon which they are based as well as changes in the demands placed on them by application programs. Designing a network to meet these requirements is no small task.

In the field of telecommunications, a communications protocol is the set of standard rules for data representation, signaling, authentication and error detection required to send information over a communications channel. An example of a simple communications protocol adapted to voice communication is the case of a radio dispatcher talking to mobile stations. The communication protocols for digital computer network communication have many features intended to ensure reliable interchange of data over an imperfect communication channel. Communication protocol is basically following certain rules so that the system works properly.

A network protocol defines a "language" of rules and conventions for communication between network devices. A protocol includes formatting rules that specify how data is packaged into messages. It also may include conventions like message acknowledgement or data compression to support reliable and/or high-performance network communication. Many protocols exist in computer networking ranging from the high level to the low level. The Internet Protocol family includes Internet Protocol (IP) and all higher-level network protocols built on top of it, such as TCP, UDP, HTTP, and FTP. Modern operating systems include services or daemons that implement support for a given network protocol. Some protocols, like TCP/IP, have also been implemented in silicon hardware for optimized performance.

Page 106 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

The Open Systems Interface (OSI) Reference Model The OSI reference model was created in the late 1970s to help facilitate data transfer between network nodes. One of the greatest functions of the OSI specifications is to assist in data transfer between disparate hosts. This means that you can transfer data between a UNIX host and a PC, for example. The OSI is not physical; rather, it is a set of guidelines that application developers can use to create and implement applications that run on a network. It also provides a framework for creating and implementing networking standards, devices, and internetworking schemes. The OSI has seven different layers, which are divided into two groups. The top three layers define how the applications within the end stations will communicate with each other and with users. The bottom four layers define how data is transmitted end-to-end. Figure 6.1 shows the three upper layers and their functions, and Figure 6.2 shows the four lower layers and their functions.

Fig 6.1: The Upper 3 Layers of OSI

In Figure 6.1, you can see that the user interfaces with the computer at the application layer, and also that the upper layers are responsible for applications communicating between hosts. Remember that none of the upper layers know anything about networking or network addresses. That is the responsibility of the four bottom layers, which are shown in Figure 6.2.

Fig 6.2: The Lower 4 Layers of OSI

Page 107 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The four bottom layers define how data is transferred through a physical wire or through switches and routers, and how to rebuild a data stream from a transmitting host to a destination hosts application. The OSI Layers The International Standards Organization (ISO) is the Emily Post of the network protocol world. Just like Ms. Post, who wrote the book setting the standardsor protocolsfor human social interaction, the ISO developed the OSI reference model as the precedent and guide for an open network protocol set. Defining the etiquette of communication models, it remains today the most popular means of comparison for protocol suites.

The OSI reference model has seven layers: The Application layer The Presentation layer The Session layer The Transport layer The Network layer The Data Link layer The Physical layer Figure 6.3 shows the functions defined at each layer of the OSI model. The following pages discuss this in detail.

a) Layer functions

Page 108 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

b) Layer based Network Architecture

Fig 6.3: OSI Layer Function

Page 109 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

The Application Layer The Application layer of the OSI model is where users communicate with the computer. The Application layer is responsible for identifying and establishing the availability of the intended communication partner and determining if sufficient resources for the intended communication exist. Although computer applications sometimes require only desktop resources, applications may unite communicating components from more than one network application; for example, file transfers, e-mail, remote access, network management activities, client/server processes, and information location. Many network applications provide services for communication over enterprise networks, but for present and future internetworking, the need is fast developing to reach beyond their limits. Today, transactions and information exchanges between organizations are broadening to require internetworking applications like the following:

World Wide Web (WWW) Connects countless servers (the number seems to grow with each passing day) presenting diverse formats. Most are multimedia and include some or all of the following: graphics, text, video, and even sound. Netscape Navigator, Internet Explorer, and other browsers like Mosaic simplify both accessing and viewing Web sites.

E-mail gateways Are versatile and can use Simple Mail Transfer Protocol (SMTP) or the X.400 standard to deliver messages between different e-mail applications.

Electronic Data Interchange (EDI) Is a composite of specialized standards and processes that facilitate the flow of tasks such as accounting, shipping/receiving, and order and inventory tracking between businesses.

Special interest bulletin boards Include the many Internet chat rooms where people can connect and communicate with each other either by posting messages or engage in a live conversation through typing. They can also share public domain software.

Internet navigation utilities Include applications like Gopher and WAIS, as well as search engines like Google, Yahoo !, Excite, and Alta Vista, which help users locate the resources and information they need on the Internet.

Financial transaction services Target the financial community. They gather and sell information pertaining to investments, market trading, commodities, currency exchange rates, and credit data to their subscribers.

Page 110 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

The Presentation Layer The Presentation layer gets its name from its purpose: It presents data to the Application layer. It is essentially a translator and provides coding and conversion functions. A successful data transfer technique is to adapt the data into a standard format before transmission. Computers are configured to receive this generically formatted data and then convert the data back into its native format for actual reading (for example, EBCDIC to ASCII, from Little Endian format to Big Endian format, one signed number representation to another). By providing translation services, the Presentation layer ensures that data transferred from the Application layer of one system can be read by the Application layer of another host. The OSI has protocol standards that define how data should be formatted. Tasks like data compression, decompression, encryption, and decryption are associated with this layer. Some Presentation layer standards are involved in multimedia operations. The following serve to direct graphic and visual image presentation:

PICT This is picture format used by Macintosh or PowerPC programs for transferring QuickDraw graphics.

TIFF The Tagged Image File Format is a standard graphics format for high-resolution, bitmapped images.

JPEG The Joint Photographic Experts Group brings these photo standards to us. Other standards guide movies and sound.

MIDI The Musical Instrument Digital Interface is used for digitized music.

MPEG The Moving Picture Experts Groups standard for the compression and coding of motion video for CDs is increasingly popular. It provides digital storage and bit rates up to 1.5Mbps.

QuickTime This is for use with Macintosh or PowerPC programs; it manages audio and video applications.

Page 111 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

The Session Layer The Session layer is responsible for setting up, managing, and then tearing down sessions between Presentation layer entities. The Session layer also provides dialog control between devices, or nodes. It coordinates communication between systems and serves to organize their communication by offering three different modes: simplex, half-duplex, and full-duplex The Session layer basically keeps different applications data separate from the data of other applications .The following are some examples of Session-layer protocols and interfaces (according to Cisco):

Network File System (NFS) Was developed by Sun Microsystems and used with TCP/IP and UNIX workstations to allow transparent access to remote resources.

Structured Query Language (SQL) SQL was developed by IBM to provide users with a simpler way to define their information requirements on both local and remote systems.

Remote Procedure Call (RPC) Is a broad client/server redirection tool used for disparate service environments . Its procedures are created on clients and performed on servers. X Window Is widely used by intelligent terminals for communicating with remote UNIX computers, allowing them to operate as though they were locally attached monitors.

AppleTalk Session Protocol (ASP) Is another client/server mechanism, which both establishes and maintains sessions between AppleTalk client and server machines. The Transport Layer Services located in the Transport layer do both namely segmentation and reassembling of data from upper-layer applications and unite it onto the same data stream. They provide end-to-end data transport services and can establish a logical connection between the sending host and the destination host on an inter network. Some of you might already be familiar with TCP and UDP and know that TCP is a reliable service and UDP is not. Application developers have their choice of the two protocols when working with TCP/IP protocols.

The Transport layer is responsible for providing mechanisms for multiplexing upper-layer application, session establishment, and teardown of virtual circuits. It also hides details of any network-dependent information from the higher layers by providing transparent data transfer.

Page 112 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Flow Control Data integrity is ensured at the Transport layer by maintaining flow control and allowing users the option of requesting reliable data transport between systems.

Prevents a sending host on one side of the connection from overflowing the buffers in the receiving hostan event that can result in lost data. Reliable data transport employs a connection-oriented communications session between systems, and the protocols involved ensure the following will be achieved: The segments delivered are acknowledged back to the sender upon their reception. Any segments not acknowledged are retransmitted. Segments are sequenced back into their proper order upon arrival at their destination. A manageable data flow is maintained in order to avoid congestion, overloading, and data loss.

Connection-Oriented Communication In reliable transport operation, one device first establishes a connection oriented session with its peer system. Figure 6.4 portrays a typical reliable session taking place between sending and receiving systems. In it, both hosts application programs begin by notifying their individual operating systems that a connection is about to be initiated. The two operating systems communicate by sending messages over the network confirming that the transfer is approved and that both sides are ready for it to take place. Once the required synchronization is complete, a connection is fully established and the data transfer begins. Cisco sometimes refers to this as a three-way handshake.

Fig 6.4: Establishing a connection Oriented session

Page 113 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology While the information is being transferred between hosts, the two machines periodically check with each other, communicating through their protocol software to ensure that all is going well and that the data is being received properly.

The following summarizes the steps in the connection-oriented session pictured in Figure 6.4. The first connection agreement segment is a request for synchronization. The second and third segments acknowledge the request and establish connection parameters between hosts.

The final segment is also an acknowledgment. It notifies the destination host that the connection agreement is accepted and that the actual connection has been established. Data transfer can now begin. During a transfer, congestion can occur because a high-speed computer is generating data traffic faster than the network can transfer it or because many computers are simultaneously sending datagrams through a single gateway or destination. In the latter case, a gateway or destination can become congested even though no single source caused the problem. In either case, the problem is basically akin to a freeway bottlenecktoo much traffic for too small a capacity. Usually, no one car is the problem; there are simply too many cars on that freeway. When a machine receives a flood of datagrams too quickly for it to process, it stores them in a memory section called a buffer. This buffering action solves the problem only if the datagrams are part of a small burst. However, if the datagram deluge continues, a devices memory will eventually be exhausted, its flood capacity will be exceeded, and it will discard any additional datagrams that arrive.

But, no worriesbecause of the transport function, network flood control systems work quite well. Instead of dumping resources and allowing data to be lost, the transport can issue a not ready indicator to the sender, or source, of the flood (as shown in Figure 6.5). This mechanism works kind of like a stoplight, signaling the sending device to stop transmitting segment traffic to its overwhelmed peer. After the peer receiver processes the segments already in its memory reservoir, it sends out a ready transport indicator.

When the machine waiting to transmit the rest of its datagrams receives this go indictor, it then resumes its transmission. In fundamental, reliable, connection-oriented data transfer, datagrams are delivered to the receiving host in exactly the same sequence theyre transmitted; the transmission fails if this order is breached. If any data segments are lost, duplicated, or damaged along the way, a failure will result in. The answer to the problem is to have the receiving host acknowledge receiving each and every data segment.

Page 114 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.5: Transmitting segments with flow contrrol

Windowing Data throughput would be low if the transmitting machine had to wait for an acknowledgment after sending each segment. Because theres time available after the sender transmits the data segment and before it finishes processing acknowledgments from the receiving machine, the sender uses the break to transmit more data. The quantity of data segments the transmitting machine is allowed to send without receiving an acknowledgment for them is called a window. Windowing controls how much information is transferred from one end to the other. While some protocols quantify information by observing the number of packets, TCP/IP measures it by counting the number of bytes. In Figure 6.6(a) and Figure 6.6(b) shown are windows of size 1 and 3 respectively. When a window size of 1 is configured, the sending machine waits for an acknowledgment for each data segment it transmits before transmitting another.

Configured to a window size of 3, its allowed to transmit three data segments before an acknowledgment is received. In our simplified example, both the sending and receiving machines are workstations. Reality is rarely that simple, and most often acknowledgments and packets will commingle as they travel over the network and pass through routers. Routing complicates things, but not to worry, youll learn about applied routing later .

Page 115 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.6: Windowing

Acknowledgments Reliable data delivery ensures the integrity of a stream of data sent from one machine to the other through a fully functional data link. It guarantees the data wont be duplicated or lost. The method that achieves this is known as positive acknowledgment with retransmission. This technique requires a receiving machine to communicate with the transmitting source by sending an acknowledgment message back to the sender when it receives data. The sender documents each segment it sends and waits for this acknowledgment before sending the next segment. When it sends a segment, the transmitting machine starts a timer and retransmits if it expires before an acknowledgment is returned from the receiving end.

In Figure 6.7, the sending machine transmits segments 1, 2, and 3. The receiving node acknowledges it has received them by requesting segment 4. When it receives the acknowledgment, the sender then transmits segments 4, 5, and 6. If segment 5 doesnt make it to the destination, the receiving node acknowledges that event with a request for the segment to be resent. The sending machine will then resend the lost segment and wait for an acknowledgment, which it must receive in order to move on to the transmission of segment 7.

Page 116 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.7: Reliable delivery by the Transport Layer The Network Layer The Network layer is responsible for routing through an inter network and for network addressing. This means that the Network layer is responsible for transporting traffic between devices that are not locally attached. Routers, or other layer-3 devices, are specified at the Network layer and provide the routing services in an inter network.

When a packet is received on a router interface, the destination IP address is checked. If the packet is not destined for the router, then the router will look up the destination network address in the routing table. Once an exit interface is chosen, the packet will be sent to the interface to be framed and sent out on the local network. If the entry for the destination network is not found in the routing table, the router drops the packet.

Two types of packets are used at the network layer: data and route updates.

Data packets Are used to transport user data through the inter network, and protocols used to support data traffic are called routed protocols.

Page 117 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Route update packets Are used to update neighbor routers about networks connected to routers in the inter network. Protocols that send route update packets are called routing protocols, and examples are RIP, EIGRP, and OSPF, to name a few. Routing update packets are used to help build and maintain routing tables on each router. Figure 6.8 shows an example of a routing table.

Fig 6.8: Routing table used in a router

The routing table used in a router includes the following information:

Network addresses Protocol-specific network addresses. A router must maintain a routing table for individual routing protocols because each routing protocol keeps track of a network with a different addressing scheme. Think of it as a street sign in each of the different languages spoken by the residents on a street.

Interface The exit interface a packet will take when destined for a specific network.

Metric It is the distance to the remote network. Different routing protocols use different methods of computing this distance. Some routing protocols use hop count (the number of routers a packet passes through when routing to a remote network), while others use bandwidth, delay of the line, or even tick count (1/18 of a second).

Routers break up broadcast domains. This means, by default, that broadcasts are not forwarded through a router. This is good. Routers also break up collision domains, but this can also accomplished through layer-2 switches. Each interface in a router is a separate network and must be assigned unique network identification numbers. Each host on the network connected to that router must use that same network number.

Page 118 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Some points about routers that you must remember: Routers, by default, will not forward any broadcast or multicast packets. Routers use the logical address in a network layer header to determine the next hop router to forward the packet to. Routers can use access lists, created by an administrator, to control security on packets trying to either enter or exit an interface. Routers can provide layer-2 bridging functions if needed and can simultaneously route through the same interface. Layer-3 devices (routers in this case) provide connections between Virtual LANs (VLANs). The Data Link Layer The Data Link layer ensures that messages are delivered to the proper device and translates messages from the Network layer into bits for the Physical layer to transmit. It formats the message into data frames and adds a customized header containing the hardware destination and source address. This added information forms a sort of capsule that surrounds the original message in much the same way that engines, navigational devices, and other tools were attached to the lunar modules of the Apollo project. These various pieces of equipment were useful only during certain stages of space flight and were stripped off the module and discarded when their designated stage was complete. Data traveling through networks is similar. Figure 6.9 shows the Data Link layer with the Ethernet and IEEE specifications. Notice in the figure that the IEEE 802.2 standard is used in conjunction with the other IEEE standards, adding functionality to the existing IEEE standards.

Fig 6.9: Data Link Layer You need to understand that routers, which work at the Network layer, do not care about where a host is located but only where networks are located. They also keep track of the best way to get to a remote network. The Data Link layer is responsible for uniquely identifying each device on a local network.

Page 119 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology For a host to send packets to individual hosts and between routers, the Data Link layer uses hardware addressing. Each time a packet is sent between routers, it is framed with control information at the Data Link layer, but that information is stripped off at the receiving router and only the original packet is left completely intact. This framing of the packet continues for each hop until the packet is finally delivered to the receiving host. It is important to understand that the packet was never altered along the route, only encapsulated with the type of control information to be passed on to the different media types.

The IEEE Ethernet Data Link layer has two sub-layers: Media Access Control (MAC) 802.3 This defines how packets are placed on the media. Contention media access is first come, first served access where everyone shares the same bandwidth. Physical addressing is defined here, as well as logical topologies. Logical topology is the signal path through a physical topology. Line discipline, error notification (not correction), ordered delivery of frames, and optional flow control can also be used at this sub layer. Logical Link Control (LLC) 802.2 This sublayer is responsible for identifying Network layer protocols and then encapsulating them. An LLC header tells the Data Link layer what to do with a packet once a frame is received. For example, a host will receive a frame and then look in the LLC header to understand that the packet is destined for the IP protocol at the Network layer. The LLC can also provide flow control and sequencing of control bits. Switches and Bridges at the Data Link Layer Switches and bridges both work at the Data link layer and filter the frames using hardware (MAC) addresses. Layer-2 switching is considered hardware-based bridging because it uses a specialized hardware called Application-Specific Integrated Circuits (ASICs). ASICs can run up to gigabit speeds with very low latency. Bridges and switches read each frame as it passes through the network. The layer-2 device then puts the source hardware address in a filter table and keeps track of which port it was received on. This tells the switch where that device is located. After a filter table is built on the layer-2 device, the device will only forward frames to the segment where the destination hardware address is located. If the destination device is on the same segment as the frame, the layer-2 device will block the frame from going to any other segments. If the destination is on another segment, the frame is only transmitted to that segment. This is called transparent bridging. When a layer-2 device (switch) interface receives a frame and the destination hardware address is unknown to the devices filter table, it will forward the frame to all connected segments. If the unknown device replies to this forwarding of the frame, the switch updates the filter table on that devices location. However, the destination address of the transmitting frame may be a broadcast address, in which case the switch will forward all broadcasts to every connected segment by default.

Page 120 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology All devices that the broadcast is forwarded to are considered to be in the same broadcast domain. Layer-2 devices propagate layer-2 broadcast storms. The only way to stop a broadcast storm from propagating through an inter network is with a layer-3 device (router). The biggest benefit of using switches instead of hubs in your inter network is that each switch port is its own collision domain, whereas a hub creates one large collision domain. However, switches and bridges do not break up broadcast domains, instead forward all broadcasts. Another benefit of LAN switching over hub implementations is that each device on every segment plugged into a switch can transmit simultaneously because each segment is its own collision domain. Hubs allow only one device per network to communicate at a time. Switches cannot translate between different media types. In other words, each device connected to the switch must use an Ethernet frame type. If you wanted to connect to a Token Ring switch or LAN, you would need a router to provide the translation services. The Physical Layer The Physical layer has two responsibilities: it sends bits and receives bits. Bits come only in values of 1 or 0a Morse code with numerical values. The Physical layer communicates directly with the various types of actual communication media. Different kinds of media represent these bit values in different ways. Some use audio tones, while others employ state transitions changes in voltage from high to low and low to high. Specific protocols are needed for each type of media to describe the proper bit patterns to be used, how data is encoded into media signals, and the various qualities of the physical medias attachment interface. The Physical layer specifications specify the electrical, mechanical, procedural, and functional requirements for activating, maintaining, and deactivating a physical link between end systems. At the Physical layer, the interface between the Data Terminal Equipment, or DTE, and the Data Circuit-Terminating Equipment, or DCE, is identified. The DCE is usually located at the service provider, while the DTE is the attached device. The services available to the DTE are most often accessed via a MODEM or Channel Service Unit/Data Service Unit (CSU/DSU). The Physical layers connectors and different physical topologies are defined by the OSI as standards, allowing disparate systems to communicate. The CCNA course and exam are only interested in the Ethernet standards. Hubs at the Physical Layer Hubs are really multiple port repeaters. A repeater receives a digital signal and re-amplifies it or regenerates the digital signal, then forwards the digital signal out to all active ports without looking at any data. An Active hub does the same thing. Any digital signal received from a segment on a hub port is regenerated or re-amplified and transmitted out all ports on the hub. This means that all devices plugged into a hub are in the same collision domain as well as in the same broadcast domain. A broadcast domain is defined as all devices on a network segment that hear all broadcasts sent on that segment. Hubs, like repeaters, do not look at any traffic as they enter and are transmitted out to the other parts of the physical media. Hubs create a physical star network where the hub is a central device and cables extend in all directions, creating the physical star effect. However, Ethernet networks use a logical bus topology. This means that the signal has to run from end to end of the network. Every device connected to the hub, or hubs, must listen if a device transmits.

Page 121 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Introduction to TCP/IP The Transmission Control Protocol/Internet Protocol (TCP/IP) is an industry-standard suite of protocols designed to be routable, robust, and functionally efficient. TCP/IP was originally designed as a set of Wide Area Network (WAN) protocols for the express purpose of maintaining communication links and data transfer between sites in the event of an atomic/nuclear war. Since those early days, development of the protocols has passed from the hands of the government and has been the responsibility of the Internet community for some time. The evolution of these protocols from a small four-site project into the foundation of the worldwide Internet has been extraordinary. But, despite more than 25 years of work and numerous modifications to the protocol suite, the inherent spirit of the original specifications is still intact.

Installing Microsofts TCP/IP as a protocol on your machine or network provides the following advantages:

An industry-standard protocol Because TCP/IP is not maintained or written by one company, it is not proprietary or subject to as many compatibility issues. The Internet community as a whole decides whether a particular change or implementation is worthwhile. Naturally, this slows down the implementation of new features and characteristics compared to how quickly one directed company might make changes, but it does guarantee that changes are well thought out, that they provide functionality with most, if not all other implementations of TCP/IP, and that a set of specifications is publicly available that can be referenced at any time over the Internet, detailing how the protocol suite should be used and implemented.

A set of utilities for connecting dissimilar operating systems Many connectivity utilities have been written for the TCP/IP suite, including the File Transfer Protocol (FTP) and Terminal Emulation Protocol (Telnet). Because these utilities use the Windows Sockets API, connectivity from one machine to another is not dependent on the network operating system used on either machine. For example, a UNIX FTP server could be accessed by a Microsoft FTP client to transfer files without either party having to worry about compatibility issues. This functionality also allows a Windows NT machine running a Telnet client to access and run commands on an IBM mainframe running a Telnet server, for example.

A scalable, cross-platform client-server architecture Consider what happened during the initial development of applications for the TCP/IP protocol suite. Vendors wanted to be able to write their own client/server applications, for instance, SQL server and SNMP. The specification for how to write applications was also up for public perusal. Which operating systems would be included? Users everywhere wanted to be able to take advantage of the connectivity options promised through utilizing TCP/IP, regardless of the operating system they were currently running. Therefore the Windows Sockets API was established, so that applications utilizing the TCP/IP protocol could write to a standard, agreedupon interface. Because the contributors included everyone, and therefore every kind of operating system, the specifications for Windows Sockets on TCP/IP were written to make the operating system transparent to the application. Microsofts TCP/IP includes support for Windows Sockets and for connectivity to other Windows Sockets-compliant TCP/IP stacks.

Page 122 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Access to the Internet TCP/IP is the de facto protocol of the Internet and allows access to a wealth of information that can be found at thousands of locations around the world. To connect to the Internet, though, a valid IP address is required. Because IP addresses have become more and more scarce, and as security issues surrounding access to the Internet have been raised, many creative alternatives have been established to allow connections to the Internet. However, all these implementations utilize gateways or firewalls that act on behalf of the requesting machines. Now that you understand the benefits of installing TCP/IP, you are ready to learn about how the TCP/IP protocol suite maps to a four-layer model. The Four Layers of TCP/IP TCP/IP maps to a four-layer architectural model. This model is called the Internet Protocol Suite and is broken into the Network Interface, Internet, Transport, and Application layers. Each of these layers corresponds to one or more layers of the OSI model. The Network Interface layer corresponds to the Physical and Data Link layers. The Internet layer corresponds to the Network layer. The Transport layer corresponds to the Transport layer, and the Application layer corresponds to the Session, Presentation, and Application layers of the OSI model. Figure 6.10 illustrates these relationships.

Fig 6.10: Relationship between Layers in OSI and TCP/IP Each of the four layers of the model is responsible for all the activities of the layers to which it maps. The Network Interface layer is responsible for communicating directly with the network. It must understand the network architecture being used, such as token-ring or Ethernet, and provide an interface allowing the Internet layer to communicate with it. The Internet layer is responsible for communicating directly with the Network Interface layer. The Internet layer is primarily concerned with the routing and delivery of packets through the Internet Protocol (IP). All the protocols in the Transport layer must use IP to send data. The Internet Protocol includes rules as to how to address and direct packets, fragment and reassemble packets, provide security information, and identify the type of service being used. However, because IP is not a connection-based protocol, it does not guarantee that packets transmitted onto the wire will not be lost, damaged, duplicated, or out of order. This is the responsibility of higher layers of the networking model, such as the Transport layer or the Application layer. Other protocols that exist in the Internet Layer are the Internet Control Messaging Protocol (ICMP), Internet Group Management Protocol (IGMP), and the Address Resolution Protocol (ARP). Each of these is described in more detail later in this chapter.
Page 123 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The Transport layer maps to the Transport layer of the OSI model and is responsible for providing communication between machines for applications. This communication can be connectionoriented or-connectionless. The primary difference between these two types of communications is whether there is a mechanism for tracking data and guaranteeing the delivery of the data to its destination. Transmission Control Protocol (TCP) is the protocol used for connection-based communication between two machines providing reliable data transfer. User Datagram Protocol (UDP) is used for connectionless communication with no guarantee of delivery. The Application layer of the Internet protocol suite is responsible for all the activities that occur in the Session, Presentation, and Application layers of the OSI model. Numerous protocols have been written for use in this layer, including Simple Network Management Protocol (SNMP), File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), as well as many others. The interface between each of these layers is written to have the capability to pass information from one layer to the other. Figure 4.11 illustrates how each layer adds its own information to the data and hands it down to the lower layers. It also illustrates how that data is then stripped off by the corresponding layer of the receiving machine, until what is left is only the information needed by that layer. The four layer structure of TCP/IP is built as information is passed down from applications to the physical network layer. When data is sent, each layer treats all of the information it receives from the layer above as data and adds control information to the front of that data. This control information is called a header, and the addition of a header is called encapsulation. When data is received, the opposite procedure takes place as each layer removes its header before passing the data to the layer above.

Page 124 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.11: Layers in the TCP/IP protocol suite

The interface between the Network Interface layer and the Internet layer does not pass a great deal of information, although it must follow certain rules. Namely, it must listen to all broadcasts and send the rest of the data in the frame up to the Internet layer for processing, and if it receives any frames that do not have an IP frame type, they must be silently discarded. The interface between the Internet layer and the Transport layer must be able to provide each layer full access to such information as the source and destination addresses, whether TCP or UDP should be utilized in the transport of data, and all other available mechanisms for IP. Rules and specifications for the Transport layer include giving the Transport layer the capability to change these parameters or to pass parameters it receives from the Application layer down to the Internet layer. The most important thing to remember about all of these boundary layers is that they must use the agreed upon rules for passing information from one layer to the other.

The interface between the Transport layer and the Application layer is written to provide an interface to applications, whether or not they are using the TCP or UDP protocol for transferring data. The interface utilizes the Windows Sockets and NetBIOS APIs to transfer parameters and data between the two layers. The Application layer must have full access to the Transport layer to change and alter parameters as necessary.

The layers provide only guidelines, though; the real work is done by the protocols that are contained within the layers. This chapter describes the TCP/IP protocol as being a suite of protocols, not just two (TCP and IP). In fact, seven primary protocols are associated with TCP/IP: Transmission Control Protocol (TCP) User Datagram Protocol (UDP) Internet Protocol (IP) Internet Control Message Protocol (ICMP) Address Resolution Protocol (ARP)/Reverse Address Resolution Protocol(RARP) Internet Group Management Protocol (IGMP)

Figures 6.12 shows where each of these protocols resides in the architectural model. Each protocol has a graphic to help you visualize the type of communication that is being achieved through these protocols. The telephone is meant to represent TCP; the letter is meant to represent UDP; the security guard is meant to represent ICMP; the cable TV is meant to represent IGMP; the
Page 125 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology detective is meant to represent ARP; and the mail truck/phone operator is meant to represent IP. A person in an unknown forest is meant to represent RARP, where he/she would like to know the current location at the earliest. Each of these protocols and the details of their implementation is discussed in the following sections. Transmission Control Protocol The first protocol that lives in the Transport layer is the Transmission Control Protocol (TCP). This protocol is a connection-based protocol and requires the establishment of a session before data is transmitted between two machines. TCP packets are delivered to sockets or ports. Because TCP sets up a connection between two machines, it is designed to verify that all packets sent by a machine are received on the other end. If, for some reason, packets are lost, the sending machine resends the data. Because a session is established and delivery of packets is guaranteed, there is additional overhead involved with using TCP to transmit packets.

Fig 6.12: Protocols within the layers of the TCP/IP Protocol Suite Figure 6.13 shows the TCP/IP protocol architecture; this diagram is by no means exhaustive, but shows the major protocol and application components common to most commercial TCP/IP software packages and their relationship.

Fig 6.13: Components of commercial TCP/IP Software Packages

Page 126 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology To understand TCP further, you must understand ports and sockets, connection-oriented communications, sliding windows, and acknowledgments. The following sections cover each of these areas.

Ports and Sockets Each process that wants to communicate with another process identifies itself to the TCP/IP protocol suite by one or more ports. A port is a 16-bit number, used by the host-to-host protocol to identify to which higher-level protocol or application program (process) it must deliver incoming messages.

The communication process between the Transport layer and the Application layer involves identifying the application that has requested either a reliable or unreliable transport mechanism. Port assignments are the means used to identify application processes to the Transport layer. Ports identify to which process on the machine data should be sent for further processing. Specific port numbers have been assigned by the Internet Assigned Numbers Authority (IANA), specifically those from 1 to 1023. These port assignments are called the well-known ports and represent the ports to which standard applications listen. Defining these standard port numbers helps eliminate having to guess to which port an application is listening so that applications can direct their queries or messages directly. Port numbers above the well-known port range are available for running applications, and work in exactly the same way. In this case, however, the client or user has to be able to identify to which port the application is connecting. Ports can be used by both TCP and UDP for delivering data between two machines. Ports themselves do not care whether the data they receive is in order or not, but the applications running on those ports might.

To identify both the location and application to which a stream of data needs to be sent, the IP address (location) and the port number (application) are often combined into one functional address called a socket. A socket is a special type of file handle which is used by a process to request network services from the operating system. A Socket is also referred to as an End-Point. A pair of end-points is known as a connection. Figure 6.14 illustrates the format for defining a socket. A socket can be defined for either TCP or UDP connections.

Fig 6.14: Definition of a Socket

Figure 6.15 shows the TCP Connection - Processes X and Y communicate over a TCP connection carried by IP datagrams.

Page 127 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.15: Applications Communicating through Reliable Connections Connection-Oriented Communication

The Transmission Control Protocol (TCP) is a connection-based protocol that establishes a connection, or session, between two machines before any data is transferred. TCP exists within the Transport layer, between the Application layer and the IP layer, providing a reliable and guaranteed delivery mechanism to a destination machine. Connection-based protocols guarantee the delivery of packets by tracking the transmission and receipt of individual packets during communication. A session is able to track the progress of individual packets by monitoring when a packet is sent, in what order it was sent, and by notifying the sender when it is received so it can send more. Figure 6.16 illustrates how TCP sets up a connection-oriented session between two machines. The first step in the communication process is to send a message indicating a desire to synchronize the systems. This is equivalent to dialing a phone number and waiting for someone to answer. The second step is for the machine to send an acknowledgment that it is listening and willing to accept data. This step is equivalent to a person answering the phone, and then waiting for the caller to say something. The third step is for the calling machine to send a message indicating that it understands the receiving machines willingness to listen and that data transmission will now begin.

Fig 6.16: Connection Based communication

Page 128 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology After the TCP session has been created, the machines begin to communicate just as people do during a phone call. In the example of the telephone, if the caller uses a cellular phone and some of the transmission is lost, the user indicates she did not receive the message by saying What did you say? I didnt hear that. This indicates to the sender that he needs to resend the data. Figure 6.18 illustrates the format of a TCP header. The header includes all the parameters that are used to guarantee delivery of packets and to provide error-checking and control. Notice that the header specifies a source and destination port for the communication. This tells the machine where it is supposed to send the data, and from where the data came.

Fig 6.17: Format of a TCP Segment

Source Port (16-bit) - used by the receiver to reply

Destination Port (16-bit) - destination port number

Sequence Number - sequence number of the first data byte in this segment. If the SYN control bit is set, the sequence number is the initial sequence number (n) and the first data byte is n+1. Acknowledgment Number - If the ACK control bit is set, this field contains the value of the next sequence number that the receiver is expecting to receive. Data Offset - 32-bit words in the TCP header. It indicates where the data begins. This is otherwise also referred to as HLEN (Header Length) in 32 bit words. Reserved - six bits reserved for future use; must be zero. URG - Urgent pointer field. ACK - acknowledgment field is valid if set to TRUE PSH Push transfer is enabled, if TRUE RST - resets the connection. SYN - synchronizes the sequence numbers; meant for establishing a TCP connection. FIN - no more data from sender; meant for clearing the TCP connection in one particular direction.

Page 129 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Window - used in ACK segments. It specifies the number of data bytes beginning with the one indicated in the acknowledgment number field which the receiver (= the sender of this segment) is willing to accept.

Checksum - The 16-bit one's complement of the one's complement sum of all 16-bit words in the pseudo-header, the TCP header and the TCP data. While computing the checksum, the checksum field itself is considered zero.

The pseudo-header is actually a pseudo-IP-header, only used for the checksum calculation, with the format shown in Fig 6.18.

Fig 6.18: Format of Pseudo-header

Urgent Pointer - points to the first data octet following the urgent data. Meaningful only when the URG control bit is set.

Options Just as in the case of IP datagram options, options can be either: A single byte containing the option number, or A variable length option in the format shown in Fig 4.19(a):

Fig 6.19 (a) TCP/IP (Variable length)

Fig 6.19 (b) Maximum Segment Size Options Fig 6.19: TCP options.

Page 130 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology There are currently only three options defined:

Kind Length Meaning ---- ------ ------0 - End of option list. 1 - No-Operation. 2 4 Maximum Segment Size.

The Maximum Segment Size Option (Fig 4.19(b)) is only used during the establishment of the connection (SYN control bit set) and is sent from the side that is to receive data to indicate the maximum segment length it can handle. If this option is not used, any segment size is allowed.

Padding - all zero bytes used to fill up the TCP header to a total length that is a multiple of 32 bits. The last part of the frame is the actual data being transmitted.

Three way Handshake for Connection Establishment Figure 6.20 describes the three different handshakes that are employed during a connection establishment between the client C and the server S.

Client(C)

Server(S)

Send SYN=1,seq=x

Receive SYN=1,seq=x Send SYN=1,seq=y

Time

ACK=1, Ack=x+1

Receive SYN=1, seq=y ACK=1, Ack=x+1 Send ACK=1,Ack=y+1

Receive ACK=1 Ack=y+1

Fig 6.20: Three way handshake

Initially C sends a TCP Segment setting SYN=1 meaning that it is trying a synchronise on the sequence number x as it wishes to communicate with S. In receiving the above, S sends back an
Page 131 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology acknowledgement with ACK=1 and Acknowledgement field having x+1 meaning that the next expected data byte will have the sequence number x+1. At the same time S tries to synchronise on the sequence number Y.

For the better synchronization C acknowledges, during the handshake, in a similar way as S did. On the receipt of the second acknowledgement in the third handshake a TCP connection is said to have been established.

But, the above procedure is very robust in the sense the failure of any of the handshake will be tolerated and ultimately the connection would be established.

For example, if handshake-1 fails then C times out. And retransmits and the retransmission is likely to succeed and hence handshake-1.

If handshake-2 fails here again C times out and retransmits seq=x. on receipt of this S understands that handshake 2 should have been a failure and hence retransmits handshake-2 ultimately leading to success.

If handshake-3 fails then S times out looking for ACK=y+1, and hence retransmits handshake-2. On receiving the transmitted handshake-2, C learns that the earlier handshake-3 should have been a failure and hence ultimately, after these three successful handshakes a TCP connection is established.

2 way handshake for clearing connection Figure 6.21(a) describes the closure of that part of the connection from C to S, where the TCP connection is full duplex in nature. At the end of this pair of handshake the TCP connection becomes simplex from S to C. Figure 6.21 b corresponds to the closure of this simplex connection too. Like 3 way handshakes these are also robust.

Page 132 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Send FIN=1, seq=i 1 Receive FIN=1, seq=i+1 Time 2 Send ACK=1, Ack=i+1

Receive ACK=1, Ack=i+1

Fig A

Send FIN=1, seq=j 1

Receive FIN=1, seq=j Send ACK=1, Ack=j+1

Receive ACK=1, Ack=j+1 Time

Fig B Fig 6.21: Closure of TCP connection

Page 133 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Sliding Windows TCP uses the concept of sliding windows for transferring data between machines. Sliding windows are often referred to in the UNIX environment as streams. Each machine has both a send window and a receive window that it utilizes to buffer data and make the communication process more efficient. A window represents the subset of data that is currently being sent to a destination machine, and is also the amount of data that is being received by the destination machine. At first this seems redundant, but it really isnt. Not all data that is sent is guaranteed to be received, so they must be kept track of on both machines. A sliding window allows a sending machine to send the window data in a stream without having to wait for an acknowledgment for every single packet. A receiving window allows a machine to receive packets out of order and reorganize them while it waits for more packets. This reorganization may be necessary because TCP utilizes IP to transmit data, and IP does not guarantee the orderly delivery of packets.

Figure 6.22 shows the send and receive windows that exist on machines that have TCP/IP installed. By default, window sizes in Windows NT are a little more than 8 KB in size, representing eight standard Ethernet frames. Standard Ethernet frames are a little more than 1KB apiece.

Fig. 6.22: Send and Receive windows

Packets do not always make it to their destination, though. TCP has been designed to recover in the event that packets are lost along the way, perhaps by busy routers. TCP keeps track of the data that has been sent out, and if it doesnt receive an acknowledgment for that data from the destination machine in a certain amount of time, the data is re-sent. In fact, until acknowledgment for a packet of data is received, further data transmission is halted completely.

Acknowledgments Acknowledgments are a very important component necessary to ensure the reliable delivery of packets. As the receiving window receives packets, it sends acknowledgments to the sending window that the packets arrived intact. When the send window receives acknowledgments for data it has sent, it slides the window to the right so that it can send any additional data stored in memory. But it can only slide over by the number of acknowledgments it has received. By default, a receive window sends an acknowledgment for every two sequenced packets it receives. Therefore, assuming no network problems, if the send window in figure 6.23 sends eight packets to the receive window on the other machine, four acknowledgment packets come back. An acknowledgment for packets 1 and 2, 3 and 4, 5 and 6, and 7 and 8. The sending window slides over to the next eight packets waiting to be sent and sends those out to the receiving window. In this manner, the number of acknowledgments sent over the network is reduced, and the flow of traffic is increased.

Page 134 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 6.23: Sliding after receiving acknowledgements

As long as the acknowledgments begin flowing back regularly from the receiving machine, data flows smoothly and efficiently. However, on busy networks, packets can get lost and acknowledgments may be delayed. Because TCP guarantees delivery and reliability of traffic flow, the window cannot slide past any data that has not been acknowledged. If the window cannot slide beyond a packet of data, no more data beyond the window is transmitted, TCP eventually has to shut down the session, and the communication fails. Each machine is therefore instructed to wait a certain amount of time before either retransmitting data or sending acknowledgments for packets that arrive out of sequence. Each window is given a timer: the send window has the Retransmit Timer and the receive window has the Delayed Acknowledgment Timer. These timers help define what to do when communication isnt flowing very smoothly.

In the sending window, a Retransmit Timer is set for each packet, specifying how long to wait for an acknowledgment before making the assumption that the packet did not get to its destination. After this timer has expired, the send window is instructed to resend the packet and wait twice as long as the time set on the preceding timer. The default starting point for this timer is approximately 3 seconds but is usually reduced to less than a second almost immediately. Each time an acknowledgment is not received, the Retransmit Timer doubles. For instance, if the Retransmit Timer started at approximately 1 second, the second Retransmit Timer is set for 2 seconds, the third for 4 seconds, the fourth, 8 seconds, up to a fifth attempt that waits 16 seconds. The number of attempts can be altered in the Registry, but if after these attempts an acknowledgment still cannot be received, the TCP session is closed and errors are reported to the application.

Figure 6.24 illustrates the resending of data after the first Retransmit Timer has expired.

The Registry location for changing the number of times to retry a transmission is in the following subkey:

Page 135 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 6.24: Retransmission of data after the Retransmit Timer has expired

In the receiving window, a Delayed Acknowledgment Timer is set for those packets that arrive out of order. Remember, by default an acknowledgment is sent for every two sequenced packets, starting from the left-hand side of the window. If packets arrive out of order (if, for instance, 1 and 3 arrive but 2 is missing), an acknowledgment for two sequenced packets is not possible. When packets arrive out of order, a Delayed Acknowledgment Timer is set on the first packet in the pair. In the parenthetical example, a Timer is set on packet number 1. The Delayed Acknowledgment Timer is hard-coded for 200 milliseconds, or 1/5 the Retransmit Timer. If packet 2 does not show up before the Delayed Acknowledgment Timer expires, an acknowledgment for packet 1, and only packet 1, is sent. No other acknowledgments are sent, including those for packets 3 through 8 that might have appeared. Until packet 2 arrives, the other packets are considered interesting, but useless. As data is acknowledged and passed to the Application layer, the receive window slides to the right, enabling more data to be received. Again though, if a packet doesnt show up, the window is not enabled to slide past it. Figure 6.25 illustrates the Delayed Acknowledgment Timer in action.

Fig 6.25: Setting of the delayed Acknowledgement Timer for out of sequence packet

Page 136 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Cognizant Network System

Fig 6.26: Cognizant Data and Voice Network

Page 137 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Summary Protocol - defines a common set of rules and signals that computers on the network use to communicate. Two popular network models serve as functional guidelines for dividing up communication tasks: o o OSI (Open System Interconnect) TCP/IP

TCP/IP provides the ability to facilitate communication and share resources between varying networks and platforms. TCP and IP are two separate protocols. TCP is connection-oriented and IP is connection-less. IP address is Four Byte (32 bit) and quantities in dotted decimal notation.

Page 138 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 8: Internetworking and Network Management

What Is an Internetwork? An internetwork is a collection of individual networks, connected by intermediate networking devices, that functions as a single large network. Internetworking refers to the industry, products, and procedures that meet the challenge of creating and administering internetworks. Figure 7.1 illustrates different kinds of network technologies that can be interconnected by routers and other networking devices to create an internetwork.

Fig 7.1: Different Network Technologies can be connected to create an Internetwork

We use the term internetwork, or sometimes just internet to refer to an arbitrary collection of networks interconnected to provide some sort of host-to-host packet delivery service. Fig.7.1 shows an example of internetowork. An internetwork is often referred to as a network of networks because it is made up of lots of smaller networks. In this figure, We see Ethernets, an FDDI ring, and a point-to-point link. Each of these is a single-technology network. The nodes that interconnect the networks are called routers. Internetworking devices are divided into four categories: repeaters, bridges, routers, and gateways.

Each of these four device types interacts with protocols at different layers of the OSI Model. Repeaters act only upon the electrical components of a signal and therefore active only at the physical layer. Bridges utilize addressing protocols and can affect the flow control of a single LAN; they are most active at the data link layer. Routers provide links between two separate but sametype LANs and the most active in the network layer. Finally, gateways provide translation services between incompatible LANs or applications and are active in all of the layers. Each of these internetworking devices also operates in all of the layers below in which it is most active
Page 139 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Repeaters: A repeater(or regenerator) is an electronic device that operates on only the physical layer of the OSI model.

Fig. 7.2: A repeater in the OSI model

Signals that carry information within a network can travel a fixed distance before attenuation endangers the integrity of the data. A repeater installed on a link receives the signal before it becomes too weak or corrupted, regenerates the original bit pattern, and puts the refreshed copy back onto the link.

A repeater allows us to extend only the physical length of a network. The repeater does not change the functionality of the network in any way. The two sections are connected by the repeater in fig 7.3. If station A sends a frame to station B, all stations (including C and D) will receive the frame, just as they would without the repeater. The repeater does not have the intelligence to keep the frame from passing to the right side when it is meant for a station on the left. The difference is that, with the repeater, stations C and D receive a truer copy of the frame than would otherwise have been possible.

Page 140 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Fig. 7.3: A repeater

Not an amplifier It is tempting to compare a repeater to an amplifier, but the comparison is inaccurate. An amplifier cannot discriminate between the intended signal and noise; it amplifies equally everything fed into it. A repeater does not amplify the signal; it regenerates it. When it receives a weekend or corrupted signal, it creates a copy bit for bit, at the original strength. A repeater is a regenerative, not an amplifier Bridges

Fig. 7.4: A Bridge in the OSI model

Bridges operate in both the physical and the data link layers of the OSI model (see Figure 7.4) Bridges can divide a large network into smaller segments (Fig 7.5).

Page 141 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 7.5: A Bridge

They can also relay frames between two originally separate LANs, unlike repeaters, however, bridges contain logic that allows them to keep the traffic for each segment separate. In this way, they filter traffic, a fact that makes them useful for controlling congestion and isolating problem links. Bridges can also provide security through this partitioning of traffic.

A bridge operates at the data link layer, giving it access to the physical addresses of all stations connected to it. When a frame enters a bridge, the bridge not only regenerates the signal but checks the address of the destination and forwards the new copy only to the segment to which the address belongs. As a bridge encounters a packet, it reads the address contained in the frame and compares that address with a table of all the stations on both segments. When it finds a match, it discovers to which segment the station belongs and relays the packet only to that segment.

For example, Fig 7.6 shows two segments joined by a bridge.

Page 142 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 7.6: Function of a bridge

A packet from station A addressed to station D arrives at the bridge. Station A is on the same segment as station D; therefore, the packet is blocked from crossing into the lower segment instead the packet is relayed to the entire upper segment and received by station D.

In fig b, a packet generated by station A is intended for station G. The bridge allows the packet to cross and relays it to the entire lower segment, where it is received by station G. Types of Bridges To select between segments, a bridge must have a look-up table that contains the physical addresses of every station connected to it. The table indicates to which segment each station belongs.

Simple Bridge Simple Bridges are the most primitive and least expensive type of bridge. A simple bridge links two segments and contains a table that lists the addresses of all the stations included in each of them. What makes it primitive is that these addresses must be entered manually. Before a simple bridge can be used, an operator must sit down and enter the addresses of every station. Whenever a new station is added, the table must be modified. If a station is removed, the newly invalid address must be deleted. The logic included in a simple bridge, therefore, is of the pass/no pass variety, a configuration that makes a simple bridge straightforward and inexpensive to manufacture. Installation and maintenance of simple bridges are time-consuming and potentially more trouble than the cost savings are worth.

Page 143 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Multiport Bridge A multiport Bridge can be used to connect more than two LANs. In figure7.7, the bridge has three tables, each one holding the physical addresses of stations reachable through the corresponding port.

Fig 7.7: Multiport bridge Transparent Bridge A transparent, or learning, bridge builds its table of station addresses on its own as it performs its bridge functions. When the transparent bridge is first installed, its table is empty. As it encounters each packet, it looks at both the destination and the source addresses. It checks the destination to decide where to send the packet. If it does not yet recognize the destination address, it relays the packet to all of the stations on both segments. It uses the source address to build its table. As it reads the source address, it notes which side the packet came from and associates that address with the segment to which it belongs. For example, if the bridge in fig 7.6. is a transparent bridge, then when station A sends its packet to station G, the bridge learns that packets coming A are coming from the upper segment, and that station A must be located in the upper segment. Now, whenever the bridge encounters packets addressed to A, it knows to relay them only to the upper segment.

With the first packet transmitted by each station, the bridge learns the segment associated with that station. Eventually it has a complete table of station addresses and their respective segment stored in its memory.

By continuing this process even after the table is complete, a transparent bridge is also selfupdating. Suppose the person at station A trades offices with the person at station G, and they both take their computers(including their NICs) with them. All of a sudden, the stored segment locations for both stations are wrong. But because the bridge is constantly checking the source address of received packets, it notices that packets from station A are now coming from the lower segment and that packets from station G are coming from the upper segment and updates its table accordingly.

Page 144 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Routers Repeaters and bridges are simple hardware devices capable of executing specific tasks. Routers are more sophisticated. They have access to network layer addresses and contain software that enables them to determine which of several possible paths between those addresses is the best for particular transmission. Routers operate in the physical, data link, and network layers of the OSI model.

Fig. 7.8: A router in the OSI model

Routers relay packets among multiple interconnected networks. They route packets from one network to any of a number of potential destination networks on an internet. Fig 7.9 shows

Fig. 7.9: Routers in an Internet

Page 145 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology A possible internet work of five networks. A packet sent from a station on one network to a station on a neighboring network goes first to the jointly held router, which switches it over to the destination network. If there is no one router connected to both the sending and receiving networks, the sending router transfers the packet across one of its connected networks to the next router in the direction of the ultimate destination. That router forwards the packet to the next router on the path and so on, until destination is reached. Routers act like stations on a network. But unlike most stations, which are members of only one network, routers have addresses on, and links to, two or more networks at the same time. In their simplest function, they receive packets from one connected network and pass them to a second connected network. However, if a received packet is addressed to a node on a network of which the router is not a member, the router is capable of determining which of its connected networks is the best next relay point for the packet. Once a router has identified the best route for a packet to travel, it passes the packet along the appropriate network to another router. That router checks the destination address, finds what it considers the best route for the packet, and passes it to the destination network (if that network is a neighbor) or across a neighboring network to the next router on the chosen path.

In internetworking, the process of moving a packet of data from source to destination is involved. Routing is usually performed by a dedicated device called a router. Routing is a key feature of the Internet because it enables messages to pass from one computer to another and eventually reach the target machine. Each intermediary computer performs routing by passing along the message to the next computer. Part of this process involves analyzing a routing table to determine the best path.

Routing: In computer networking the term routing refers to selecting paths in a computer network along which to send data.

Routing is often confused with bridging, which performs a similar function. The principal difference between the two is that bridging occurs at a lower level and is therefore more of a hardware function whereas routing occurs at a higher level where the software component is more important. And because routing occurs at a higher level, it can perform more complex analysis to determine the optimal path for the packet.

Page 146 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Gateways Gateways potentially operate in all seven layers of the OSI model. See Figure 7.10

Fig 7.10: A gateway in the OSI model

A gateway is a protocol converter. A router by itself transfers, accepts, and relays packets only across networks using similar protocols. A gateway on the other hand, can accept a packet formatted for one protocol and convert it to a packet formatted for another protocol.(eg. TCP/IP ) before forwarding it A gateway is generally software installed within a router. The gateway understands the protocols used by each network linked into the router and is therefore able to translate from one to another. In some cases, the only modifications necessary are the header and trailer of the packet. In other cases, the gateway must adjust the data rate, size and format as well. Fig 7.11 shows a gateway connecting an SNA network (IBM) to a NetWare network (Novell).

Fig 7.11: TCP/IP and the internet (page 705 : forouzan)

Page 147 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology What is a network firewall? A firewall is a system or group of systems that enforces an access control policy between two networks. The actual means by which this is accomplished varies widely, but in principle, the firewall can be thought of as a pair of mechanisms: one which exists to block traffic, and the other which exists to permit traffic. Some firewalls place a greater emphasis on blocking traffic, while others emphasize permitting traffic. Probably the most important thing to recognize about a firewall is that it implements an access control policy. If you don't have a good idea what kind of access you want to permit or deny, or you simply permit someone or some product to configure a firewall based on what they or it think it should do, then they are making policy for your organization as a whole. Why would I want a firewall? The Internet, like any other society, is plagued with the kind of jerks who enjoy the electronic equivalent of writing on other people's walls with spray paint, tearing their mailboxes off, or just sitting in the street blowing their car horns. Some people try to get real work done over the Internet, and others have sensitive or proprietary data they must protect. Usually, a firewall's purpose is to keep the jerks out of your network while still letting you get your job done. Many traditional-style corporations and data centers have computing security policies and practices that must be adhered to. In a case where a company's policies dictate how data must be protected, a firewall is very important, since it is the embodiment of the corporate policy. Frequently, the hardest part of hooking to the Internet, if you're a large company, is not justifying the expense or effort, but convincing management that it's safe to do so. A firewall provides not only real security it often plays an important role as a security blanket for management. Lastly, a firewall can act as your corporate "ambassador" to the Internet. Many corporations use their firewall systems as a place to store public information about corporate products and services, files to download, bugfixes, and so forth. Several of these systems have become important parts of the Internet service structure (e.g.: UUnet.uu.net, whitehouse.gov, gatekeeper.dec.com) and have reflected well on their organizational sponsors. What can a firewall protect against? Some firewalls permit only Email traffic through them, thereby protecting the network against any attacks other than attacks against the Email service. Other firewalls provide less strict protections, and block services that are known to be problems.

Generally, firewalls are configured to protect against unauthenticated interactive logins from the "outside" world. This, more than anything, helps prevent vandals from logging into machines on your network. More elaborate firewalls block traffic from the outside to the inside, but permit users on the inside to communicate freely with the outside. The firewall can protect you against any type of network-borne attack if you unplug it.

Firewalls are also important since they can provide a single "choke point" where security and audit can be imposed. Unlike in a situation where a computer system is being attacked by someone dialing in with a modem, the firewall can act as an effective "phone tap" and tracing tool. Firewalls provide an important logging and auditing function; often they provide summaries to the administrator about what kinds and amount of traffic passed through it, how many attempts there were to break into it, etc.

Page 148 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology What can't a firewall protect against? Firewalls can't protect against attacks that don't go through the firewall. Many corporations that connect to the Internet are very concerned about proprietary data leaking out of the company through that route. Unfortunately for those concerned, a magnetic tape can just as effectively be used to export data. Many organizations that are terrified (at a management level) of Internet connections have no coherent policy about how dial-in access via modems should be protected. It's silly to build a 6-foot thick steel door when you live in a wooden house, but there are a lot of organizations out there buying expensive firewalls and neglecting the numerous other back-doors into their network. For a firewall to work, it must be a part of a consistent overall organizational security architecture. Firewall policies must be realistic, and reflect the level of security in the entire network. For example, a site with top secret or classified data doesn't need a firewall at all: they shouldn't be hooking up to the internet in the first place, or the systems with the really secret data should be isolated from the rest of the corporate network.

Another thing a firewall can't really protect you against is traitors or idiots inside your network. While an industrial spy might export information through your firewall, he's just as likely to export it through a telephone, FAX machine, or floppy disk. Floppy disks are a far more likely means for information to leak from your organization than a firewall! Firewalls also cannot protect you against stupidity. Users who reveal sensitive information over the telephone are good targets for social engineering; an attacker may be able to break into your network by completely bypassing your firewall, if he can find a "helpful" employee inside who can be fooled into giving access to a modem pool. What about viruses? Firewalls can't protect very well against things like viruses. There are too many ways of encoding binary files for transfer over networks, and too many different architectures and viruses to try to search for them all. In other words, a firewall cannot replace security- consciousness on the part of your users. In general, a firewall cannot protect against a data-driven attack -- attacks in which something is mailed or copied to an internal host where it is then executed. This form of attack as occurred in the past against various versions of Sendmail and GhostScript, a freely-available PostScript viewer.

Organizations that are deeply concerned about viruses should implement organization-wide virus control measures. Rather than trying to screen viruses out at the firewall, make sure that every vulnerable desktop has virus scanning software that is run when the machine is rebooted. Blanketing your network with virus scanning software will protect against viruses that come in via floppy disks, modems, and Internet. Trying to block viruses at the firewall will only protect against viruses from the Internet - and the vast majority of viruses are caught via floppy disks.

Firewall technology First, a definition "A component or set of components that restricts access between a protected network and the internet, or between other sets of networks." The firewall can be hardware in the form of a router or a computer, software running on a gateway system, or some combination. Each type of implementation has inherent pros and cons, and each specific implementation likewise has good and bad points, strengths and weakness. With that in mind, let's consider the two main types of firewalls.

Page 149 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology VPN Virtual Private Network (VPN) is defined as customer connectivity deployed on a shared infrastructure with the same policies as a private network. The shared infrastructure can leverage a service provider IP, Frame Relay, or ATM backbone, or the Internet. There are three types of VPNs, which align with how businesses and organizations use VPNs: Access VPNProvides remote access to a corporate intranet or extranet over a shared infrastructure with the same policies as a private network. Access VPNs enable users to access corporate resources whenever, wherever, and however they require. Access VPNs encompass analog, dial, ISDN, Digital Subscriber Line (DSL), mobile IP, and cable technologies to securely connect mobile users, telecommuters, or branch offices. Intranet VPNLinks corporate headquarters, remote offices, and branch offices over a shared infrastructure using dedicated connections. Businesses enjoy the same policies as a private network, including security, quality of service (QoS), manageability, and reliability. Extranet VPNLinks customers, suppliers, partners, or communities of interest to a corporate intranet over a shared infrastructure using dedicated connections. Businesses enjoy the same policies as a private network, including security, QoS, manageability, and reliability. This figure provides a logical topology view of a VPN. Currently there are no standards outlining the software and hardware components of a VPN. Every vendor that provides a VPN service performs it in a method that is best supported by its

Fig 7.12: VPN Network

Page 150 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Currently there are no standards outlining the software and hardware components of a VPN. Every vendor that provides a VPN service performs it in a method that is best supported by its own hardware platforms and software applications. The following sections of this chapter discuss the Cisco Systems implementation of VPN services.

Basic VPN Requirements: User Authentication Address Management Data Encryption Key management for servers and client Protocols involved o PPTP (Point-to-Point Tunneling Protocol) o L2TP (Layer Two Tunneling Protocol) o IPSEC (IP Security Tunnel Mode) Network Management The International Organization for Standards (ISO) has created a network management model that is useful for placing the above anecdotal scenarios in a more structured framework. Five areas of network management are defined:

Performance management: The goal of performance management is to quantify, measure, report, analyze, and control the performance (for example, utilization, and throughput) of different network components. These components include individual devices (for example links, routers, and hosts) as well as end-to-end abstractions such as a path through the network. Simple Network Management Protocol (SNMP) plays a central role. Fault Management: The goal of fault management is to log, detect, and respond to fault conditions in the network. The line between fault management and performance management is rather blurred. We can think of fault management as the immediate handling of transient network failures (for example, link, host, or router hardware or software outages. As with performance management, the SNMP protocol plays a central role in fault management.

Configuration management: Configuration management allows a network manager to track which devices are on the managed network and the hardware and software configurations of these devices.

Accountant Management: Accounting management allows the network manager to specify, log, and control user and device access to network resources. Usage quotas, usage-based charging, and the allocation of resource-access privileges all fall under accounting management.

Security Management: The goal of security management is to control access to network resources according to some well-defined policy. The key distribution centers and certification authorities.

Page 151 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Summary: The most important topics of internetworking and Internet management are: o o o How internetworking devices work? Necessity for a firewall, antivirus schemes Various Network management schemes

Page 152 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 9: Advanced Computing Concepts A Survey

Learning Objective After completing this module, you will be able to: Understand pipelining and parallelism concepts Know Client-Server Concepts Understand Multiprocessor Organization Pipelining The Performance of a computer depends on The way in which Compiler translates programs into machine language Choice of machine language instructions The design of hardware Concept of Parallelism Cache Memory concept Measure of performance - Processor clock cycle Execution Time, T in seconds is given by T = (N x S) / R o where N = No. of Machine language instructions o S = Average number of basic steps per instruction o R = Clock rate in Cycles / second Improvement in the performance by PIPELINING techniques RISC and CISC processors

What is Pipelining? Increasing concurrency by dividing a computation into a number of steps and allowing a number of tasks to be in various stages of execution at the same time. Pipelining is the effective way of organizing parallel activity in a computer System It is a technique of decomposing a sequential process into sub operations, with each sub process being executed in a special dedicated segment that works concurrently with all other segments Any operation that can be decomposed into a sequence of sub operations of about the same complexity can be implemented by a pipeline processor This technique is efficient for those applications that need to repeat the same task many times with different sets of data

Page 153 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Example 8.1 We want to perform the combined multiply and add operations with a stream of numbers. Ai * Bi + Ci for i = 1,2,3,..,7 R1 through R5 are registers that receive new data with every clock pulse The sub operations performed are: R1 Ai, R2 Bi R3 R1*R2, R4 Ci R5 R3 + R4

Ai R1 R2

Bi

Ci

Multiplier

R3

R4

Adder

R5

Fig 8.1: Arithmetic Pipeline Scheme An Example

Example 8.1 (Contd.) Clock Pulse Number 1 2 3 4 5 6 7 8 9 A1 A2 A3 A4 A5 A6 A7 ------Segment1 R1 B1 B2 B3 B4 B5 B6 B7 ------R2 ---A1* B1 A2* B2 A3* B3 A4 B4 A5* B5 A6* B6 ---R3 ---C1 C2 C3 C4 C5 C6 -Segment2 R4 ------A1*B1+C1 A2*B2 +C2 A3*B3 +C3 A4*B4 +C4 A5*B5 +C5 A6*B6 +C6 A7*B7 +C7 Segment3 R5

Page 154 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology There are 2 areas of computer design where the pipeline organization is applicable: o o An arithmetic pipeline divides an arithmetic operation into suboperations for execution in the pipeline segments An instruction pipeline operates on a stream of instructions by overlapping the fetch, decode and execute phases of the instruction cycle

With a four-stage pipeline, the rate at which instructions are executed is almost four times that of sequential operation Pipelining does not speed up the time required for the execution of an instruction Pipelining results in more throughput (Number of Instructions per second) Effect of operation that takes more than 1 clock cycle Stalling of pipeline operation Possible reasons for Stalling of Pipeline operation o Some Arithmetic operations o Cache miss o Page fault o Some logic operations o Divide operations Why cant the pipeline operate at its maximum theoretical speed? Different segments may take different times to complete their suboperation. The clock cycle must be chosen to equal the time delay of the segment with maximum propagation time. This causes all other segments to waste time while waiting for the next clock The time delay for a pipeline circuit is usually greater than the nonpipeline equivalent circuit Parallelism Parallelism is the simultaneous execution of the same task (split up and specially adapted) on multiple processors in order to obtain results faster. The idea is based on the fact that the process of solving a problem usually can be divided into smaller tasks, which may be carried out simultaneously with some coordination.

Massive parallelism (MP) is a term used in computer architecture, reconfigurable computing, application-specific integrated circuit (ASIC) and field-programmable gate array (FPGA) design. It signifies the presence of many independent arithmetic units or entire microprocessors, that run in parallel. Today's most powerful supercomputers are all MP systems such as Earth Simulator, Blue Gene, ASCI White, ASCI Red, ASCI Purple, ASCI Thor's Hammer.

Task A logically discrete section of computational work.

Page 155 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Parallel Tasks Tasks whose computations are independent of each other, so that all such tasks can be performed simultaneously with correct results.

Serial Execution Execution of a program sequentially, one statement at a time.

Parallelizable Problem A problem that can be divided into parallel tasks. This may require changes in the code and/or the underlying algorithm. Flynns Classification Computers can be classified with respect to their parallel categories are relevant: processing capability; the following 4

Single instruction, single data stream SISD A serial (non-parallel) computer Single instruction: only one instruction stream is being acted on by the CPU during any one clock cycle Single data: only one data stream is being used as input during any one clock cycle Deterministic execution This is the oldest and until recently, the most prevalent form of computer Examples: most PCs, single CPU workstations and mainframes

Fig 8.2: SISD Process

Single Instruction, Multiple Data (SIMD): A type of parallel computer Single instruction: All processing units execute the same instruction at any given clock cycle Multiple data: Each processing unit can operate on a different data element

Page 156 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology This type of machine typically has an instruction dispatcher, a very high-bandwidth internal network, and a very large array of very small-capacity instruction units. Best suited for specialized problems characterized by a high degree of regularity,such as image processing. Synchronous (lockstep) and deterministic execution Two varieties: Processor Arrays and Vector Pipelines Examples: o o Processor Arrays: Connection Machine CM-2, Maspar MP-1, MP-2 Vector Pipelines: IBM 9000, Cray C90, Fujitsu VP, NEC SX-2, Hitachi S820

Fig 8.3: SIMD Process

Multiple Instruction, Single Data (MISD): A single data stream is fed into multiple processing units. Each processing unit operates on the data independently via independent instruction streams. Few actual examples of this class of parallel computer have ever existed. One is the experimental Carnegie-Mellon C.mmp computer (1971). Some conceivable uses might be: o o Multiple frequency filters operating on a single signal stream Multiple cryptography algorithms attempting to crack a single coded message.

Page 157 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig 8.4: MISD Process

Multiple Instruction Multiple Data (MIMD): Currently, the most common type of parallel computer. Most modern computers fall into this category. Multiple Instruction: every processor may be executing a different instruction stream Multiple Data: every processor may be working with a different data stream Execution can be synchronous or asynchronous, deterministic or non-deterministic Examples: most current supercomputers, networked parallel computer "grids" and multi-processor SMP computers - including some types of PCs.

Fig 8.5: MIMD Process Client Server Definition: The data processing interaction in which a program at one site (the client) sends a request to a program at another site (the server) and awaits a response.

Introduction: Client server is network architecture which separates a client from a server. Each instance of the client software can send requests to a server. Specific Types of servers include: application servers, file servers, terminal servers, and mail servers.

Page 158 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Characteristics of a server: Passive (slave) Waits for requests Upon receipt of requests, processes them and then serves replies Characteristics of a client: Active (master) Sends requests Waits for and receives server replies

Client/server describes the relationship between two computer programs in which one program, the client, makes a service request from another program, the server, which fulfills the request. Although the client/server idea can be used by programs within a single computer, it is a more important idea in a network. In a network, the client/server model provides a convenient way to interconnect programs that are distributed efficiently across different locations. Architecture Generic client/server architecture has two types of nodes on the network: clients and servers. As a result, these generic architectures are sometimes referred to as "two-tier" architectures.

Some networks will consist of three different kinds of nodes: server, application servers which process data for the clients and database servers which store data for the application servers. This is called three-tier architecture. Client Server Model

Fig 8.6: Client Server Model

Client/server describes the relationship between two computer programs in which one program, the client, makes a service request from another program, the server, which fulfils the request. In a network, the client/server model provides a convenient way to interconnect programs that are distributed efficiently across different locations. The communications method in computing includes Local procedure calls and Remote procedure calls.

Page 159 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Remote Procedure Call: This is a protocol that one program can use to request the services from other located in other machine in a network without having to understand the network details. Usually when a program using RPC are compiled into an executable program, a stub is included which acts as the representative of remote procedure code. When the program is run, and the procedure issue the stub receives a request and forwards it to the client runtime in the local computer by the daemons. The client runtime program knows the address of the remote computer and server application. It then sends the request across the network .The server also have a runtime program and stub that interface with remote procedure. The result is returned the same way. Local Procedure Call: A local procedure call (LPC) is an interprocess communication facility for high-speed message passing. In Windows NT, client-subsystem communication happens in a fashion similar to that in the MACH operating system. Each subsystem contains a client-side DLL that links with the client executable. The DLL contains stub functions for the subsystems API. The subsystem process, after the necessary processing, returns the results to the client DLL. The stub function in the DLL waits for the subsystem to return the results and, in turn, passes the results to the caller. The client process simply resembles calling a normal procedure in its own code. In the case of RPC, the client actually calls a procedure sitting in some remote server over the networkhence the name remote procedure call. In Windows NT, the server runs on the same machine; hence the mechanism is called as a local procedure call. Server A computer or device on a network that manages network resources. For example, a file server is a computer and storage device dedicated to storing files. Any user on the network can store files on the server. A print server is a computer that manages one or more printers, and a network server is a computer that manages network traffic. A database server is a computer system that processes database queries. Server Types This list, the many different types of servers used in the marketplace today: A term often used synonymously with operating system, a platform is the underlying hardware or software for a system and is thus the engine that drives the server. Sometimes referred to as a type of middleware, application servers occupy a large chunk of computing territory between database servers and the end user, and they often connect the two. Audio/Video servers bring multimedia capabilities to Web sites by enabling them to broadcast streaming multimedia content.

Server Platforms

Application Servers

Audio/Video Servers

Page 160 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Chat servers enable a large number of users to exchange information in an environment similar to Internet newsgroups that offer real-time discussion capabilities. A fax server is an ideal solution for organizations looking to reduce incoming and outgoing telephone resources but that need to fax actual documents. One of the oldest of the Internet services, File Transfer Protocol makes it possible to move one or more files securely between computers while providing file security and organization as well as transfer control. A groupware server is software designed to enable users to collaborate, regardless of location, via the Internet or a corporate intranet and to work together in a virtual atmosphere. An option for those seeking real-time discussion capabilities, Internet Relay Chat consists of various separate networks (or "nets") of servers that allow users to connect to each other via an IRC network. List servers offer a way to better manage mailing lists, whether they be interactive discussions open to the public or one-way lists that deliver announcements, newsletters, or advertising. Almost as ubiquitous and crucial as Web servers, mail servers move and store mail over corporate networks (via LANs and WANs) and across the Internet. News servers act as a distribution and delivery source for the thousands of public news groups currently accessible over the USENET news network. Proxy servers sit between a client program (typically a Web browser) and an external server (typically another server on the Web) to filter requests, improve performance, and share connections. A Telnet server enables users to log on to a host computer and perform tasks as if they're working on the remote computer itself.

Chat Servers

Fax Servers

FTP Servers

Groupware Servers

IRC Servers

List Servers

Mail Servers

News Servers

Proxy Servers

Telnet Servers

Page 161 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology At its core, a Web server serves static content to a Web browser by loading a file from a disk and serving it across the network to a user's Web browser. This entire exchange is mediated by the browser and server talking to each other using HTTP.

Web Servers

File Server In telecommunication, the term file server has the following meanings: A form of disk storage that hosts files within a network; file servers do not need to be high-end but must have enough disk space to incorporate a large amount of data. Many people mistake file servers for a high-end storage system, but in reality, file servers do not need to possess great power or super fast computer specifications. A computer program, that allows different programs, running on other computers, to access the files of that computer In common parlance, the term file server refers specifically to a computer on which a user can map or mount a drive or directory so that the directory appears to be on the machine at which the user is sitting. Additionally, on this type of file server, the user can read or write a file as though it were part of the file system of the user's computer. Compute Server A computer cluster is a group of loosely coupled computers that work together closely so that in many respects they can be viewed as though they are a single computer. The components of a cluster are commonly, but not always, connected to each other through fast local area networks. Clusters are usually deployed to improve performance and/or availability over that provided by a single computer, while typically being much more cost-effective than single computers of comparable speed or availability. Database Server A Data Server manages data and is typically one or more of many servers in an environment A database server is a computer program that provides database services to other computer programs or computers, as defined by the client-server model. The term may also refer to a computer dedicated to running such a program. Database management systems frequently provide database server functionality, and some DBMS's (e.g., MySQL) rely exclusively on the client-server model for database access. Database Master servers are central and main locations of data while Database Slave servers are synchronized backups of the master acting as proxies.

Page 162 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Communication Server Definition: A specialized network server that provides access to resources on the network for users not directly attached to the network or that permits network users to access external resources not directly attached to the network. Introduction: Communications servers are open, standards-based computing systems that operate as a carriergrade common platform for a wide range of communications applications and allow equipment providers to add value at many levels of the system architecture. Support for communications servers as a category of server is developing rapidly throughout the communications industry. Standards bodies, industry associations, vendor alliance programs, hardware and software manufacturers, communications server vendors and users are all part of an increasingly robust communications server ecosystem.

Regardless of their specific, differentiated features, communications servers have the following attributes: open, flexible, carrier-grade, and communications-focused. Multiprocessor Organization

Introduction: To use multiple processors for parallel execution of programs to improve performances. There are three solutions: Symmetric Multi Processors: several identical processors within the same computer Clusters: a group of interconnected computers working together as a unified computing resource Non Uniform Memory Access: a shared-memory multi-processor architecture for which the access time to a memory words depends on the location of the word and on the processor accessing it.

Page 163 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Summary Pipelining is an effective way of organizing parallel activity in a computer System There are 2 areas of computer design where the pipeline organization is applicable: o o An arithmetic pipeline divides an arithmetic operation into sub-operations for execution in the pipeline segments An instruction pipeline operates on a stream of instructions by overlapping the fetch, decode and execute phases of the instruction cycle

Flynns Classification of Parallel Computers Various types of Servers and their Applications Performance improvement through Multiprocessor Organization Test your Understanding 1. Which of the following is TRUE about Pipelining? a. Pipelining doesnt speed up the rate of execution of instruction b. Throughput remains the same in pipelining c. Stalling cannot happen in a Pipeline d. None of the above 2. What is parallelism? 3. Is MISD implementation viable? 4. What is two-tier and three-tier architectures? 5. Which protocol is used for browsing web pages in the web server context? Answer: 1. a

Page 164 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 10: Case Study UNIX

Learning Objectives After completing this chapter, you will be able to: Understand the internal working of UNIX OS What is UNIX? UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. . It is a stable, multi-user, multi-tasking system for servers, desktops and laptops. UNIX is highly portable across hardware since it is written in C language.

UNIX allows only needed modules to be loaded in memory (modularity).It has an inverted tree like file structure, with files and directories created within the file structure. Each file can be protected using read, write and execute permissions for the user, group and others(security).. UNIX uses TCP/IP protocol. CAD/CAM applications best perform in a UNIX system, with its varied support for graphic cards.

UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which are not covered by a graphical program, or when there is no windows interface available, for example, in a telnet session. Types of UNIX There are many different versions of UNIX, although they share common similarities. The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X.

Here in the School, we use Solaris on our servers and workstations, and Fedora Core Linux on the servers and desktop PCs.

History of UNIX 1969: Ken Thompson, Dennis Ritchie started working on a multi-user OS on PDP-7, Bell Labs. 1970: OS named as UNIX 1973: OS rewritten in C 1975: First Version of Berkeley Software Distribution (BSD) 1982: AT&T announced UNIX System III, first public release. 1983: AT&T announced UNIX System V, the first supported release. Installed base 45,000. 1984: Berkeley releases 4.2BSD, includes TCP/IP. X/Open formed. 1984: System V Release 2 introduced. 1, 00,000 installations worldwide.

Page 165 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology 1986: 4.3BSD released, including internet name server. Installed base 2, 50,000. 1987: System V Release 3 introduced. Around 7, 50,000 installations. 1988: Open Software Foundation formed. 1989: System V Release 4 ships unifying System V, BSD and Xenix. 1.2 million installations. its varied support for graphic cards. Layered Architecture UNIX is a layered operating system. The innermost layer is the hardware that provides the services for the OS. The operating system, referred to in UNIX as the kernel, interacts directly with the hardware and provides the services to the user programs. Most well written user programs are independent of the underlying hardware, making them readily portable to new systems.

Fig 9.1: Layered Architecture of the UNIX System

You can have many users logged into a system simultaneously, each running many programs. It's the kernel's job to keep each process and user separate and to regulate access to system hardware, including cpu, memory, disk and other I/O devices. Kernel The kernel of UNIX is the hub of the operating system. It provides the most basic interface between the machines itself and the rest of the operating system. The kernel is responsible for the management of the central processor. The kernel includes the dispatcher to allocate the central processor, to determine the cause of an interrupt and initiate its processing, and some provision for communication among the various system and user tasks currently active in the system.

Page 166 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology The main functions of the kernel are to provide: A mechanism for the creation and deletion of processes, CPU scheduling, memory management, and device management for these processes, Synchronization tools so that the processes can synchronize their actions, Communication tools so that processes can communicate with each other. UNIX System Calls The UNIX operating system has two separable parts: the kernel and the service programs. User programs interact with the kernel through a set of standard system calls. These system calls request services to be provided by the kernel. Such services would include accessing a file: open close, read, write, link, or execute a file; starting or updating accounting records; changing ownership of a file or directory; changing to a new directory; creating, suspending, or killing a process; enabling access to hardware devices; and setting limits on system resources.

The kernel provides control of file system, CPU scheduling, memory management, and other operating system functions through system calls. System calls define the programmer interface to operating system; the set of systems programs commonly available defines the user interface.

System calls also provide the interface between a running program and the operating system. The C language allows system calls to be made directly. Typical system calls are,

_open _close _read _write _getch _putch _ioctl

open a device or file close a device or file read from a device or file write to a device or file read a character from a terminal write a character to the terminal control/set device parameters

Header Files: Header files define how a system call works. A header file contains a definition of the system call, and the parameters (variables) required by the call, and the parameters returned by the system call.

Page 167 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

UNIX User Interface In the last few years, there has been extensive work to improve the user interface to UNIX. The most dramatic effort has been the addition of windowing interfaces on top of UNIX such as Xwindows, Suntools, NextStep, Motif, OpenLook, etc. These windowing interfaces do not change UNIX itself but are built on top of UNIX to provide a more intuitive interface to UNIX. Each of the different user interfaces has some advantages and some disadvantages. Currently intensive development effort is being done on all of these Graphical User Interfaces (GUIs). Even with all of these efforts, UNIX is weak in the end-user interface area. UNIX Shell The shell is your interface to the operating system. It acts as a command interpreter; it takes each command and passes it to the operating system. It then displays the results of this operation on your screen.

An interpreter operates in a simple loop: It accepts a command, interprets the command, executes the command, and then waits for another command. The shell displays a "prompt," to notify you that it is ready to accept your command. This is depicted in Fig. 9.2.

Fig 9.2: Shell Command Loop

Each shell command consists of a command name, followed by command options (if any or desired) and command arguments (if any or desired). The command name, options, and arguments, are separated by a blank space. A program is referred to as a process while the kernel is running it. The kernel can run the same shell program (or any other program) simultaneously for many users on a UNIX system, and each running copy of the program as a separate process.

Many basic shell commands are actually subroutines built in to the shell program. The commands that are not built in to the shell require the kernel to start another process to run them.
Page 168 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology When you execute a non built-in shell command, the shell asks the kernel to create a new sub process (called a "child" process) to perform the command. The child process exists just long enough to execute the command. The shell waits until the child process finishes before it will accept the next command. There are several shells in widespread use. The most common ones are described below. Bourne shell (sh) o Original UNIX shell written by Steve Bourne of Bell Labs. Available on all UNIX systems. Does not have the interactive facilities provided by modern shells such as the C shell and Korn shell. The Bourne shell does provide an easy to use language with which you can write shell scripts. C shell (csh) o Written at the University of California, Berkley. As it name indicates, it provides a C like language with which to write shell scripts. Written by David Korn of bell labs. It is now provided as the standard shell on UNIX systems. Provides all the features of the C and TC shells together with a shell programming language similar to that of the original Bourne shell.

Korn shell (ksh) o

TC Shell (tcsh) o Available in the public domain. It provides all the features of the C shell together with EMACS style editing of the command line. Bourne Again Shell (bash) o Public domain shell written by the Free Software Foundation under their GNU initiative. Ultimately it is intended to be a full implementation of the IEEE POSIX Shell and Tools specification. Widely used within the academic community. Provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh).

Logging in and Logging out

Logging in to a UNIX system requires a username and a password. The person who creates the account, usually the administrator, assigns a Username and a password. The username must be unique. $ is the default prompt of the shell. To change your password, type the command passwd After you have logged in. The system will ask for the old password. Then it will ask for the new password. You will be asked to confirm your new password, to make sure that you didn't mistype. When you're ready to quit, type the command exit

Page 169 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Basic Form of UNIX Commands The basic form of a UNIX command is: commandname [-options] [arguments]

The command name is the name of the program to execute. The command options, usually indicated by a dash, allow to alter the behavior of the command. The arguments are the names of files, directories, or programs that the command needs to access.

The square brackets ([ and ]) signify optional parts of the command that may be omitted. You can abort the current command by typing Control-C.

Getting Help on Commands $ man command: To get the default manual entry of the command.

Example: $ man passwd To get the manual entry on the command passwd.

Simple Shell Commands $ pwd o To print the current working directory $ date o o To display the current system date and time To display only the hour $ date +%H $ who o To list the logged in users of the system $ ls o o To list the names of files and directories To list the names of files and directories in long format $ ls -l $ ls -R o To recursively list the names of files and directories starting from the current directory $ mkdir Telcom_proj o o To create a directory Telcom_proj in the current directory To change the working directory to Telcom_proj $ cd Telcom_proj $ rmdir Telcom_proj o To remove the directory Telcom_proj; The directory should be empty $ cat abc.txt o To display the contents of the file abc.txt on the screen.
Page 170 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology $ cp file1.txt file2.txt o To copy the contents of the file, file1.txt to file, file2.txt $ rm file1.txt o To delete the file file1.txt

Standard Input, Standard Output and Standard Error Input/Output redirection is based on the UNIX standard I/O concept. Each command uses three I/O streams: standard input, standard output and standard error. The standard I/O streams determine where input is read from and output is written to.

I/O Stream

Abbreviation

Description UNIX commands receive information from the user via standard input. By default, standard input is the keyboard. UNIX commands send information to the user via standard output. By default, standard output is the terminal (i.e. written to the screen). UNIX commands send error messages to the user via standard error. By default, standard error is the terminal.

Standard Input

stdin

Standard Output

stdout

Standard Error

stderr

Example $ rm -i fhere fnothere remove fhere? y rm: fnothere: No such file or directory rm is used to remove two files, fhere and fnothere. The -i option is used for interactive deletion.

Redirecting Standard Input When programs require input from the user, it is usually entered from the keyboard. However, it can be read from a file by following the command with a less than sign (<) followed by a filename. command < filename

This is useful with UNIX commands that do not open files. For example, the tr (translate characters) command is used to transform one string into another.

Page 171 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Example $ tr "[:lower:]" "[:upper:]" < file1 Will change all characters in file1 from lower case to upper case and print the results to the screen.

Redirecting Standard Output The output from a command can be saved in a file by following any command with a greater than sign (>) followed by a filename. command > filename

Example $ cat file1 file2 > file3 Saves the contents of file1 and file2 into a new file named file3. The output from the cat command is redirected from the terminal to the file, file3. If file3 already exists then it will be overwritten.

$ cat file2 >> file3 Appends the contents of file2 to file3. The result is file3 contains the contents of file1 followed by the contents of file2.

Standard input and standard output can be redirected in the same command.

$ tr "[:lower:]" "[:upper:]" < file1 > file2 Will change all characters in file1 from lower case to upper case and save the results in the file, file2.

Piping Piping directs the standard output of one UNIX command into the standard input of another UNIX command. Piping is done by separating two commands with a pipe character (|).

cmd1 | cmd2

Example $ ls | more Sends output from the ls command to the more command. This is useful if a directory listing scrolls off the screen.

Page 172 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

UNIX Process Management The Process ID (PID) Every process running on UNIX server has a unique number called the process id abbreviated as PID. When you start a process in the background, the system displays the PID associated with the background process. For example, $ longcmd & [1] 310 The PID associated with longcmd is 310. All processes have a PID. $ ps Will list the status of all processes being executed

Process Context Process context includes the following: User Level Context : Program text, data and stack (dynamic allocation of variables) Register Level Context : Value of Program Counter (PC), Contents of the processors registers, Value of the variables System Level Context : o Static: Process table entry, uarea, Per Process region table; o Dynamic: User Stack which typically contains data such as subroutine parameter, return address, and temporary variables; Kernel stack which typically contains temporary data such as subroutine parameter, return address, and temporary variables of system calls

Process table The O/S maintains information about each process in a process table. Entries in this table are often called process control blocks and must contain information about process state memory state resource state for each process.

Process state includes the value of each register program counter stack pointer state of the process (runnning, runnable, blocked) process ID of itself, its parent, etc. elapsed time. pending signals that have not yet been dealt with (eg they arrived while the process was asleep).

Page 173 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Memory state Pointers to the various memory areas used by the program need to be kept, so that they can be relocated back as needed.

Resource state The process will generally have files open in particular directory, have a certain user ID, etc. The information about these will need to be stored also.

In UNIX each process has a file table. The first entry in this (file descriptor zero) is for the processes' standard input, the second entry is for standard output, the third for standard error. Additional entries are made when the process opens more files.

Fig. 9.3: Process Implementation Scheme

Figure 9.3 depicts a simple process implementation scheme. There are two processes, A and B, each with its own instructions, data and context, stored in main memory. The OS maintains, also in memory, a list of pointers to the above processes, and perhaps some additional information for each of them.

The content of a ``current process'' location identifies which process is currently being executed. The processor registers then contain data relevant to that particular process. Among them are the base and top addresses of the area in memory reserved to the process: an error condition would be trapped if the program being executed tried to write in a memory word whose address is outside those bounds.

Page 174 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Process States and Transitions When a system boots UNIX, it creates a single process called ``init''. This init acts as the root of the process tree. The init forks a set of copies of itself, one for each terminal line that is connected to it. Each one of these, type the login message and then blocks waiting for terminal input.

When the user name and password are typed, init checks that the user is valid, and if so changes to the user's home directory, resets the user ID of the process to the user, and ``exec''s a shell. At this point the init for that terminal line has been replaced by the login shell for that user. The user does whatever they want to do, and eventually logs out.

Logging out terminates the login shell. In the meantime, the init at the top of the process tree has done a wait, waiting on any of its children. The login shell is in fact a direct child of this top level init because it came from exec-ing a child. So when the shell terminates, the top level init wakes up.

The top level init then forks a new init for that terminal line and starts a wait again, for another child to terminate.

When a process is created, it goes through a series of states as depicted in Figure 9.3. The following list contains the complete set of process states. 1. The process is executing in user mode. 2. The process is executing in kernel mode. 3. The process is ready to run as soon as the kernel schedules it. 4. The process is sleeping and resides in main memory. 5. The process is ready to run, but the swapper (process 0) must swap the process into main memory before the kernel can schedule it to execute. 6. The process is sleeping, and the swapper has swapped the process to secondary storage to make room for other processes in main memory. 7. The process is returning from the kernel to user mode, but the kernel preempts it and does a context switch to schedule another process. 8. The process is newly created and is in a transition state; the process exists; but it is not ready to run, nor is it sleeping. This state is the start state for all process. 9. The process executed the exit system call and is in the zombie state. The process no longer exists; but it leaves a record containing an exit code. The zombie state is the final state of a process.

First, the process gets created with the fork () system call and it enters the bubble diagram at bubble number 8. Then the process enters state 3 or 5 depending on whether there is enough memory or not. Lets say there is enough memory and it is in state 3. That state is the ready to run in memory, where the process is waiting in line to get its time quantum for the CPU. When the scheduler chooses it based on its scheduling algorithm, the process enters the kernel running state where it finishes its part of the fork () system call.

Page 175 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Fig. 9.4: Process State Transition Diagram

After that, the process can go into the user mode until its time quantum is up. At that time, the scheduler will pick another process to run, and the previous process goes back to the end of the line to wait its turn again. That state is the Preempted state. The preempted state is the same as the ready to run state.

The dotted line shows their equivalence. Eventually the process will get back into the user mode again for another time quantum. But let's say, it makes a system call and it goes back to kernel running again. Lets also say that system call requires the service of some I/O from the disk, but that resource is not available now. Then that process goes to state 4, asleep in memory.

When the I/O becomes available, the interrupt handler awakens the process, and the process enters the ready to run stage again to go back to the CPU. If there is a shortage of memory, then the process gets swapped into the swap space on the hard disk, where the next most suitable process gets to go on memory to get some CPU time. After the process finishes in user mode, it goes back to the kernel mode, and then it exits to stage 9.

Stopping processes There are two ways in which processes can stop: voluntarily stop, or be forced to stop.

Page 176 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Foreground and Background Processes Normally when you enter a command at the UNIX prompt, the next prompt does not appear until the command is finished running. This is called running the command in the foreground and the process associated with the command is called a foreground process. You can also start a command in the background creating a background process. When a command is executed in the background, the UNIX prompt returns immediately. You can continue to work at the UNIX prompt while the command runs. To run a command in the background, append a space and ampersand (&) at the end of the command. UNIX CPU Scheduling Short term scheduling in UNIX is designed to benefit interactive jobs. Processes are given small CPU time slices by an algorithm that reduces to round robin for CPU-bound jobs, although there is a priority scheme. There's no preemption of one process by another when running in kernel mode. A process may relinquish the CPU because it's waiting for I/O (including I/O due to page faults) or because its time slice has expired.

Every process has a scheduling priority associated with it; the lower the numerical priority, the more likely is the process to run. System processes doing disk I/O and other important tasks have negative priorities and cannot be interrupted. Ordinary user processes have positive priorities and thus are less likely to be run than any system process, although user processes may have precedence over one another. The nice command may be used to affect this precedence according to its numerical priority argument.

The more CPU time a process accumulates, the lower (more positive) its priority becomes. The reverse is also true (process aging is employed to prevent starvation). Thus there is negative feedback in CPU scheduling, and its difficult for a single process to take CPU all time.

Old UNIX systems used a 1 sec. quantum for the round-robin scheduling algorithm. Later 4.2BSD did rescheduling every 0.1 seconds, and priority re-computation every second. The round-robin scheduling is accomplished by the timeout mechanism, which tells the clock interrupt driver to call a certain system routine after a specified interval. The subroutine to be called in this case causes the rescheduling and then resubmits a timeout to call itself again 0.1 sec later. The priority recomputation is also timed by a subroutine that resubmits a timeout for itself.

When a process chooses to relinquish the CPU (voluntarily, in a user program, or because this decision is to be made in the kernel context for a process executing that program) it sleep on an even. The system call used for this is called sleep (not to be confused with the C library routine with the same name, sleep(3)). It takes an argument that is by convention the address of a kernel data structure related to an event the process wants to occur before it is awakened. When the event occurs, the system process that knows about it calls wakeup with the address corresponding to the event, and all processes that had done a sleep on the same address are put in the ready queue.

Page 177 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology For example, a process waiting for disk I/O to complete will sleep on the address of the buffer corresponding to the data being transferred. When the interrupt routine for the disk driver notes that the transfer is complete, it calls wakeup on that buffer, causing all processes waiting for that buffer to be awakened. Which process among those actually does run is chosen by the scheduler effectively at random. Sleep, however, also takes a second argument, which is the scheduling priority to be used for this purpose. UNIX Memory Management UNIX, like other advanced operating systems, allows you to use all of the physical memory installed in your system as well as area(s) of the disk (called swap space) which have been designated for use by the kernel in case the physical memory is insufficient for the tasks at hand. Virtual memory is simply the sum of the physical memory (RAM) and the total swap space assigned by the system administrator at the system installation time. Mathematically, Virtual Memory (VM) = Physical RAM + Swap space The UNIX kernel divides the memory into manageable chunks called pages. A single page of memory is usually 4096 or 8192 bytes (4 or 8KB). Memory pages are laid down contiguously across the physical and virtual memory. The System and User Areas When the kernel loads, it uses RAM to keep itself memory resident. Consequently, it has to ensure that user programs do not overwrite/corrupt the kernel data structures (or overwrite/corrupt other users' data structures). It does so by designating part of RAM as kernel or system pages (which hold kernel text and data segments) and user pages (which hold user stacks, data, and text segments). Strong memory protection is implemented in the kernel memory management code to keep the users from corrupting the system area. For example, only the kernel is allowed to switch from the user to the system area. During the normal execution of a UNIX process, both system and user areas are used. A common system call when memory protection is violated is SIGSEGV (you see a "Segmentation violation" message on the screen when this happens. The culprit process is killed and its inmemory portions dumped to a disk file called "core"). Memory Management Schemes: Swapping: Processes requested from different users are allocated space in memory. When RAM is not sufficient to hold all processes, the swapper process swaps out sleeping processes onto the swap device. When the processes move to Ready to Run state, they are swapped back to RAM. The transfer between RAM and swap space is the whole process. The disadvantages of such a scheme are many processes cannot co-exist at the same time in main memory and processes of sizes greater than RAM cannot be executed. Demand Paging: When a process starts in UNIX, not all its memory pages are read in from the disk at once. Instead, the kernel loads into RAM only a few pages at a time. After the CPU digests these, the next page is requested. If it is not found in RAM, a page fault occurs, signalling the kernel to load the next few pages from disk into RAM. This is called demand paging.

Page 178 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology UNIX File System The file system usually refers to the entity which contains all the data for the workstation or server: system data, user data and all binary executable programs runnable on the machine. The word "file system" under UNIX can mean different things. It can refer to the hierarchical UNIX directory tree structure or the virtual file system or the physical file system, depending on the context:

Virtual file system or the UNIX directory tree The hierarchical representation of files and directories of files, with which a user or administrator may perform various functions: e.g. editing, viewing, executing, etc. This is the UNIX interface to the physical file system. Many UNIX resources (including hardware) are available via the virtual file system.

The root of the filesystem and the UNIX directory tree The top level directory under UNIX (denoted by a forward slash - /) is referred to as the root of the UNIX (virtual) filesystem. Under the root directory are a number of directories and files.

One of the unique things about UNIX as an operating system is that regards everything as a file. Files can be divided into the following categories : Ordinary files: Ordinary files can contain text, data, or program information. An ordinary file cannot contain another file, or directory. An ordinary file can be thought of as a one-dimensional array of bytes. Directories: Directories are containers that can hold files, and other directories. A directory is actually implemented as a file that has one line for each item contained within the directory. Each line in a directory file contains only the name of the item, and a numerical reference to the location of the item. The reference is called an i-number or inode, and is an index to a table known as the i-list. The i-list is a complete list of all the storage space available to the file system. Special files: Special files represent input/output devices, like a tty (terminal), a disk drive, or a printer. Special files can be either character special files that deal with streams of characters or block special files that operate on larger blocks of data. Typical block sizes are 512 bytes, 1024 bytes, and 2048 bytes. Links: A link is a pointer to another file. A directory is nothing more than a list of the names and inodes of files. There are two types: o Hard links are not really files. They exist when more than one directory entry references the same inode. Hence, when a hard link is opened by a user program, the directory entry that is opened points directly to the inode of the data to be provided. And, when a hard link is deleted using rm, the directory entry is removed. Only when one deletes the last remaining directory entry that points to an inode are the data deleted. Soft Link is implemented as a directory file entry containing a pathname. The information in the file is the name of the file being referenced. When a user program attempts to read a file that is a soft link, the file system opens the symbolic link file, reads the reference, and then opens the file that is referenced. File management programs operate on the symbolic link file. For example, ls -l reads the symbolic link file and displays the name of the file being referenced, and

Page 179 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology rm deletes the symbolic link file, leaving untouched the file that is referenced by the link. Soft links are distinguishable from files, and can span across file systems.

Physical file system The collection of data represented by the virtual file system. The physical file system may be arranged on one or more actual storage devices, typically hard disks.

Fig. 9.5: Components of a File System

Every file system is organized in a sequence of blocks of 1024 bytes and generally has four components namely, Boot Block: Is the Master Boot Record (MBR) that contains a small boot program and the partition table. When the system is booted, the system BIOS checks for the existence of the first hard disk and loads the entire segment of the boot block into memory. It then hands over control to the bootstrapping program. This in turn loads the kernel into memory. However, the bootstrapping program is read in from the boot block of the root file system. For other file system, this block is simply kept blank. Super Block: contains global file information about disk usage and availability of data blocks and inodes. It contains o o o o o o Size of the file system Length of the file systems logical block Last time of updating in-memory to disk Number of free data block available and a partial list of immediately allocable free data blocks. Number of inodes available and a partial list of immediately usable inodes. The state of the file system

Inode Block: Every file has an inode a 128-byte table. All inodes are stored in a contiguous area called inode block in a user inaccessible area of the file system. The files inode is used as an index into this inode block. Each inode contains the following attributes of a file: o o o o o o o o o File type (regular, directory, device, etc.) Number of links (the number of aliases the file has) User-id (owner of the file) Group-id of the owner File modes of user, group and others (three permissions) Size of the file (bytes) Date and time of last modification of file data Date and time of last access of file data Date and time of last change of the inode.

Page 180 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology o An array of 15 pointers to the file. (addresses where the contents of the file are stored )

Data Blocks: The smallest block that can be read and written by the disk controller is 512 bytes. Its often called as a physical block. The kernel reads and writes data using a different block size, and this block is often referred to as a logical block. The data blocks commence from the point the Inode blocks terminate. Every block is identified by an address a number that refers to the position of the block in the data block area. The blocks containing data are known as direct block. The blocks of a file are mostly not contiguous. When a file expands, the kernel may not find the adjacent block free. It has to locate a free one from the blocks scattered randomly throughout the disk. This slow down read/write operations and lead to disk fragmentation. The inode keeps track of all direct block addresses (12) and some indirect blocks. The indirect blocks do not contain data but only the addresses of those direct blocks which couldnt be a accommodated in the inode. UNIX I/O Subsystem Special files are also known as device files. In UNIX all physical devices are accessed via device files; they are what programs use to communicate with hardware. Device files contain information on location, type, and access mode for a specific device. When a device file is opened, the kernel uses the information in it to determine which physical device to access and how to access it.

There are two types of device files; character and block, as well as two modes of access. Block device files are used to access block device I/O. Block devices do buffered I/O, meaning that the the data is collected in a buffer until a full block can be transferred. Character device files are associated with character or raw device access. They are used for unbuffered data transfers to and from a device. Rather than transferring data in blocks the data is transferred character by character. One transfer can consist of multiple characters.

Fig. 9.6: Relationship between inode and data blocks

Page 181 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Some devices, such as disk partitions, may be accessed in block or character mode. Because each device file corresponds to a single access mode, physical devices that have more than one access mode will have more than one device file.

Device files are found in the /dev directory. Each device is assigned a major and minor device number. The major device number identifies the type of device, i.e. all SCSI devices would have the same number as would all the keyboards. The minor device number identifies a specific device, i.e. the keyboard attached to this workstation.

Device files are created using the mknod command. The form for this command is:

mknod device-name type major minor Where: device-name is the name of the device file type is either "c" for character or "b" for block major is the major device number minor is the minor device number UNIX IPC

Introduction to Inter Process Communication Processes do not run in isolation from each other. Generally they need to communicate with each other.

Examples Any two processes in a pipeline are communicating. One sends a stream of bytes to the other. Access to the lineprinter is controlled by a single process called ``lpd'' (the lineprinter daemon). Each time a user runs ``lpr'' this has to communicate with ``lpd'' and send it the file to print. Your home directories are stored on the machine ``willow''. Each time you access a file the O/S has to make a connection to willow, request the file from a suitable process on willow and accept responses from it.

Files and shared memory suffer from various concurrent processing problems. For example, if one process is putting information into a file, how does the other process know that the first process is done and it can go ahead and read the file or how does a process know when another process has read the message in a file and it is safe to delete it. Pipes and named pipes get away from these problems.

Page 182 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Shared memory If two processes share the same piece of memory then they can use this to communicate. For example, one may write information in this shared area and the other may read it.

This can be a very fast method of information transfer because RAM can be used. Synchronisation is a major problem - if the first process keeps writing data, how can it ensure that the second one reads it?

Pipe A pipe acts like a channel between two processes. When one process writes into the pipe the other process can read from it. A pipe can usually buffer information so that the writer can place a lot of information in the pipe before the child has to read it. When the pipe becomes full the writer has to suspend.

Pipes can be un-named. This is the norm in UNIX where a process creates a pipe and then forks, so that the two processes share the pipe between them.

If the processes do not come from a common ancestor then they can only share a pipe if they can both name it (otherwise they could not find it). Named pipes usually appear as though they were files in the file system. Streams Pipes carry unstructured data - you put bytes in one end and get the same bytes out the other. Streams are designed to carry record information - you put records in at one end and get the same records out the other. Each record must contain a field saying how large it is.

Message Queues A message queue is like a pipe, and is used to transfer messages between processes in a UNIX system. Unlike a pipe, it retains message boundaries and hence is a much more reliable way for many processes to use the same IPC. This is often the case if a server process is receiving service requests from many different processes. Remember that a named pipe is used for a stream of bytes, so there are no boundaries.

Semaphores A semaphore provides a synchronizing mechanism for processes that are accessing the same resource. No data is passed with a semaphore-it simply coordinates access to shared resources.

Sockets Sockets are more like ports that you can send data to. A process will be ``listening'' at a port and will accept data sent to it.

Page 183 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology Signals Signals are a fairly crude method if IPC. A process may send a signal to another such as ``wake up'' or ``die''. The other process can respond to these signals in various ways. Network Support in UNIX One of the biggest reasons for using UNIX is networking capability. With other operating systems, additional software must be purchased for networking. With UNIX, networking capability is simply part of the operating system. UNIX is ideal for such things as world wide e-mail and connecting to the Internet. In 1984, the University of California at Berkeley released version 4.2BSD which included a complete implementation of the TCP/IP networking protocols. Systems based on this and later BSD releases provided a multi-vendor networking capability based on Ethernet networking. The networking support included, remote login, file transfer, electronic mail, and other important features. As UNIX was ported onto more and more different types of computer hardware the UNIX networking allowed many different types of systems to share and mutually use data. Networks consisting of many different systems could be used as a large distributed system. When SUN Microsystems added NFS (Network File System), this ability to share and mutually use data was significantly enhanced.

UNIX was founded on what could be called a "small is good" philosophy. The idea is that each program is designed to do one job well. Because UNIX was developed by different people with different needs it has grown to an operating system that is both flexible and easy to adapt for specific needs.

UNIX was written in a machine independent language. So UNIX and UNIX-like operating systems can run on a variety of hardware. These systems are available from many different sources, some of them at no cost. Because of this diversity and the ability to utilize the same "user-interface" on many different systems, UNIX is said to be an open system.

A socket is an endpoint of communication between processes. It is a software entity that provides the basic building block for interprocess communications.

SCO TCP/IP supports sockets in the Internet and UNIX domains. A socket has a type and one or more associated processes. Three types of sockets are available to the programmer: stream socket datagram socket raw socket

The TCP/IP protocol and UNIX forms the basis for the Internet.

Page 184 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Session 11: Case Study WINDOWS XP


Learning Objectives After completing this chapter, you will be able to: Classify Windows XP Windows XP Introduction: Microsoft designed Windows XP to be an extensible, portable operating system. Windows XP supports multiples operating environments and symmetric multiprocessing, including both 32 bit and 64 bit processors, and NUMA computers. The use of kernel objects to provide basic services, and support for client server computing. It can run programs compiled for MSDOS, Win 16, Windows 95, Windows 2000, and/or POSIX. It provides virtual memory, integrated caching, and preemptive scheduling. It also supports a security model stronger than those of previous Microsoft operating systems, and includes internationalization

Fig 9.7: Windows XP Architecture


Page 185 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

History In 1988, Microsoft decided to develop a new technology (NT) portable operating system that supported both the OS/2 and POSIX APIs. Originally, NT was supposed to use the OS/2 API as its native environment but during development NT was changed to use the Win32 API, reflecting the popularity of Windows 3.0 Design Principles Extensibility o It is a layered architecture. Executive, which runs in protected mode, provides the basic system services. On top of the executive, several server subsystems operate in user mode. Portability o Windows XP can be moved from on hardware architecture to another with relatively few changes (a) Written in C and C++ (b) Processor-dependent code is isolated in a dynamic link library (DLL) called the hardware abstraction layer (HAL). XP uses hardware protection for virtual memory, and software protection mechanisms for operating system resources.

Reliability o

Compatibility o Applications that follow the IEEE 1003.1 (POSIX) standard can be complied to run on XP without changing the source code Performance o The subsystems can communicate with one another via high-performance message passing. Preemption of low priority threads enables the system to respond quickly to external events and also designed for symmetrical multiprocessing.

International supports different locales via the national language support (NLS) API System Components Kernel Foundation for the executive and the subsystems Never paged out of memory; execution is never preempted There are four main responsibilities: o thread scheduling o interrupt and exception handling o low-level processor synchronization o recovery after a power failure Kernel Process and Threads Threads are the unit of execution scheduled by the kernels dispatcher Each thread has its own state, including a priority, processor affinity, and accounting information

Page 186 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Kernel Scheduling The dispatcher uses a 32-level priority scheme to determine the order of thread execution. Those priorities are divided into two classes o o o o o The real-time class contains threads with priorities ranging from 16 to 31 The variable class contains threads having priorities from 0 to 15 Trends to give very good response times to interactive threads that are using the mouse and windows Enables I/O-bound threads to keep the I/O devices busy Complete-bound threads soak up the spare CPU cycles in the background

Characteristics of XPs priority strategy

Scheduling can occur when a thread enters the ready or wait state, when a thread terminates, or when an application changes Real-time threads are given preferential access to the CPU; but XP does not guarantee that a real-time thread will start to execute within any particular time limit is called soft realtime

Executive Object Manager XP uses objects for all its services and entities; the object manger supervises the use of all the objects o o o Generates an object handle Checks security Keeps track of which processes are using each object

Objects are manipulated by a standard set of methods, namely create, open, close, delete, query name, parse and security Executive Virtual Memory Manager The design of the VM manager supports virtual to physical mapping; a paging mechanism, transparent cache coherence on multiprocessor systems, and virtual address aliasing The VM manager in XP uses a page-based management scheme with a page size of 4 KB The XP VM manager uses a two step process to allocate memory o o The first step reserves a portion of the processs address space The second step commits the allocation by assigning space in the 2000 paging file

Page 187 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Executive Process Manager Provides services for creating, deleting, and using threads and processes. Issues such as parent/child relationships or process hierarchies are left to the particular environmental subsystem that owns the process. Executive Local Procedure Call (LPC) Facility The LPC passes requests and results between client and server processes within a single machine. In particular, it is used to request services from the various XP subsystems. When a LPC channel is created, one of three types of message passing techniques must be specified. 1. suitable for small messages, up to 256 bytes; port's message queue is used as intermediate storage, and the messages are copied from one process to the other. 2. avoids copying large messages by pointing to a shared memory section object created for the channel. 3. Called quick LPC was used by graphical display portions of the Win32 subsystem. Executive I/O Manager The I/O manager is responsible for o o o o file systems cache management device drivers network drivers

Keeps track of which installable file systems are loaded, and manages buffers for I/O requests Works with VM Manager to provide memory-mapped file I/O Controls the XP cache manager, which handles caching for the entire I/O system Supports both synchronous and asynchronous operations. Executive Security Reference Monitor The object-oriented nature of XP enables the use of a uniform mechanism to perform runtime access validation and audit checks for every entity in the system Whenever a process opens a handle to an object, the security reference monitor checks the processs security token and the objects access control list to see whether the process has the necessary rights

Page 188 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

File System The fundamental structure of the XP file system (NTFS) is a volume o Created by the XP disk administrator utility o Based on a logical disk partition o May occupy a portions of a disk, an entire disk, or span across several disks All metadata, such as information about the volume, is stored in a regular file NTFS uses clusters as the underlying unit of disk allocation o o A cluster is a number of disk sectors that is a power of two Because the cluster size is smaller than for the 16-bit FAT file system, the amount of internal fragmentation is reduced

File System Security Security of an NTFS volume is derived from the XP object model Each file object has a security descriptor attribute stored in this MFT record This attribute contains the access token of the owner of the file, and an access control list that states the access privileges that are granted to each user that has access to the file Networking XP supports both peer-to-peer and client/server networking; it also has facilities for network management. To describe networking in XP, we refer to two of the internal networking interfaces: NDIS (Network Device Interface Specification) Separates network adapters from the transport protocols so that either can be changed without affecting the other TDI (Transport Driver Interface) Enables any session layer component to use any available transport mechanism

XP implements transport protocols as drivers that can be loaded and unloaded from the system dynamically. The server message block (SMB) protocol is used to send I/O requests over the network. It has four message types: Session control File Printer Message The network basic Input/Output system (NetBIOS) is a hardware abstraction interface for networks. NetBEUI (NetBIOS Extended User Interface): default protocol for Windows 95 peer networking and Windows for Workgroups; used when XP wants to share resources with these networks.

Page 189 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

Summary The early advantages of UNIX were that this system was written "in a high-level language, was distributed in source form. Files are supported by the kernel as unstructured sequences of bytes. Direct access and sequential access are supported through system calls and library routines. The data blocks are found by pointers in the inode. Directory entries point to inodes. UNIX is a multiprogrammed system. Processes can easily create new processes with the fork system call. Processes can communicate with pipes or, more generally, sockets. Processes are represented by two structures: the process structure and the user structure. Networking support is one of the most important features. The socket concept provides the programming mechanism to access other processes. Test Your Understanding 1. What is the relation between process system time, process waiting time, and process CPU time? 2. What is the difference between UNIX and windows? 3. What is the difference between process and thread ? 4. Different types of Real-Time Scheduling? 5. Difference between Primary storage and secondary storage?

Answers: 1. Process system time (turn around time) = process cpu time + process waiting time 2. UNIX is multi user multi tasking, while windows is single user multi tasking 3. Process is some job or task which is running in background. while a thread is a single line of execution in a programs , so many threads can be there in a program. 4. Hard real-time systems: Required to complete a critical task within a guaranteed amount of time. Soft real-time computing: Requires that critical processes receive priority over less fortunate ones. 5. Main memory: Only large storage media that the CPU can access directly. Secondary storage: Extension of main memory that provides large nonvolatile storage capacity.

Page 190 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

References

Websites http://www.ece.eps.hw.ac.uk/Modules/B35dq1/slides/Performance/sld001.htm http://www.it.kmitl.ac.th/Publish/ComputerOrganization&Architecture/com.htm http://users.cs.cf.ac.uk/David.W.Walker/CM0323/ http://www.mcs.anl.gov/mpi/ For information on the World`s fastest supercomputers : http://www.top500.org www.sei.cmu.edu/str/descriptions/clientserver_body.html en.wikipedia.org/wiki/Client-server www.microsoft.com/windowsserver2003/technologies/storage/default.mspx computing-dictionary.thefreedictionary.com/compute+server https://computeserver.dev.java.net/ www.rollyo.com/explore.html?rollterm=j simple.wikipedia.org/wiki/Wikipedia:Privacy_policy www.rollyo.com/explore.html?rollterm=j www.answers.com/topic/firebird-database-server www.rollyo.com/explore.html?rollterm=j Books B Govindarajalu, Computer Architecture and Organization, Design Principles and Applications John P Hayes, Computer Architecture and Organization Jane Holcombe Charles Holcombe, Survey of Operating Systems Computer Networks A Systems Approach, Larry L.Patterson and Bruce S.Davie William Stallings, Operating Systems: Internals and Design Principles Prentice Hall, 2001 M. Morris Mano, Computer System Architecture Data Communications and Networking, Behrouz A. Forouzan Carl Hamacher, Zvonko Vranesic, Safwat Zaky ,Computer Organization McGrawHill International Edition, 2002.

Page 191 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Handout - Fundamentals of Computer Technology

STUDENT NOTES:

Page 192 Copyright 2007, Cognizant Technology Solutions, All Rights Reserved C3: Protected

Potrebbero piacerti anche