POSIX

Portable Operating System Interface X indicates its lineage to the Unix API. Linux has progressively implemented this interface; WINDOWS NT partially implemented.

\

The system calls

The user application invokes the API (application program interface) of the system call interface, which intercepts the request and invokes the corresponding system call in the operating system. For the user application, there is no need to know the details of this, only the result of the operation.

\

file

A file is a logical concept and belongs to a virtual device. Think about it.

\

Operating system development language

Linux and Windows XP are written mainly in C, and a few device drivers and register operations are in assembly rather than assembly entirely.

Reason:

1) Fast development, more compact code, and easy to understand and debug

2) Using the latest compilation technology, recompilation can immediately improve the existing product

3) Easier to transplant

4) May be a bit slower than assembly, with increased storage requirements, but these are not problems today. And modern compilation techniques can produce good code that handles complexity better than what a skilled assembler could write by hand

5) The key to performance is data structures and algorithms, not assembly code that executes faster

6) After writing a runnable operating system with high-level language, you can find out the most critical parts of high performance and rewrite them with assembly

Operating system architecture

1) Simple structure

Without a clear and carefully defined structure and functional partition, the system is prone to collapse, or difficult to expand and enhance. Such as MS-DOS and early Unix.

On the one hand, it is because these operating systems were relatively simple at first, with limited functions, and then slowly expanded, with more and more functions, beyond the original scope. On the other hand, it was also limited by the level of hardware at the time.

\

2) the hierarchical

The operating system is divided into several layers, with the hardware at the bottom and the user interface at the top. Each layer can only leverage the functions and services of the lower layers.

Advantages are easy to construct and debug;

The difficulty is how to layer, how to define each layer, and the order of the layers.

The disadvantage is that the command layer transfer, slightly worse efficiency.

\

3) The microkernel removes all non-basic parts from the kernel and implements them as system or user programs, resulting in a smaller kernel. In general, a microkernel includes minimal process and memory management and communication capabilities.

The main function of the microkernel is to provide communication between clients and service programs. The client does not interact directly with the server, but messages are passed through the microkernel. Oh, my God, isn’t that the broker model?

The advantage is easy to expand. If you want to add something, you can add a server without changing the kernel. If you do change the kernel, it doesn’t change much because it’s so small. In addition, the services are so well separated that one problem does not affect the others.

The downside is the increased overhead of system functionality (relying on microkernels for communication?) , the performance deteriorates.

\

4) module

Rather than strip away the non-essential parts, the entire kernel is partitioned into modules that resemble a solar system: several loadable kernel modules surround a core kernel.

Note that loadable three words, which means dynamic management; This management is handled by the core kernel.

At the same time, modules can call each other without communicating through core kernel modules.

The virtual machine

The hardware of a single computer is abstracted into different execution parts, making each independent execution environment as if it were running on its own computer.

The virtual machine has the same interface as the hardware and provides no additional functionality.

Virtual machine implementation is difficult. Because the host operating system has two modes: user mode and kernel mode, and the virtual machine must have both modes, called virtual user mode and virtual kernel mode. If a transition from user mode to kernel mode is caused on the host operating system, there must be a corresponding transition on the virtual machine.

The vm software (software that provides VM services) itself runs in kernel mode of the host operating system, while the VM runs in user mode.

The corresponding examples are

vmWare

Java JVM

The.net CLR

Where CLR is a mechanism, first will. NET source code is compiled into an intermediate language, and local code is compiled at runtime in conjunction with specific machines. I don’t think it’s a virtual machine in the usual sense, because it doesn’t have the illusion of running on your own machine, but it’s actually running on your own machine, just compiled locally before running.

The JVM has a similar mechanism that can be compiled to JIT. But a JVM can also be a generic virtual machine.

System startup

How do I install the operating system after startup? How does the machine know where the OS entry is?

Most computer systems have a small piece of code, called a bootloader, that locates the operating system kernel, loads it into memory, and begins execution.

In the case of a PC, a simple boot program (presumably placed in the BIOS) pulls in a more complex boot program from disk, which then loads the operating system kernel.

The bootstrap program needs to do a number of things. Usually, to self-check, self-check hardware bar, self-check through, and then can proceed. All parts of the system are initialized, from CPU registers to device controllers, and memory. Finally, the operating system boots up.

\