Operating System-Notes-Chapter 1-The Concept of Operating System

Table of contents

1. Chapter 1 - The concept of the operating system

1. The concept and function of the operating system

(1) level

(2) Summary

2. Characteristics of the operating system (4)

(1) Concurrency and parallelism

(2) Sharing and mutual exclusion

(3) virtual

(4) Asynchronous (Asyn)

3. Development and classification of operating systems

(1) Real-time operating system

(2) Network, distributed, personal

4. Operating mechanism of the operating system

(1) User Mode & Kernel Mode

(2) Summary

5. Interruption (※※※※※※)

(1) External interrupt & internal interrupt

(2) Interrupt program - kernel program (kernel state)

(3) Summary

6. System call

(1) Summary

7. The kernel (structural system) of the operating system

(1) Big Kernel & Micro Kernel

(2) Advantages and disadvantages

(3) Summary

8. Operating system (what does the computer do when it is turned on)

9. Virtual machine

(1) On a physical machine (can have multiple operating systems) 

(2) Allocation of virtual machines


1. Chapter 1 - The concept of the operating system

1. The concept and function of the operating system

(1) level

(2) Summary

2. Characteristics of the operating system (4)

(1) Concurrency and parallelism

Concurrency - time period (server - high concurrency: many responses to the request interface can be realized~)

Parallel - time (simultaneous - multi-threaded - multi-core CPU)

(2) Sharing and mutual exclusion

shared - can be used concurrently (resource)

Mutual exclusion - can only be used by one person (data consistency)

Rely on each other (shared & concurrent)

(3) virtual

(4) Asynchronous (Asyn)

With concurrency, there is asynchrony~

That must be multi-threaded ~ (Open a separate thread to achieve asynchronous operation without blocking the main thread)

1.   Synchronization (Synchronous): Synchronization refers to the execution of tasks in sequence, and each task must wait for the completion of the previous task before it can start executing. In synchronous mode, the execution between tasks is blocked, that is, the execution of one task will block the progress of other tasks until the task is completed.

2.   Asynchronous (Asynchronous): Asynchronous means that tasks can be executed concurrently or in parallel, and tasks are independent of each other. In asynchronous mode, the execution of tasks is non-blocking, that is, the execution of a task does not wait for the completion of other tasks, but implements concurrent execution of tasks and return of results through mechanisms such as callback functions and event monitoring.

Asynchronous programming is usually used to deal with situations involving time-consuming operations such as network requests, file operations, and database queries, in order to improve system performance and resource utilization.

Asynchronous programming is generally implemented by technologies such as event-driven, callback function, and coroutine.

  1. Synchronous programming is more intuitive and easy to understand, but it may lead to program performance degradation and resource waste in the case of processing a large number of concurrent tasks or needing to wait.
  2. Asynchronous programming can make better use of system resources and improve the efficiency and responsiveness of programs.
  3. Choosing to use synchronous or asynchronous depends on the specific application scenarios and requirements.
  4. In programming, you can choose the appropriate mode according to the characteristics of the task, or combine synchronous and asynchronous to handle different tasks and situations flexibly.

3. Development and classification of operating systems

(1) Real-time operating system

(2) Network, distributed, personal

4. Operating mechanism of the operating system

(1) User Mode & Kernel Mode

When the user state wants to "override", the hardware CPU will detect the problem! Automatic metamorphosis, and interrupt the program! 

(2) Summary

5. Interruption (※※※※※※)

(1) External interrupt & internal interrupt

Internal interrupt - abnormal (page fault, illegal instruction, trapped instruction-system call)

External interrupt - program processing (IO, clock)

(2) Interrupt program - kernel program (kernel state)

Both hardware and software can implement interrupts - the principles of computer composition are taught

【Interrupt vector table】——after querying—you will know what kind of [interrupt handler] should be executed

(3) Summary

6. System call

Trapped Instructions - System Calls

The corresponding interface is provided by the operating system, so that the application program can use the instruction

When the CPU encounters a [trapped instruction], it will... (the application returns control to the operating system)

Unix is ​​indeed written in [C language], and it is the first operating system written in C language in the world.

[Windows operating system] is developed in [C and assembly language]

[Windows operating system] is now being refactored using [Rust language]

Windows also supports writing applications in other programming languages, such as C++, C#, and Visual Basic.

(1) Summary

7. The kernel (structural system) of the operating system

Both Ubuntu and CentOS are Linux kernels

What they mainly develop is - non-kernel functions (GUI, commands, etc.)

(1) Big Kernel & Micro Kernel

Why a big kernel? ——Because several functions are divided into the kernel state

Microkernel - state transition more

(2) Advantages and disadvantages

large: fast (difficult to maintain)

Micro: slow (modular, easy to maintain)

(3) Summary

8. Operating system (what does the computer do when it is turned on)

First, we have booted through the BIOS, installed an operating system, divided partitions, and installed software

Now start booting:

  1. The CPU reads the disk information (executes the main boot program - hardware self-test)
  2. Execute [disk boot program + partition table]
  3. Read the initialization program of the operating system
  4. Execute the initialization program of the operating system - complete the initialization

Your general description is correct, but some details could be added. The following are fixes and additions to the OS boot process:

  1. After the power is turned on, the computer performs a power self-test to ensure that all hardware devices are normal .
  2. The BIOS chip on the motherboard is accessed to execute the Basic Input/Output System (BIOS) program. BIOS is responsible for initializing each hardware device and performing a series of self-tests , including checking RAM , display adapter, etc.
  3. The BIOS loads the boot program by reading the boot area ( Master Boot Record , MBR ) of the hard drive . MBR is located in the first sector of the partition table, which stores the location and size information of the boot program.
  4. The bootloader loads the operating system's boot loader ( bootloader ), such as GRUB or Windows Boot Manager . The bootloader sits at a specific location on the disk and is responsible for loading the operating system kernel and passing control to it.
  5. The operating system kernel is loaded into memory and starts executing the initialization routine. The initialization program is responsible for configuring the system environment, loading device drivers and initializing various subsystems.
  6. The initialization process usually involves loading some core components, setting up memory management and process management structures, and preparing other necessary system resources.
  7. Once initialization is complete, the operating system is ready for user interaction and other applications can run on the operating system.

It should be noted that different operating systems and computer architectures may vary, but the basic process is generally similar. Also, the details of hard disk partitioning and software installation are usually done after the operating system is initialized.

Self-test - find the bootloader - load - execute

9. Virtual machine

(1) On a physical machine (can have multiple operating systems) 

similar to docker

(2) Allocation of virtual machines

The first category - run directly on physical resources (high authority, fast speed, multiple installations)

The first category - I have a dual system (one Windows, one Ubuntu)

The second category - running on the basis of an operating system (slow speed, low permissions, one is enough~)

The second category - I installed a Ubangtu VMM virtual machine on Windows

The second category - easy migration - can be packaged - and then used by others (similar to docker)

  1. Dual system: You can install two different operating systems on one computer, such as Windows and Ubuntu, and can choose which operating system to enter when booting.
  2. VMM virtual machine: You can install virtual machine software such as VMware or VirtualBox on the Windows operating system and install the Ubuntu operating system in the virtual machine. A virtual machine simulates an isolated computing environment in which to run another operating system.

It's a long way to go, the more I learn, the harder I feel, is it because I don't have enough positive feedback? No, I have to keep working hard, the starlight will live up to the passers-by! Do you remember three years ago? You were still a novice at that time and didn't understand anything, but you had a passion for it! In the past three years, is your blood still there? All of you! ! ! It depends on today! ! ! Keep going, don't give up, you must succeed! You must succeed! ——Anyway , come on! ! ! Grit your teeth and hold on!


Time: August 14, 2023 15:09:25

Guess you like

Origin blog.csdn.net/Pan_peter/article/details/132276090