Presentation on theme: "ADAMA UNIVERSITY SCHOOL OF ENGENEERING & INFORMATION TECHNOLOGIES 1-11-1 Sem. II,2010/11 INSTRUCTOR TARIKU W OPERATING SYSTEM (IT3016)"— Presentation transcript:
ADAMA UNIVERSITY SCHOOL OF ENGENEERING & INFORMATION TECHNOLOGIES Sem. II,2010/11 INSTRUCTOR TARIKU W OPERATING SYSTEM (IT3016)
Major Topics Sem II rd year G5-G Introduction to Operating System and its Structures 2. Process Management 3. Memory Management 4. Storage Management 5. Protection And Security Textbook:- o Operating System Concepts- Abraham Silberchatz, Peter B. Galvin, Greg Gagne 7th Edition, John Wiley References: - Operating System, Principles & Deign Implementation, William Stalling Modern Operating System, Andrew S.Tanenbaum, Third edition. Assessment:- 1.Mid………………………..…………… % 2. assignment……………………….…10-15% 3.PROJECT……………………………… % 4.Final……………………………………...40%
Chapter 1 Introduction to OPERATING SYSTEM and Its structures
Introduction Sem II rd year G5-G Computer software can be divided roughly into two kinds: 1. System software:- which manages the operation of the computer itself. 2. Application programs:-which performs the actual work the user wants. The most important system program is the operating system (OS), whose job is to control all the computer's resources and provide a base upon which the application programs can be written. The OS controls and coordinates the use of the hardware among the various system programs and application programs for a various users. It simply provides an environment with which other programs can do useful work.
Definition and Objectives of an Operating System Sem II rd year G5-G Definition: Os is a System program that controls execution of programs to prevent errors and improper use of the computer. acts as an interface between the hardware and its users. Objectives: Convenience – Top Down View – Virtual Machine Extending the real hardware and acting as a Virtual Machine Hiding the truth about the hardware from the user Providing the user a convenient interface which is easier to program Efficiency – Bottom Up View – Resource Manager Providing an orderly and controlled allocation of resources Improving resource utilization Manages all resources
Sem II rd year G5-G Ability to Evolve Adaptability to new changes Hardware upgrades/New types of hardware Need of new services Easy fixes of latent errors Operating Systems and Computer Architecture are historically tied because architectural changes affect both structure of Operating Systems performance of Operating Systems Operating system goals can be summarized as: I. Execute user programs and make solving user problems easier. II. Make the computer system convenient to use. III. Use the computer hardware in an efficient manner.
Computer System Structure Sem II rd year G5-G Computer system can be divided into four components Hardware – provides basic computing resources CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among various applications and users Application programs – define the ways in which the system resources are used to solve the computing problems of the users Word processors, compilers, web browsers, database systems, video games Users People, machines, other computers
Four Components of a Computer System Sem II rd year G5-G
A computer system can be viewed as a system consisting of hardware, software and data. Os provides the means for proper use of these resources An Os is like a government, which does not perform any useful function by itself. But it simply provides an environment so that other programs can perform useful work. Operating system roles Two views a. User view The user view of a computer system depends on the types of interfaces being used. 1. One PC-one user: -a single user monopolizes all the resources that a single PC has. Objective-maximizes work. but no resource sharing C OMPUTER S YSTEM …
Sem II rd year G5-G Users at terminals:-a user sits at a terminal connected to a main frame or a minicomputer. Other users can have access to this same mainframe. Users also may exchange information. objective:-maximizes resource-sharing(the OS must assure that no individual user consumes more than its fair share) 3. Users at workstations connected to networks of other workstations Users have individual resources at their disposal but also share resources such as networks and servers-file, printers,etc. so an OS designed for such purpose must compromise b/n individual usability & resource utilization. 4. Handheld computers:-most are standalone & for individual use. They might be wired/less/. OS designed for these systems maximizes individual usability but performance per amount of power must be an issue. C OMPUTER S YSTEM S TRU ….
Sem II rd year G5-G System view:-from the computers point of view The OS is most intimately involved program with the hardware 1. The OS is a resource manager. Since it manages CPU time, memory space, storage space,I/O devices and so on which are used by the computer system in solving problem. OS manages d/t requests that may conflict with each other and assigns them the available resources fairly. o The OS can deallocate a resource when the program to which it is allocated either terminates or makes an explicit request for deallocation. o Alternatively, it can deallocate a resource by force. This actions is called resource preemption. o System resources may be preempted by an OS to enforce fairness in their use by programs, or to realize certain system-level goals. C OMPUTER S YSTEM S TRU ….
Sem II rd year G5-G o A preempted program can not execute unless the preempted resource unit, or some resource unit of the same resource class, is allocated to it. Resources can be shared by a set of programs in two ways: o Sequential sharing:- a resource is allocated for exclusive use by a program. When the resource is deallocated, it is marked as free in the resource table so that it will be allocated to another program. o Concurrent sharing:- two or more programs can concurrently use the same resource. o The CPU can be shared only in sequential manner where as the memory can be shared in both sequential as well as pool-based manner. C OMPUTER S YSTEM S TRU ….
Sem II rd year G5-G OS is a control program. It manages the execution of user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices. The fundamental goal of a computer system is to execute user programs and make solving user problems easier. For this purpose computer hardware was constructed. But bare hardware is not used for this purpose. This leads to the development of application programs. Application programs have certain common operations, such as controlling I/O devices. The common functions of controlling and allocating resources are brought together into a piece of software called OS. C OMPUTER S YSTEM S TRU ….
Sem II rd year G5-G Operating System Definition OS is a resource allocator Manages all resources Decides between conflicting requests for efficient and fair resource use OS is a control program Controls execution of programs to prevent errors and improper use of the computer No universally accepted definition Everything a vendor ships when you order an operating system is good approximation But varies wildly The one program running at all times on the computer is the kernel. Everything else is either a system program (ships with the operating system) or an application program
Operating System Functions Sem II rd year G5-G Can be summarized into two broad functions: 1. Resource Management Time management - CPU and disk transfer scheduling Space management - main and secondary storage allocation Synchronization and deadlock handling - IPC, critical section, coordination Accounting and status information - resource usage tracking 2. User Environment monitoring- OS layer transforms bare hardware machine into higher level abstractions Execution environment - process management, file manipulation, interrupt handling, I/O operations, language. Error detection and handling Protection and security Fault tolerance and failure recovery
Examples of where you will find OSs Sem II rd year G5-G Servers (Mainframe Computers):- specialized for processing large volumes of requests for a given service. Generally has a large number of necessary resources. 2. Desktops:- specialized for single-user (or limited number of users). o Generally has a GUI that is integral to system software o designed to minimize response time to user requests o May run several different types of operating systems (Windows, MacOS, UNIX, Linux). 3. Embedded Systems:- specialized for managing a limited number of resources such as power, memory, I/O speed. PDAs, cell phones, smart cards, automobiles.
Examples of where you will find … Sem II rd year G5-G Clustered (Message-passing multicomputer) Systems:- are interconnected by a high-speed interconnection fabric. Each processor has its own local memory and they communicate using the interconnect. May share secondary storage. 5. Real-time Systems:- Specialized systems that must meet stringent performance and behavior requirements. RTOS is one that must react to inputs and responds to them quickly. 6. Distributed Systems Distribute the computation among several physical processors. Distributed OS runs on and controls the resources of multiple machines.
Examples of where you will find … Sem II rd year G5-G Parallel Systems Multiprocessor systems with more than on CPU in close communication. 8. Multiprogrammed Batch System Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. 9. Time-Sharing Systems–Interactive Computing Time-sharing systems supports interactive users. It is also called multitasking and it is a logical extension of multiprogramming. Time-sharing systems uses CPU scheduling and multiprogramming to provide an economical interactive system of two or more users. Here each user is given a time-slice for executing his job in round robin fashion. Job continues until the time-slice ends.
Computer Startup Sem II rd year G5-G bootstrap program is loaded at power-up or reboot Typically stored in ROM or EPROM, generally known as firmware Initializes all aspects of system Loads operating system kernel and starts execution Computer System Organization Computer-system operation One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles
Sem II rd year G5-G Computer-System Operation I/O devices and the CPU can execute concurrently. Each device controller is in charge of a particular device type. Each device controller has a local buffer. CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller. Device controller informs CPU that it has finished its operation by causing an interrupt.
Storage Structure Sem II rd year G5-G Main memory – the only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are subdivided into sectors. The disk controller determines the logical interaction between the device and the computer.
Storage-Device Hierarchy Sem II rd year G5-G
Caching Sem II rd year G5-G Important principle, performed at many levels in a computer (in hardware, operating system, software) Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy
Performance of Various Levels of Storage Sem II rd year G5-G Movement between levels of storage hierarchy can be explicit or implicit
Computer system structure Sem II rd year G5-G A computer system can be categorized into a number of ways based on the number of general purpose processors used. 1. single processor systems most systems belongs to this category ranges from PDAs to main frames have one main CPU capable of executing a general purpose instruction set, including instructions from user process. The use of a special purpose processor does not change a single- processor system into multiprocessor.
Sem II rd year G5-G Multiprocessor system also called parallel systems or tightly coupled systems have 2 or more general purpose processors in close communications, sharing the computer bus and sometimes the clock, memory and peripherals. Has three main advantages a. Increased throughput b. Economy of scale c. Increased reliability i. increased throughput. Increasing number of processors =>more work done in less time. The speedup ratio of N-processors is not N. Rather it is less than N(cause- the overhead incurred in keeping all parts working together plus contention for shared resources) C OMPUTER SYSTEM STRUCTURE ( CONT )
Sem II rd year G5-G ii. Economy of scale-multiprocessor systems cost less than equivalent multiple single processor systems, because they can share peripherals, mass storage, and power supplies. If several programs operates on the same set of data, it is cheaper to store those data on one disk and to have all the processors share them than to have many computers with local disks and many copies of the data. iii. Increased Reliability. Functions being distributed properly among several processors, failure of one processor will not halt the system, only slow it down. If 10 processors are there and if one fails, then each of the remaining 9 processors can pickup a share of the work of the failed processor.==>the entire system runs only 10% slower, rather than failing altogether. C OMPUTER SYSTEM STRUCTURE ( CONT )
Computer system structure(cont) Sem II rd year G5-G The ability to continue providing proportional service to the level of surviving hardware is called graceful degradation.(Exc. Compare it with fault tolerant). Multiprocessors are two types o Asymmetric multiprocessors o Symmetric multiprocessors Asymmetric multiprocessors Each processor is assigned a specific task. A master processor controls the system; the other processors either look to the master for instruction or have predefined tasks. Defines a master-slave relationships The master processor schedules and allocates work to the slave processors.
Computer system structure(cont) Sem II rd year G5-G Symmetric multiprocessors(SMP) Each processor performs all tasks within the operating system. SMP-means all processors are peers benefit-many processes can run simultaneously. 3. clustered Systems is a type of multi-CPU system Have multiple CPUs to accomplish computational work(like multiprocessor systems) They are composed of two or more individual systems coupled together(difference with multiprocessors) They share storages and are closely liked via a LAN or faster interconnect such as InfiniBand. Provide high availability service(service will continue even if one or more systems in the cluster fail)
Computer system structure(cont ) Sem II rd year G5-G Clustering can be a. asymmetric mode One machine is in hot-stand-by mode, while the other is running the application. The HSM host machine does nothing but actively monitors the server. If server fails, the HSM become the active server. b. Symmetric mode Two or more hosts are running applications, and are monitoring each other. More efficient as it uses all of the available hardware.
Operating System Structure Sem II rd year G5-G Multiprogramming needed for efficiency Single user cannot keep CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job. Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second
Sem II rd year G5-G Each user has at least one program executing in memory process If several jobs ready to run at the same time CPU scheduling If processes dont fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory VM enables users to run programs that are larger than actual physical memory O PERATING S YSTEM S TRUCTURE ( CONT )
Memory Layout for Multiprogrammed System Sem II rd year G5-G Processor switches from one process to an other when ever an I/O event or Timer interrupt occurs Figure :-4 processes are loaded to memory in Multiprogramming systems
Operating System Components Sem II rd year G5-G All OSs have similar core components Shell(User level) Kernel (core) The shell exposes functions to users and applications Piece of software that provides an interface for users using either command-line or graphical interface Acts as an interface between the user and the kernel. Normally reside on disks and are loaded into memory when needed. The kernel (nucleus) interacts with hardware devices Allocates time & memory to programs and handles the file store & communication in response to system calls Reside in memory all the time and is the hub of the OS
Operating-System Operations Sem II rd year G5-G Modern OS are interrupt driven. Software error or request creates exception or trap Division by zero or invalid memory access. Other process problems include infinite loop, processes modifying each other or the operating system Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user
Sem II rd year G5-G During a transition from User to Kernel Mode an infinite loop may occur. To prevent infinite loop / process hogging resources a Timer is used.how? o Set interrupt after specific period o Operating system decrements counter o When counter zero generate an interrupt o Set up before scheduling process to regain control or terminate program that exceeds allotted time A computer system executing tasks on behalf of a user applications, the system is in user mode. When a user application requests service from an OS(via system call) it is in kernel mode. At system boot time, the hardware starts in kernel mode. Then the OS is loaded and starts execution of user applications in a user mode. System call provide the means for a user program to ask the OS to perform tasks reserved for the OS on the users programs behalf.
Operating system services Sem II rd year G5-G User interface:-command line or GUI Program execution:- I/O operations File System Manipulations Communication Error detection Resource allocation Accounting Protection and Security
Operating System Services Sem II rd year G5-G Below are some of the main services of the operating system that provides helpful functions to the user. User interface - Almost all operating systems have a user interface (UI) Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) I/O operations - A running program may require I/O, which may involve a file or an I/O device. File-system manipulation - programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
Operating System Services (Cont.) Sem II rd year G5-G Communications – Processes may exchange information, on the same computer or between computers over a network Communications may be via shared memory or through message passing (packets moved by the OS) Error detection – OS needs to be constantly aware of possible errors An error may occur in the CPU and memory hardware, in I/O devices, in user program For each type of error, OS should take the appropriate action to ensure correct and consistent computing Debugging facilities can greatly enhance the users and programmers abilities to efficiently use the system Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated Fairley to each of them
Operating System Services (Cont.) Sem II rd year G5-G Many types of resources - Some (such as CPU cycles, Main memory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code. Accounting - To keep track of which users use how much and what kinds of computer resources Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other Protection involves ensuring that all access to system resources is controlled Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
User Operating System Interface - CLI Sem II rd year G5-G CLI allows direct command entry Sometimes implemented in kernel, sometimes by systems program Sometimes multiple flavors implemented – shells Two approaches Primarily fetches a command from user and executes it commands are just names of programs oIn the latter, adding new features doesnt require shell modification
User Operating System Interface - GUI Sem II rd year G5-G User-friendly desktop metaphor interface Usually mouse, keyboard, and monitor Icons represent files, programs, actions, etc Various mouse buttons over objects in the interface cause various actions (provide information, options, execute function, open directory (known as a folder) Invented at Xerox PARC Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI command shell Apple Mac OS X as Aqua GUI interface with UNIX kernel underneath and shells available Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
System Calls Sem II rd year G5-G are ready-made functions comprises of frequently used code(such as device controlling codes-which may waste programmers time if programmers write them) Provide an interface to allow user-level processes to request services of the operating system. Typically written in a high-level language (C or C++), but some are written in assembly and machine languages. The next slide shows the sequence of system calls used in copying data from one file to another file.
Example of System Calls Sem II rd year G5-G System call sequence to copy the contents of one file to another file. even simple programs make heavy use of the operating system. But most programmers do not see this level of detail. Fig;-Example of howsystem calls are used.
Sem II rd year G5-G Usually application developers design programs based on Application Programming Interface(APIs). APIs specify a set of functions that are available to an application programmer, including the parameters used for each function including the return type a programmer expect. Most programs access system calls via APIs, rather than direct system call. Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) Why did an application programmer prefer programming according to APIs instead of invoking direct system calls? Portability:-program designed in APIs can compile and run on other systems sporting the same APIs. Convenience : Actual sys calls are usually more detail and difficult to work with than the API available to app programmer.
Example of Standard API Sem II rd year G5-G Consider the ReadFile() function in the Win32 APIa function for reading from a file A description of the parameters passed to ReadFile() HANDLE filethe file to be read LPVOID buffera buffer where the data will be read into and written from DWORD bytesToReadthe number of bytes to be read into the buffer LPDWORD bytesReadthe number of bytes read during the last read LPOVERLAPPED ovlindicates if overlapped I/O is being used (Note that the system-call names used throughout this presentation are generic, each operating system has its own name for each system call)
System Call Implementation Sem II rd year G5-G Typically, a number associated with each system call System-call interface maintains a table indexed according to these numbers The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)
API – System Call – OS Relationship Sem II rd year G5-G
Standard C Library Example Sem II rd year G5-G C program invoking printf() library call, which calls write() system call
Sem II rd year G5-G Example:-to make clear how a systems call works, consider a read system call with signature as follows. - read(fd,&buffer,nbytes); A call from a C program might look like this; - count=read(fd,&buffer,nbytes); System calls are performed in a number of steps: - to see the steps consider the read system call discussed above.
System Call Parameter Passing Sem II rd year G5-G Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and call Three general methods are used to pass parameters between a running program and the operating system. Simplest: pass the parameters in registers In some cases, may be more parameters than registers Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This approach taken by Linux and Solaris Parameters placed on stack:- parameters are pushed onto the stack by the program and popped off the stack by the operating system Block and stack methods do not limit the number or length of parameters being passed Explain how parameters are exchanged between procedures during a system call
Parameter Passing via Table Sem II rd year G5-G
Types of System Calls Sem II rd year G5-G Generally grouped into five. 1. Process control end, abort load, execute Create process, terminate process Get process attribute, set process attribute Wait event, signal event Allocate and free memory 2. File management Create, delete file Open, close Read, write, reposition Get/set file attributes 3. Device management Request device, release device Read, write, reposition Set/get device attributes Logically attach/detach device 4. Information maintenance get time/date, set time/date get/set system data get/set process, file or device attribute 5. Communications Create, delete, communication connection Send, receive messages Transfer status inform. Attach/detach remote devices
System Programs(cont) Sem II rd year G5-G System programs provide a convenient environment for program development and execution. The can be divided into: File manipulation Status information File modification Programming language support Program loading and execution Communications Application programs Most users view of the operation system is defined by system programs, not the actual system calls
Sem II rd year G5-G Provide a convenient environment for program development and execution Some of them are simply user interfaces to system calls; others are considerably more complex File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories Status information Some ask the system for info - date, time, amount of available memory, disk space, number of users Others provide detailed performance, logging, and debugging information Typically, these programs format and print the output to the terminal or other output devices Some systems implement a registry - used to store and retrieve configuration information S YSTEM P ROGRAMS ( CONT )
System Programs (contd) Sem II rd year G5-G File modification Text editors to create and modify files Special commands to search contents of files or perform transformations of the text Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes provided Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systems Allow users to send messages to one anothers screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another
Operating System Design and Implementation Sem II rd year G5-G Design and Implementation of OS not solvable, but some approaches have proven successful Internal structure of different Operating Systems can vary widely Start by defining goals and specifications Affected by choice of hardware, type of system User goals and System goals User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient
System Implementation Sem II rd year G5-G Traditionally written in assembly language, operating systems can now be written in higher-level languages. Code written in a high-level language: can be written faster. is more compact. is easier to understand and debug. An operating system is far easier to port (move to some other hardware) if it is written in a high-level language.
System Generation (SYSGEN) Sem II rd year G5-G Operating systems are designed to run on any of a class of machines; the system must be configured for each specific computer site. SYSGEN program obtains information concerning the specific configuration of the hardware system. Booting:- starting a computer by loading the kernel. Bootstrap program:- code stored in ROM that is able to locate the kernel, load it into memory, and start its execution.
Operating System Structure Sem II rd year G5-G Modern operating systems are complex and consists of different components. These components of modern systems are interconnected and melded to the kernel. five different OS structures have been tried so far. The five designs are: a. monolithic systems b. layered systems c. virtual machines d. Microkernels and e. modules
I.Monolithic Systems Sem II rd year G5-G written to provide the most functionality in the least space Not divided into modules It is a simple structure. The operating system is written as a collection of procedures, each of which can call any of the other ones whenever it needs to. When this technique is used, each procedure in the system has a well-defined interface in terms of parameters and results, and each one is free to call any other one, if the latter provides some useful computation that the former needs. In this approach, software is characterized by the fact that different parts of the software know each others internal details and freely use this knowledge in their functioning (no data hiding).
Sem II rd year G5-G The following are draw backs of monolithically structured OS: Each OS component is machine dependent, that is, each component has to interface with the computer hardware (bare machine). This made OS development difficult, time consuming and expensive. A change made in one monolithic software component can affect its other components. This is due to the reason that different components of the monolithic software share each others data. Testing and debugging is difficult. MS-DOS is an example of such OSs. M ONOLITHIC S YSTEMS ( CONT )
Simple Structure Sem II rd year G5-G MS-DOS L AYER S TRUCTURE M ONOLITHIC S YSTEMS ( CONT )
II.Layered Approach(Design) Sem II rd year G5- G8 64 Were developed in which functions are organized hierarchically and interaction only takes place between adjacent layers. The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers. In layered approach, most or all of the layers execute in kernel mode. The basic discipline in layered OS design is that the routines of one layer use only the facilities of the layer directly below it, that is, no layer in the structure can be bypassed.
Sem II rd year G5-G The OS is designed to organize the operating system as a hierarchy of layers, each one constructed upon the one below it. The first system constructed in this way was the THE system built at the Technische Hogeschool Eindhoven in the Netherlands by E. W. Dijkstra and his students. L AYERED O PERATING S YSTEM L AYERED A PPROACH ( CONT
Sem II rd year G5-G The layered approach suffers from two problems: 1. The operation of a system be slowed down by the layered structure. Each layer adds a system call overhead. 2. The second problem concerns difficulties in developing a layered design. UNIX UNIX – limited by hardware functionality, the original Unix operating system had limited structuring. The Unix OS consists of two separable parts Systems programs The kernel Consists of everything below the system-call interface and above the physical hardware Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level L AYERED A PPROACH ( CONT )
III.Virtual Machines Sem II rd year G5-G A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. A virtual machine provides an interface identical to the underlying bare hardware. The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory. The resources of the physical computer are shared to create the virtual machines. CPU scheduling can create the appearance that users have their own processor. Spooling and a file system can provide virtual card readers and virtual line printers. A normal user time-sharing terminal serves as the virtual machine operators console.
Virtual Machines(cont) Sem II rd year G5-G The heart of the system, known as the virtual machine monitor, runs on the bare hardware and does the multiprogramming, providing not one, but several virtual machines to the next layer up. However, unlike all other operating systems, these virtual machines are not extended machines, with files and other nice features. Instead, they are exact copies of the bare hardware, including kernel/user mode, I/O, interrupts, and everything else the real machine has. Because each virtual machine is identical to the true hardware, each one can run any operating system that will run directly on the bare hardware.
System Models Sem II rd year G5- G8 69 Non-virtual Machine Virtual Machine V IRTUAL M ACHINES ( CONT )
Strengths/weakness of Virtual Machines Sem II rd year G5-G The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources. A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine. (weakness)
IV.Microkernel System Structure Sem II rd year G5-G Microkernel is a small OS core that provides the foundation for modular extensions. The main function of microkernel is to provide a communication facility between the client program and the various services that are also running in user space. At the bottom layer, running in kernel mode, is a program called the Microkernel. Its job is to allocate resources to virtual machines and then check attempts to use them to make sure no machine is trying to use somebody else's resources. Each user-level virtual machine can run its own operating system, except that each one is restricted to using only the resources it has asked for and been allocated.
. Sem II rd year G5-G The microkernel need only keep track of which virtual machine has been assigned which resource. The microkernel architecture assigns only a few essential functions to the kernel, including address space, inter-process communication and basic scheduling. The microkernel is designed to support execution of OS code which exists outside it. This feature permits new features and facilities to be added to the OS to suit specific operating environments. Benefits: I. easier to extend a microkernel II. easier to port the operating system to new architectures III. more reliable (less code is running in kernel mode) IV. more secure Detriments: Performance overhead of user space to kernel space communication M ICROKERNEL S YSTEM S TRUCTURE ( CONT )
Solaris Modular Approach Sem II rd year G5-G Most modern operating systems implement kernel modules Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel Overall, similar to layers but with more flexible V. M ODULES S YSTEM S TRUCTURE
Practice Exercises Sem II rd year G5-G What are the three main purposes of an operating system? State the main advantage of multiprogramming? What are the main differences between operating systems for mainframe computers and personal computers? In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems. a. What are two such problems? b. Can we ensure the same degree of security in a time-shared machine as we have in a dedicated machine? Explain your answer. What are the differences between a trap and an interrupt? What is the use of each function? Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?
Sem II rd year G5-G What are the five major activities of an operating system in regard to process management? States the functions of the OS in relation to resource management. Describe the three major activities of an operating system in regard to memory management What is the purpose of the command interpreter? Why is it usually separate from the kernel? What is the purpose of system calls? Using system calls, write a program in either C or C++ that reads data from one file and copies it to another file. P RACTICE E XERCISES (C ONT )
END OF CHAPTER ONE Sem II rd year G5-G OPERATING SYSTEM AND ITS STRUCTURES