I. Operating System Overview
The operating system architecture consists of three types: module structure, hierarchical structure, and object structure. The module structure is the most efficient, but the system is less understandable, maintainability, and portability.
Linux Kernel is basically a module structure, while the MS-DOS system kernel uses a hierarchical structure, Windows NT/2000 and Solaris is a typical object structure. The operating system kernel can be divided into macro kernel and micro kernel according to its running conditions. The former is also called a single kernel, and the Linux system belongs to the single kernel type. The system kernel of the object structure is usually a microkernel. For example, a Windows NT/2000 system is a microkernel. The Linux kernel uses a module structure and a single kernel mode, which makes the system highly efficient, but the scalability and portability of the system are affected. To solve this problem, Linux uses the additional module technology. By using the module technology, you can easily add new components to the kernel or uninstall kernel components that are no longer needed, and such loading and uninstallation can be performed dynamically. But it also reduces performance. Linux also uses many micro-kernel features. 2. Several Concepts of processor management: jobs and processes
,Program. A job may have one or more programs. In this way, one or more programs will be submitted.
Multiple programs, the data required by these programs, and the necessary job descriptions constitute a job.
A process may contain several programs, and a program may contain several processes. Jobs can be divided into online jobs and batch jobs according to the processing method of jobs. In the Linux time-based batch processing system, you can also divide the Response Features of a job into foreground and background jobs. The process is a program being executed, dynamic, and static. Processes and jobs:
A job is the basic unit for a user to submit a job to a computer system. It is the sum of the work that the user requires the computer to do in a transaction processing or computing process. A process is a running activity of a program with certain independent functions about a data set. It is the basic unit for the operating system to allocate resources and schedule tasks. A job is the entity that describes the task submitted by a user to the system, and a process is the entity that the program executes when the system completes the task. From this perspective, they are at different levels. Jobs describe the task delegation relationship between users and the operating system, while processes describe the specific execution process of tasks within the operating system. A user's task, that is, a job, is submitted to the system by the user and must be completed in the form of a process.
The process switching scene is called the context. It contains all the information of a process, including process control blocks (PCB), related program blocks, and corresponding datasets, generally speaking, the PCB records all the data of the process, all or part of the resident memory. The PCB records the address pointer of the program segment and dataset, process description information, process control information, process-related resource information, and CPU field protection structure. The PCB in Linux is described by the task-struct structure (a process in Linux is called a task ). The process description information includes the process ID (PID, process identifier, user and group identity, and connection information that describes the process family relationship. The process control information records the current status, scheduling information, recording time and time information of the process, and inter-process communication information. The process resource information records the various addresses and materials of the memory related to the process, the file system, and the information about opening the file) field information generally includes basic data such as internal registers and stacks of the processor.
Task-struct is the process control block (PCB) of the Linux system. By operating the PCB, the system allocates resources and schedules the process, and finally creates and revokes the process. The system uses the description information in the PCB to identify a process and determines whether the process should run according to the scheduling information in the PCB. If this process is going to run, first resume the operation site based on the CPU field information, then obtain the corresponding program segment and dataset based on the resource information, and then start execution at the previous position, at the same time, it works together with other processes through the communication information in the PCB.
Several States of the process, three loops, and state conversion process (conditions)
The conversion between process states is usually controlled in three different ways: Process Control primitives, system core functions (such as scheduling), and external events (such as interruptions ).
The primitive call can be called by the kernel or by the parent process.
Process Communication: There are two types of communication: low-level communication, small data size, synchronization and mutex, control the running speed; advanced communication, large data volume, mainly for information exchange. Based on the communication status, process communication can be divided into master-slave, session, message or mailbox mechanisms (without establishing a connection relationship), and shared storage areas (suitable for a large amount of data ). The Process Communication Mechanism in Linux includes signal (low-level communication, two major signal sigstop sigkill. Common processes can only send signals to processes with the same UID and GID or in the same process group. The signal is generated by setting a position in the signal field in the task-struct structure .) , Pipeline (inherited from UNIX, is a special file type, implemented through the file system, suitable for large-scale data transmission), System V (semaphore, message queue, shared memory) socket network threads are introduced to reduce the system overhead of context switching. Internal Threads share process resources, so thread switching efficiency is high. But in Linux, there is no difference between threads and processes, and the same descriptive method and scheduling management are used. Linux also supports system-level threads and user-level threads. Iii. Storage Management