Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2.2 Operating-System Structures

Similar presentations


Presentation on theme: "Chapter 2.2 Operating-System Structures"— Presentation transcript:

1 Chapter 2.2 Operating-System Structures
Modified Considerably by your Instructor 35

2 Chapter 2: Operating-System Structures
(Continued from Chapter 2.1 slides) System Programs Operating System Design and Implementation Operating System Structure Virtual Machines Operating System Generation System Boot

3 Focus on Chapter 2.2 Is the Structure of an operating system.
Will start off by looking at ‘system programs.’ To start of discussing systems programs, we need to recall the hardware hierarchy.

4 5. System Programs Let’s recall the architectural hierarchy: (going ‘up’…) Hardware Operating system sits on top of the hardware and is very hardware dependent in many places. System Programs A number are conveniences for us, as in supplying user interfaces to system calls Many are quite complex and low level A number of these are utilities to assist us too. Application Programs. Programs that provide functionality to the users. Let’s look at some typical categories of system programs as well as some samples.

5 System Programs – Overview by Category
File manipulation Used to create, delete, copy, print, list, move, etc. Status information Programs ask for time, number of users, sometimes request debugging information; File modification Create, modify, search, etc. May include text editors, search algorithms for files, etc. Programming language support Compilers, debuggers, interpreters… Program loading and execution Loaders, linkage editors, absolute / relocatable loaders, overlay loaders, and more Communications Creating virtual connections among processes, users, and computing systems. Browse web pages, electronic mail, remote log in, transfer files, etc. Application programs Most computing systems also have programs to solve useful problems, such as word processors, text formatters, spreadsheets, compilers, database systems, etc. Most users’ view of the operation system is defined by system programs and the application programs, not the actual system calls Application programs have little or no knowledge of underlying system calls when their programs request service.

6 6 Operating System Design and Implementation
No simple solution to design / implement an operating system. Hardware influences the design and the type of system batch, time shared, multi-user, etc. But in general no cookbook design approach. A highly-creative, very complex, exacting undertaking! Two general groups of goals to consider in considering a design of an operating system. User goals and System goals User Goals: utility, learnability, usability, reliability, speed, – but there’sno solid agreement on how to achieve these. System Goals: Same: reliable, flexible, efficient, etc. – but no solid agreement on how these requirements can be specifically met.

7 Operating System Design and Implementation (Cont.)
Most older operating systems written in assembler language, such as MSDOS, which (written in 8088 assembler language), This version of DOS was only available on the Intel family of CPUs Tended to be very architecture dependent (register number, size, etc.) Modern systems are normally Almost totally written in C or C++ with some special routines written in assembler language (super efficient speeds) Higher level language implementation offers many advantages over assembler-constructed systems. Among these are: faster construction, ease of understanding and relative ease of debugging Also easier to recompile when changed, and port to other hardware. Higher level language construction disadvantages: reduced speed and increased storage capacities but with modern technologies, these are not significant.

8 Advantages / Disadvantages of OS written in Higher Level Languages
But: Improvement in algorithm usage and data structures can improve performance better than programming in assembler languages. And, Only a small part of the operating system is absolutely critical to overall performance (memory manager and CPU scheduling). Parts of these can be fine-tuned with selective assembler coding. So we can see that most operating systems are written essentially in higher level languages. This has been the case for many years now.

9 7 Operating System Structure Simple Structure
In this section, we’ll look at some approaches to structuring an operating system. Before we go into Virtual Machines, we will consider different structural approaches for the operating system design and implementation: Simple structure Layered approach Micro-kernel approach Modular approach

10 7.1 Simple Structure MS-DOS – written to provide the most functionality in the least space No vision as what it would develop into Not divided into modules Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated Means that application programmers can access basic I/O routines and write directly to display devices and disk drives. Clearly, this leaves MSDOS open to malicious behaviors! Limited too by hardware of this era. There were few protection mechanisms available… Consider the next figure. This shows the original structure of MS-DOS. Again, designers were after the most functionality in limited space.

11 MS-DOS Layer Structure
Most of your operating system is here Low level (device drivers) were here… Read-only memory basic input/output device drivers were here. (burned in chips)

12 7.1 Simple Structure (continued)
Early Unix too suffered from a lack of structuring and protection. Hardware was very slow then and very limited. More modern capabilities of the hardware were not available. Operating System still had two essential components: kernel and system programs Kernel = interfaces & device drivers – everything below system call interface (a device driver is an operating system module (usually in the kernel) that deals directly with a device or I/O module) (different source) (kernel: a portion of the operating system that includes the most heavily used portions of software. Generally, the kernel is maintained permanently in main memory. Kernel runs in privileged mode and responds to calls from processes and interrupts from devices) (different source) All below system call interface and above the physical hardware is the kernel. Kernel provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level Kernel activities are accommodated via system calls. In sum, this is an enormous amount of functionality combined into one level. This monolithic structure was difficult to implement and maintain.

13 UNIX System Structure

14 7.2 Layered Approach The operating system is divided into a smaller pieces arranged in number of layers (levels), each built on top of lower layers. Bottom layer (layer 0), is the hardware; highest layer (layer n), is the user interface. OS can retain much greater control over computer this way. This is a top-down approach Overall functionality and features separated into components. Implemented in layers Modularity is hence established via layers with very separate functionality in each – designed that way as separation of concerns Under this layered architectural design, layers only use functions (operations) and services of lower-level layers. Normally don’t skip over a layer, but can…

15 Layered Design Approach - Advantages
Simplicity of construction. Divide and conquer design goal; cohesive… Simplicity in debugging because functions only use lower-level functions. Layer 1 only uses hardware functions. Debugging is simplified. Layer 2 can have bugs; however, they must lie within that layer, because the layers below are already debugged. Upper level functions have no knowledge of how a lower level function is implemented. Thus we have the hiding of certain data structures and operations.

16 Layered Design Approach - Disadvantages
Must define and document purposes / constraints, features for various layers. Must carefully plan layer contents: layer can only use services of lower level. Some cases requirements may be quite complex; care must be exercised! We will discuss some of these details ahead. Layered approach tends to be less efficient. This is easy to see: A user executes an I/O instruction, that executes a system call that is trapped in the I/O layer, which calls memory management layer, which in turn calls CPU scheduling layer, which is then passed to the hardware. For each layer, parameters and other data may be passed and modified Thus each layer adds overhead to the system call, which may result in a system call that is less efficient than that on a non-layered system. Result: we have a layered architecture with more functionality in each layer Provides for some of the advantages of layering (cohesion; info hiding) while Avoiding the difficult problems of layer definition and interaction (clear definitions of functionality, interface, responsibilities, etc.)

17 Layered Operating System

18 7.3 Microkernel System Structure Design
Microkernel: a small privileged operating system core that provides process scheduling, memory management, and communication services and relies on other processes to perform some of the functions traditionally associated with the operating system kernel. Moves a good bit of non-essential functionality from the kernel into “user” space Removed kernel functionality implemented as system programs; sometimes user programs. In Microkernel OS Design: kernel provides Minimal memory management and Minimal process management and Minimal communications.

19 Microkernel System Structure Design
Benefits: Easier to extend the OS new services are added to user space and not to the kernel. Easier to port the operating system to new architectures because kernel is smaller (as many services are running as user and not kernel processes). Detriments: Communications occurs between user modules using message passing This means that Clients acquire service only indirectly by communication via messages with the microkernel So, clearly, overall performance suffers because of increased system function overhead (passing parameters, and more) This is very significant!

20 7.4 Modular System Structural Design
Most modern operating systems implement kernel modules Flexible approach because kernel provides only critical core features, but kernel knows how to load and communicate with other dynamically-loadable modules as needed. More efficient too, since this approach does not use message processing Additional modules can be developed and added as loadable modules and be added to the kernel as needed, since structure is modular. Communications among modules is via well-defined interfaces. This is probably the most current method for operating system design Uses OO programming techniques to effect the kernel and supporting core services.

21 Solaris Modular Approach
Can readily see how additional modules can be added and implemented as loadable modules when needed. There’s no ‘going through’ layers to get to certain functionality.

22 8 Virtual Machines A virtual machine takes the layered approach to its logical conclusion. A ‘virtual machine’ abstracts the hardware consisting of a single CPU, memory, disk, network interface cards, etc.) into several different (and potentially very different) computing environments! Users get impression s/he has a dedicated machine - with its own processor, memory, file system, et al. User gets impression that s/he has direct access to underlying hardware. But processes do have/require system calls, file I/O , etc., which are NOT provided by the basic hardware So the virtual machine approach provides an interface identical to the underlying bare hardware

23 Virtual Machines (Cont.)
Each process has ‘its own’ kernel, ... running on its own machine. (a) Nonvirtual machine (b) virtual machine Processes; one kernel; hardware VM interface Non-virtual Machine Virtual Machine

24 Virtual Machines – Sharing Disk
Lots of issues with Virtual Machines. (Never a free lunch!) Sharing the same hardware among multiple virtual machines – often with different ‘concurrent operating environments’ presents a number of problems, most prominent is sharing disk. Disk space is a finite resource, and a number of virtual machines simply cannot be allocated separate disk drives. Each virtual machine in practice requires a good amount of disk space to provide virtual memory and spooling. Virtual Memory provides the illusion the entire program is memory resident upon execution) (separate chapters on this topic!) Spooling (covered in depth much later) is essential providing a buffer that holds output for a device, such as a printer or disk, that cannot accept interleaved data streams. Such devices can only accept on stream at a time. Spooling and file system provide virtual card readers and line printers. To assist in this matter, spooling outputs to buffers so that the real writing is done without confusion. Requires queuing and management of spool files.

25 Virtual Machines - Implementation
Recall: underlying real machine has two modes: user mode and kernel mode. The VM software actually runs in kernel mode because it IS the operating system. But the VM itself can execute in only user mode. So, we need a Virtual user mode, and a Virtual kernel mode Both of which run in a physical user mode. So, actions causing a transfer from user mode to kernel mode on a real machine (like a system call) must cause a transfer from virtual user mode to virtual kernel mode on the VM. But it is important to note that there is another downside to this: time. All this switching from one mode to another – regardless of the mechanism used – may well take a good bit of time. Instructions may be simulated, and only certain instructions can be executed in certain modes, so protection must be guaranteed, etc.

26 Virtual Machines (cont) – Benefits:
Virtual-machine concept provides complete protection of system resources each virtual machine is isolated from all other virtual machines but this isolation, 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 a virtual machine, instead of on a physical machine. No disruption of normal services and operations. Lastly, again, the virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine Let’s take a look at a few examples that are interesting…

27 VMware Know that VM abstracts the hardware of host machine along with fundamental resources (CPU, memory, disks, etc.). In VMware, the Intel 80X86 is abstracted into isolated virtual machines. VMware runs as an application on a host operating system such as Windows or Linux and allows this host system to concurrently run several different guest operating systems as independent virtual machines. A good application is presented in your book where a developer wants to develop an application to run under three different operating systems. Under the VM concept, such a set of virtual machines can be readily set up to simulate three different operating environments on one machine. While there are other (less efficient) ways to test this development, the VMware approach provides such an environment.

28 VMware Architecture Each virtual machine has its own CPU, memory, disk drives, network interfaces and more… Different operating systems: This layer abstracts the hardware into isolated virtual machines

29 The Java Virtual Machine
Java is, of course, a language specification and has a large API, and also provides specification for a Java Virtual Machine (JVM). A Java application consists of one or more classes (compiled Java source code). But the compiler produces architectural-neutral bytecode (.class files) that can run on any implementation of a JVM. The JVM is a spec for an abstract computer consisting of a .class loader and a Java interpreter that executes the architectural neutral bytecode file. The Class loader loads the .class files (compiled) If all is loaded well, the JVM runs (interprets) the files. The JVM manages its own memory via garbage collection.

30 The Java Virtual Machine (JVM) - implementation
JVM can be implemented in a number of ways. 1. JVM implemented as software on top of a host operating system such as Windows or Linux. The problem with interpretation is that, in general, a single instruction at a time is interpreted and executed, and this can take a lot of time. 2. But, if the JVM is implemented in software, and a just-in-time (JIT) compiler is used, when a method is invoked, native machine language code can be produced and cached so that subsequent executions of the method use the machine code and do not have to be re-interpreted. 3. An even faster approach is to run the JVM in hardware on a special Java chip that executes the Java byte-code as native code. No need for a Java interpreter or a just-in-time compiler.

31 9. Operating System Generation
While operating systems are designed to run on any of a class of machines, the system must be configured for each specific computer site Think older IBM 370s and all their models. Very common When the operating system is about to be ‘loaded’ it must be ‘configured.’ This process is called System Generation (SYSGEN). SYSGEN program obtains information concerning the specific configuration of the hardware system May be fed by the operator or sensed in the hardware. Memory size, number and characteristics of disk drives, availability of features such as floating point hardware; extended instruction sets, etc., must be determined. Once all the information is gathered, the operating system can be compiled and made ready for ‘booting.’ Again, this can be done a number of ways…. But the notion of a system generation activity is critically important to understand.

32 System Booting OK, So the operating system is configured and ready to go. But how do we … ‘start.’ How does the hardware know where the kernel is or how to even load that kernel? The procedure in starting the computer by loading the kernel is called booting. On most systems, there is a bootstrap loader burned into read-only memory (ROM ). ROM is a chip with burned in instructions and needs no initialization like RAM would need. The bootstrap loader contains the address of the kernel, loads it into main memory, and starts its execution. Sometimes, the bootstrap loader is even smaller. Here, the bootstrap loader code instructs machine to fetch a more complex boot program from disk, which in turn loads the kernel. Specifically, upon powering up, the instruction register in the CPU is loaded with a specific address, which is frequently the location of the bootstrap loader, as described above.

33 System Booting On some small systems, the entire operating system can be burned into ROM. Problem here is, of course, the code cannot be easily changed. Alternative: use EPROM: erasable, programmable read-only memory. EPROM is read-only, unless given an instruction to be ‘writable.’ (All forms of ROM are known as firmware, since their characteristics fall between hardware and software. As your book points out, for large general purpose operating systems, such as Windows, Unix, etc.) or for systems that change frequently, the bootstrap loader is stored in firmware, and the operating system is on disk. Using this approach, the bootstrap loader has a little code to read a single block at some fixed location (say block zero) from disk and execute this code called a boot block. Executing boot block may be sufficient to load entire operating system and begin execution. More likely, the boot block is just some simple code and only knows the address on disk and the length of the remainder of the bootstrap program. Once the full bootstrap program has been loaded, it can traverse the file system to find the operating system kernel, load it into primary memory, and start its execution. Now, the system is said to be running.

34 End of Chapter 2


Download ppt "Chapter 2.2 Operating-System Structures"

Similar presentations


Ads by Google