360 likes | 667 Views
Operating Systems. Agenda. Revisiting Operating System Structures. 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
E N D
Operating Systems NUST Institute of Information Technology, Pakistanhttp://www.niit.edu.pk
Agenda • Revisiting Operating System Structures
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 • 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
Operating System Design and Implementation (Cont.) • Important principle to separate Policy: What will be done?Mechanism: How to do it? • Mechanisms determine how to do something, policies decide what will be done • The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later • Implementation • Using higher level languages • Can be easily recompiled for different platforms • Assembly language • Optimum implementation • Hybrid
Processor support for dual mode NUST Institute of Information Technology, Pakistanhttp://www.niit.edu.pk
Simple Structure • MS-DOS – written to provide the most functionality in the least space • Not divided into modules • Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated
Layered Approach • 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 • Current trend • Less layers, more functionality per layer
Layered Approach • Debugging is fairly easy as it can be implemented in layers. • Difficulty in careful definition of layers, because each layer can only use layers beneath it. • Another problem is that layered approach tends to be a little slow at times because each process has to go through subsequent layers and each layer might add extra calculations or traps. • Advantage is modularity! • But tend to be less efficient than other types • User program executes an IO operation, it executes a system call that is trapped to the IO layer • IO layer calls the memory management layer • Memory management layer calls the CPU scheduling layer • Then passed to hardware • Overhead at each layer !
UNIX • UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts • System programs [backup slides] • 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
Microkernel System Structure • Kernels grew in size with increased functionality in the OS. • This give birth to the idea of Micro Kernel • Remove unnecessary programs from the kernel into the user space. • Micro kernels typically provide minimal process and memory management, in addition to communication facility • Communication takes place between user modules using message passing. • Idea of having Clients and Servers within one system. • If a program wants to access a file it does not interact directly with kernel but kernel is just used to pass the messages indirectly.
Microkernel System Structure • 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 • Example: Tru64 UNIX, QNX
Modules • 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
Mac OS X Structure • Hybrid structure • Mach • Memory management, inter-process communication, scheduling • BSD • BSD command line interface, support for networking, and file systems etc • Applications can interact with Mach & BSD facilities directly
Windows NT Architecture (Simplified View) • In modern operating systems, applications are kept separate from the operating system itself. • The operating system code runs in a privileged processor mode known as kernel-mode and has access to system data and hardware. • Applications run in a non-privileged processor mode known as user mode and have limited access to system data and hardware through a set of tightly controlled application programming interfaces (APIs).
Windows NT (Case Study) • Windows NT is a multithreaded microkernel-based operating system. • Keeping the base operating system as small and as tight as possible was one of the primary design goals of Windows NT. • To do this, Microsoft kept in the base operating system only those functions that could not reasonably be performed elsewhere. • Functionality pushed out of the kernel was put in six non-privileged servers known as protected subsystems. • The protected subsystems provide the traditional operating system support to applications through a feature-rich set of APIs.
Windows NT (Case Study) • This design results in a very stable base operating system. Enhancements occur at the protected subsystem level. • New protected subsystems can be added without modifying either the base operating system or the other existing protected subsystems
Questions? NUST Institute of Information Technology, Pakistanhttp://www.niit.edu.pk
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
Virtual Machines (Cont.) • 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
Virtual Machines (Cont.) (a) Non virtual machine (b) virtual machine Non-virtual Machine Virtual Machine
Virtual Machines (Cont.) • 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
Operating System Generation • 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
System Boot • Operating system must be made available to hardware so hardware can start it • Small piece of code – bootstrap loader, locates the kernel, loads it into memory, and starts it • Sometimes two-step process where boot block at fixed location loads bootstrap loader • When power initialized on system, execution starts at a fixed memory location • Firmware used to hold initial boot code Boot sequence
Recommended Reading: OSRC http://www.nondot.org/sabre/os/articles M. F. Kaashoek, et. al., "Application Performance and Flexibility on Exokernel Systems “http://www.csie.fju.edu.tw/~yeh/research/papers/os-reading-list/frans-sosp97-exokernel.pdf G. Hamilton and P. Kougiouris, " The Spring Nucleus: A Microkernel for Objects ,“http://www.csie.fju.edu.tw/~yeh/research/papers/os-reading-list/hamilton-usenix93-spring.pdf Questions? NUST Institute of Information Technology, Pakistanhttp://www.niit.edu.pk
System Programs • 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
System Programs • 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
Boot Sequence • All computers running Windows XP Professional share the same startup sequence: • Power-on self test (POST) phase • Initial startup phase • Boot loader phase • Detect and configure hardware phase • Kernel loading phase • Logon phase
Power On Self Test (POST) • As soon as you turn on a computer, its central processing unit (CPU) begins to carry out the programming instructions contained in the basic input/output system (BIOS). • The BIOS, which is a type of firmware, contains the processor dependent code that starts the computer regardless of the operating system installed. • The first set of startup instructions is the power-on self test (POST). The POST is responsible for the following system and diagnostic functions: • Performs initial hardware checks, such as determining the amount of memory present. • Verifies that the devices needed to start an operating system, such as a hard disk, are present. • Retrieves system configuration settings from non-volatile complementary metal-oxide semiconductor (CMOS) memory, which is located on the motherboard.
booting process … • Power on self-test (POST). • Find boot device and load boot record (handled by the system BIOS). The master boot record (MBR) reads the partition table, determines the location of the boot record, and then jumps to that sector and begins execution there. • Windows NT bootstrap routine finds and loads NTLDR. • NTLDR switches processor to 32-bit flat memory mode. • NTLDR reads the BOOT.INI and displays operating system choices. • User selects an operating system (Windows NT in this example). • NTLDR loads NTDETECT.COM. • NTDETECT.COM builds the hardware list. It then passes the list and control back to NTLDR. • NTLDR loads NTOSKRNL.EXE. • NTOSKRNL.EXE loads and initializes Windows NT using information from the Registry to load and initialize drivers and other system settings.