Presentation is loading. Please wait.

Presentation is loading. Please wait.


Similar presentations



2 Major Topics Introduction to Operating System and its Structures
Process Management Memory Management Storage Management Protection And Security Textbook:- 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:- Mid………………………..…………… % assignment ……………………….…10-15% PROJECT……………………………… % Final……………………………………...40% Sem II rd year G5-G8

3 Chapter 1 Introduction to OPERATING SYSTEM and Its structures

4 Introduction Computer software can be divided roughly into two kinds: System software:- which manages the operation of the computer itself. 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. Sem II rd year G5-G8

5 Definition and Objectives of an Operating System
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-G8

6 Operating system goals can be summarized as:
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: Execute user programs and make solving user problems easier. Make the computer system convenient to use. Use the computer hardware in an efficient manner. Sem II rd year G5-G8

7 Computer System Structure
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 Sem II rd year G5-G8

8 Four Components of a Computer System
Sem II rd year G5-G8

9 a. User view Computer System…
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 role’s Two views a. User view The user view of a computer system depends on the types of interfaces being used. One PC-one user: -a single user monopolizes all the resources that a single PC has. Objective-maximizes work. but no resource sharing Sem II rd year G5-G8

10 3. Users at workstations connected to networks of other workstations
Computer System Stru…. 2. 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. Sem II rd year G5-G8

11 System view:-from the computers point of view
Computer System Stru…. System view:-from the computers point of view The OS is most intimately involved program with the hardware 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. The OS can deallocate a resource when the program to which it is allocated either terminates or makes an explicit request for deallocation. Alternatively, it can deallocate a resource by force. This actions is called resource preemption. System resources may be preempted by an OS to enforce fairness in their use by programs, or to realize certain system-level goals. Sem II rd year G5-G8

12 Resources can be shared by a set of programs in two ways:
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: 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. Concurrent sharing:- two or more programs can concurrently use the same resource. 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. Computer System Stru…. Sem II rd year G5-G8

13 Computer System Stru…. 2. 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. Sem II rd year G5-G8

14 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 Sem II rd year G5-G8

15 Operating System Functions
Can be summarized into two broad functions: 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 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 Sem II rd year G5-G8

16 Examples of where you will find OSs
Servers (Mainframe Computers):- specialized for processing large volumes of requests for a given service. Generally has a large number of necessary resources. Desktops:- specialized for single-user (or limited number of users). Generally has a GUI that is integral to system software designed to minimize response time to user requests May run several different types of operating systems (Windows, MacOS, UNIX, Linux). Embedded Systems:- specialized for managing a limited number of resources such as power, memory, I/O speed. PDAs, cell phones, smart cards, automobiles. Sem II rd year G5-G8

17 Examples of where you will find …
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. 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. Distributed Systems Distribute the computation among several physical processors. Distributed OS runs on and controls the resources of multiple machines. Sem II rd year G5-G8

18 Examples of where you will find …
Parallel Systems Multiprocessor systems with more than on CPU in close communication. Multiprogrammed Batch System Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them. 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. Sem II rd year G5-G8

19 Computer System Organization
Computer Startup 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-G8

20 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. Sem II rd year G5-G8

21 Storage Structure 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. Sem II rd year G5-G8

22 Storage-Device Hierarchy
Sem II rd year G5-G8

23 Caching 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 Sem II rd year G5-G8

24 Performance of Various Levels of Storage
Movement between levels of storage hierarchy can be explicit or implicit Sem II rd year G5-G8

25 Computer system structure
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-G8

26 2. Multiprocessor system
Computer system structure(cont) 2. 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 Increased throughput Economy of scale 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) Sem II rd year G5-G8

27 Computer system structure(cont)
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. Sem II rd year G5-G8

28 Computer system structure(cont)
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 Asymmetric multiprocessors Symmetric 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. Sem II rd year G5-G8

29 Computer system structure(cont)
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) Sem II rd year G5-G8

30 Computer system structure(cont)
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. Sem II rd year G5-G8

31 Operating System Structure
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-G8

32 Each user has at least one program executing in memory process
Operating System Structure(cont) 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 don’t 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 Sem II rd year G5-G8

33 Memory Layout for Multiprogrammed System
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 Sem II rd year G5-G8

34 Operating System Components
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 Sem II rd year G5-G8

35 Operating-System Operations
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-G8

36 Set interrupt after specific period
During a transition from User to Kernel Mode an infinite loop may occur. To prevent infinite loop / process hogging resources a Timer is Set interrupt after specific period Operating system decrements counter When counter zero generate an interrupt 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 user’s programs behalf. Sem II rd year G5-G8

37 Operating system services
User interface:-command line or GUI Program execution:- I/O operations File System Manipulations Communication Error detection Resource allocation Accounting Protection and Security Sem II rd year G5-G8

38 Operating System Services
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. Sem II rd year G5-G8

39 Operating System Services (Cont.)
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 user’s and programmer’s 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 Sem II rd year G5-G8

40 Operating System Services (Cont.)
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. Sem II rd year G5-G8

41 User Operating System Interface - CLI
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 In the latter, adding new features doesn’t require shell modification Sem II rd year G5-G8

42 User Operating System Interface - GUI
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) Sem II rd year G5-G8

43 System Calls 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. Sem II rd year G5-G8

44 Example of System Calls
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 how system calls are used. Sem II rd year G5-G8

45 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. Sem II rd year G5-G8

46 Example of Standard API
Consider the ReadFile() function in the Win32 API—a function for reading from a file A description of the parameters passed to ReadFile() HANDLE file—the file to be read LPVOID buffer—a buffer where the data will be read into and written from DWORD bytesToRead—the number of bytes to be read into the buffer LPDWORD bytesRead—the number of bytes read during the last read LPOVERLAPPED ovl—indicates 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) Sem II rd year G5-G8

47 System Call Implementation
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) Sem II rd year G5-G8

48 API – System Call – OS Relationship
Sem II rd year G5-G8

49 Standard C Library Example
C program invoking printf() library call, which calls write() system call Sem II rd year G5-G8

50 - read(fd,&buffer,nbytes);
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. Sem II rd year G5-G8

51 System Call Parameter Passing
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 Sem II rd year G5-G8

52 Parameter Passing via Table
Sem II rd year G5-G8

53 Types of System Calls Generally grouped into five . Process control
Set/get device attributes Process control Logically attach/detach device end, abort Information maintenance load, execute get time/date, set time/date Create process, terminate process get/set system data get/set process, file or device attribute Get process attribute, set process attribute Communications Wait event, signal event Create, delete, communication connection Allocate and free memory Send, receive messages File management Transfer status inform. Create, delete file Attach/detach remote devices Open, close Read, write, reposition Get/set file attributes Device management Request device, release device Sem II rd year G5-G8

54 System Programs(cont)
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-G8

55 Provide a convenient environment for program development and execution
System Programs(cont) 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 Sem II rd year G5-G8

56 System Programs (cont’d)
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 another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another Sem II rd year G5-G8

57 Operating System Design and Implementation
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 Sem II rd year G5-G8

58 System Implementation
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. Sem II rd year G5-G8

59 System Generation (SYSGEN)
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. Sem II rd year G5-G8

60 Operating System Structure
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: monolithic systems layered systems virtual machines Microkernel’s and modules Sem II rd year G5-G8

61 Monolithic Systems Not divided into modules
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 other’s internal details and freely use this knowledge in their functioning (no data hiding). Sem II rd year G5-G8

62 Testing and debugging is difficult.
Monolithic Systems(cont) 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 other’s data. Testing and debugging is difficult. MS-DOS is an example of such OSs. Sem II rd year G5-G8

63 Simple Structure MS-DOS Layer Structure Monolithic Systems(cont)
Sem II rd year G5-G8

64 Layered Approach(Design)
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-G8

65 Layered Approach(cont
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. Layered Operating System Sem II rd year G5-G8

66 Layered Approach(cont)
The layered approach suffers from two problems: The operation of a system be slowed down by the layered structure. Each layer adds a system call overhead. 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 Sem II rd year G5-G8

67 Virtual Machines A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. A virtual machine provides an interface identical to the underlying bare hardware. The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory. The resources of the physical computer are shared to create the virtual machines. CPU scheduling can create the appearance that users have their own processor. Spooling and a file system can provide virtual card readers and virtual line printers. A normal user time-sharing terminal serves as the virtual machine operator’s console. Sem II rd year G5-G8

68 Virtual Machines(cont)
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. Sem II rd year G5-G8

69 System Models Non-virtual Machine Virtual Machine
Virtual Machines(cont) System Models Non-virtual Machine Virtual Machine Sem II rd year G5-G8

70 Strengths/weakness of Virtual Machines
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) Sem II rd year G5-G8

71 Microkernel System Structure
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-G8

72 . Microkernel System Structure (cont)
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: easier to extend a microkernel easier to port the operating system to new architectures more reliable (less code is running in kernel mode) more secure Detriments: Performance overhead of user space to kernel space communication Sem II rd year G5-G8

73 Solaris Modular Approach
V. Modules System Structure 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 Solaris Modular Approach Sem II rd year G5-G8

74 Practice Exercises 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-G8

75 States the functions of the OS in relation to resource management.
Practice Exercises(Cont) 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. Sem II rd year G5-G8



Similar presentations

Ads by Google