Operating System 简明教程
Operating System - Structure
操作系统是一种允许用户应用程序与系统硬件交互的结构。由于操作系统是一个如此复杂的结构,因此在创建该操作系统时应非常小心,以便可以轻松使用和修改。实现此目标的一个简单方法是对操作系统进行分拆。这些部分中的每一部分都应明确定义,具有清晰的输入、输出和函数。
An operating system is a structure that allows the user application programs to interact with the system hardware. Since the operating system is such a complex structure, it should be created with utmost care so it can be used and modified easily. An easy way to do this is to create the operating system in parts. Each of these parts should be well defined with clear inputs, outputs and functions.
以下是各种流行的操作系统结构实现。
Following are various popular implementations of Operating System structures.
-
Simple Structure
-
Monolith Structure
-
Micro-Kernel Structure
-
Exo-Kernel Structure
-
Layered Structure
-
Modular Structure
-
Virtual Machines
Simple Structure
有许多结构相当简单的操作系统。这些系统一开始很小,后来迅速扩展,远远超出了其范围。MS-DOS 就是一个常见的例子。它仅为小部分人设计。没有迹象表明它会变得如此受欢迎。
There are many operating systems that have a rather simple structure. These started as small systems and rapidly expanded much further than their scope. A common example of this is MS-DOS. It was designed simply for a niche amount for people. There was no indication that it would become so popular.
与 MS-DOS 不同,操作系统最好具有模块化结构。那样将对计算机系统及其各种应用进行更好的控制。模块化结构还允许程序员根据需要隐藏信息,并根据自己的需要实现内部例程,而无需更改外部规格。
It is better that operating systems have a modular structure, unlike MS-DOS. That would lead to greater control over the computer system and its various applications. The modular structure would also allow the programmers to hide information as required and implement internal routines as they see fit without changing the outer specifications.
Advantages
以下是简单操作系统结构的优点。
Following are advantages of a simple operating system structure.
-
Easy Development - In simple operation system, being very few interfaces, development is easy especially when only limited functionalities are to be delivered.
-
Better Performance - Such a sytem, as have few layers and directly interects with hardware, can provide a better performance as compared to other types of operating systems.
Disadvantages
以下是简单操作系统结构的缺点。
Following are disadvantages of a simple operating system structure.
-
Frequent System Failures - Being poorly designed, such a system is not robust. If one program fails, entires operating system crashses. Thus system failures are quiet frequent in simple operating systems.
-
Poor Maintainability - As all layers of operating systems are tightly coupled, change in one layer can impact other layers heavily and making code unmanageable over a period of time.
Monolith Structure
在整体结构操作系统中,称为内核的中心代码部分负责操作系统的全部主要操作。此类操作包括文件管理、内存管理、设备管理等。内核是操作系统的核心组件,它向应用程序和系统程序提供操作系统的全部服务。
In monolith structured operating system, a central piece of code called kernel is responsible for all major operations of an operating system. Such operations includes file management, memory management, device management and so on. The kernal is the main component of an operating system and it provides all the services of an operating system to the application programs and system programs.
内核可以访问所有资源,它充当应用程序和底层硬件之间的接口。一个整体内核结构促进了分时、多道程序模型,并在旧的银行系统中使用。
The kernel has access to the all the resources and it acts as an interface with application programs and the underlying hardware. A monolithic kernel structure promotes timesharing, multiprogramming model and was used in old banking systems.
Advantages
以下是整体操作系统结构的优点。
Following are advantages of a monolith operating system structure.
-
Easy Development - As kernel is the only layer to develop with all major functionalities, it is easier to design and develop.
-
Performance - As Kernel is responsible for memory management, other operations and have direct access to the hardware, it performs better.
Disadvantages
以下是整体操作系统结构的缺点。
Following are disadvantages of a monolith operating system structure.
-
Crash Prone - As Kernel is responsible for all functions, if one function fails entire operating system fails.
-
Difficult to enhance - It is very difficult to add a new service without impacting other services of a monolith operating system.
Micro-Kernel Structure
与整体结构一样,在微内核中存在单个内核,而在微内核中,我们有多个内核,每个内核都专门于特定服务。每个微内核都独立于其他内核开发,并使系统更稳定。如果一个内核发生故障,操作系统将继续使用其他内核功能运行。
As in case monolith structure, there was single kernel, in micro-kernel, we have multiple kernels each one specilized in particular service. Each microkernel is developed independent to the other one and makes system more stable. If one kernel fails the operating sytem will keep working with other kernel’s functionalities.
Advantages
以下是微内核操作系统结构的优点。
Following are advantages of a microkernel operating system structure.
-
Reliable and Stable - As multiple kernels are working simultaneously, chances of failure of operating sytem is very less. If one functionlity is down, operating system can still provide other functionalities using stable kernels.
-
Maintainability - Being small sized kernels, code size is maintainable. One can enhance a microkernel code base without impacting other microkernel code base.
Disadvantages
以下是微内核操作系统结构的缺点。
Following are disadvantages of a microkernel operating system structure.
-
Complex to Design - Such a microkernel based architecture is difficult to design.
-
Performance Degradation - Multi kernel, Multi-modular communication may hamper the performance as compared to monolith architecture.
Exo-Kernel Structure
Exo-Kernal 结构操作系统是在麻省理工学院设计和开发的。该设计的目的是保持内核大小最小,同时允许应用程序直接管理硬件资源。删除硬件资源的操作系统抽象的目的是使应用程序员能够编写高性能代码,而 exo-kernel 处理其他操作。
Exo-Kernal Structured operating system was designed and developed at MIT. The aim of this design was to keep Kernel size minimal while allowing the application programs to manage hardware resources directly. The purpose of removing abstraction of operating system for hardware resources was to enable application programmer to write high performance code while exo-kernel handles other operations.
Advantages
以下是 exo-kernel 操作系统结构的优点。
Following are advantages of a exo-kernel operating system structure.
-
High Performance - As application program can allocate memory, a better designed code can make optimal use and perform better.
-
Application Control - As resource management is not secured by operating system, application program has more control over system resources and can write custom operations on system resources.
Layered Structure
在操作系统中实现模块化的办法之一就是采用分层方法。在这种方法中,最底层是硬件,最顶层是用户界面。
One way to achieve modularity in the operating system is the layered approach. In this, the bottom layer is the hardware and the topmost layer is the user interface.
演示分层方法的图像如下所示:
An image demonstrating the layered approach is as follows −
如图像所示,每一层都基于底层构建。所有层对上层隐藏一些结构、操作等。
As seen from the image, each upper layer is built on the bottom layer. All the layers hide some structures, operations etc from their upper layers.
分层结构中的一个问题是每一层都需要仔细定义。这是必要的,因为上层只能使用下层的各个功能。
One problem with the layered structure is that each layer needs to be carefully defined. This is necessary because the upper layers can only use the functionalities of the layers below them.
Advantages
分层操作系统结构的优点如下。
Following are advantages of a layered operating system structure.
-
High Customizable - Being layered, each layer implmentation can be customized easily. A new functionality can be added without impacting other modules as well.
-
Verifiable - Being modular, each layer can be verified and debugged easily.
Disadvantages
分层操作系统结构的缺点如下。
Following are disadvantages of a layered operating system structure.
-
Less Performant - A layered structured operating system is less performant as compared to basic structured operating system.
-
Complex designing - Each layer is to planned carefully as each layer communicates with lower layer only and a good design process is required to create a layered operating system.
Modular Structure
模块结构操作系统的工作原理与单内核的操作系统类似,但设计更合理。一个中心内核负责操作系统的几乎所有主要操作。此内核具有许多核心功能,其他服务在启动时或在运行时动态地加载到内核中,以模块形式存在。Sun Solaris 操作系统就是模块结构操作系统的示例之一。
Modular structure operating system works on the similar princhiple as a monolith but with better design. A central kernal is responsible for all major operations of operating system. This kernal has set of core functionality and other services are loaded as modules dynamically to the kernal at boot time or at runtime. Sun Solaris OS is one of the example of Modular structured operating system.
Advantages
模块化操作系统结构的优点如下。
Following are advantages of a modular operating system structure.
-
High Customizable - Being modular, each module implmentation can be customized easily. A new functionality can be added without impacting other modules as well.
-
Verifiable - Being modular, each layer can be verified and debugged easily.
Disadvantages
模块化操作系统结构的缺点如下。
Following are disadvantages of a modular operating system structure.
-
Less Performant - A modular structured operating system is less performant as compared to basic structured operating system.
-
Complex designing - Each module is to planned carefully as each module communicates with kernal. A communication API is to be devised to facilitate the communication.
Virtual Machine Structure
在这种结构中,CPU、内存、硬盘之类的硬件都抽象到了虚拟机中。用户可以使用它们,而实际上是使用执行上下文将其进行配置。虚拟机占用大量的磁盘空间,需要进行预置。单个物理机上可以创建多个虚拟机。
In this kind of structure, hardware like CPU, memory, hard disks are abstracted into virtual machines. User can use them with actually configure them using execution contexts. Virtual machine takes a good amount of disk space and is to be provisioned. Muliple virtual machines can be created on a single physical machine.
Advantages
以下是基于虚拟机操作系统的结构的优点。
Following are advantages of a virtual machine based operating system structure.
-
High Customizable - Being virtual, functionality are easily accessible, can be customized on need basis.
-
Secure - Being virtual, and no direct hardware access, such systems are highly secured.
Disadvantages
以下是基于虚拟机操作系统的结构的缺点。
Following are disadvantages of a virtual machine based operating system structure.
-
Less Performant - A virtual structured operating system is less performant as compared to modular structured operating system.
-
Complex designing - Each virtual component of the machine is to planned carefully as each component is to abstract underlying hardware.