Operating system principle and Operating System Concept

Source: Internet
Author: User

Operating system principle and Operating System Concept
Operating System Principle We deal with the operating system every day. It is absolutely necessary to understand the operating system principles. It helps you understand how the operating system works, why is there such a problem? It provides us with ideas to solve these problems.
This article is completely written for ordinary computer users. It omits all hard-to-understand algorithms and principles and does not have much detail, it only provides implementation ideas for problems that may interest normal computer users. Writing these things is just my willingness, so I am afraid that I will write more deeply, and beginners will not understand it. If the 10 k text can give you a better understanding of the operating system, it would be a waste of these sweaty summer afternoons.

Q: What is interruption?
A: interruption. Here is an easy-to-understand example.
For example, when Lian and Tang are playing chess, they will soon be unable to stand up. At this crucial moment, Tang
When Tang's girlfriend came, he had to accompany her to the streets to buy clothes (Tang fainted :-), so Tang
Do not discuss with Lian, seal the board first, and continue fighting after buying clothes. Tang
Tang went back to the board with a full face of fatigue. As a result, Lotus was defeated by the strength of the game.
This is the entire interruption process. Let's take a look at how the interrupt process occurs:
1) Request interruption: Tang's girlfriend wants him to go shopping
2) interrupted response: Tang and Tang are preparing to put down the board and accompany his girlfriend to go shopping
3) On-site protection: the Board is first closed
4) interrupt handling: Tang spent time shopping with his girlfriend to buy clothes
5) restore the scene: unseal the Board
6) return of Interruption: continue fighting
In computers, the interrupt mechanism is very important. It is used to coordinate the system's response to various external events.
Handling, and is a necessary condition for achieving multi-task. In this case, if there is no interrupt mechanism,
There is no computer. Oh, by the way, if Tang moves the game to the bottom of the secret room, don't let his girlfriend disturb,
This is called "interruption blocking ".

Q: What does RING3 and RING0 mean?
A: This should start with the privilege level of the CPU Command System (commands used to control the CPU to complete various functions.
Among all the CPU commands, some commands are very dangerous. If they are used incorrectly, the entire system will be
Crash. For example, clear the memory and set the clock. If all programs can use these commands
It's not surprising that your system crashes n times a day. Therefore, the CPU divides commands into privileged commands and non-
Privileged commands: Dangerous commands can only be used by the operating system and its related modules.
Applications can only use commands that do not cause disasters. In the image, privileged commands are
Some children are not suitable, while non-authority commands are suitable for all ages.
Intel's CPU has four levels of privilege: RING0, RING1, RING2, and RING3. Windows only
Use two levels of RING0 and RING3. RING0 is only used by the operating system, and RING3 can be used by anyone.
If a common application attempts to execute the RING0 command, Windows displays an "invalid command" error message.
. Despite the privilege-level protection of the CPU, it is a pity that WINDOW98 has many vulnerabilities and uses
Windows 98 system crashes n times a day.

Q: Why is an operating system required?
A: Haha, have you ever felt the charm of the operating system? Because there is something as good as Windows
In the operating system, we have a problem with our machines one day or later.
We need to reinstall Windows one day or later, so that we can firmly remember
Name, and the name of an outstanding programmer and boss like Bill Gates ......

Well, seriously, although Windows is unstable, it cannot be denied that it is the best practice today.
As one of the systems. The operating system plays an important role in the computer. It provides
A runtime environment that isolates applications from specific hardware. For example, if you change a sound card in a machine
The sound card driver needs to be re-installed, but if there is no operating system, you must
Buy all the applications for this new sound card so that these applications can recognize this sound card.
Card and can use it.
The operating system manages various computer resources, such as memory, disk,
CPU. To use these resources, the application must be approved by the operating system (resource application ),
In addition, the operating system schedules the usage time (resource allocation) in a unified manner, and resources must be
Return to the Operating System (Resource Recovery) for other applications. In this way, the Computer System
Operating system management is the most efficient and methodical.

Q: What is a process? What are the differences between processes and programs?
A: A process is an execution activity of A program on A computer. When you run a program, you start
Process. Obviously, the program is dead (static), and the process is active (dynamic ).
Processes can be divided into system processes and user processes. Any process used to complete various functions of the Operating System
Is the system process, they are the operating system itself in the running state; user processes do not need me
Let's talk about it more. All processes started by you are user processes.
A process is the unit in which the operating system allocates resources. In Windows
The process is refined into threads, that is, multiple processes can run independently.
Smaller unit.

Q: What is multitasking?
A: during the same time period, if two or more processes are allowed to run in the same computer system
Line status, which is multi-task. Modern Operating Systems are almost all multi-task operating systems.
Manage the running of multiple processes. The benefits of multitasking are obvious. For example, you can listen to mp3 while surfing the Internet,
At the same time, you can even print the downloaded documents without interfering with each other.

Q: What is "concurrency "? What is "Parallel "?
A: As the saying goes, the same applies to computers. In principle, one CPU can only be allocated to one
Process to run the process. We usually use only one CPU, that is
Only one heart, to make it single-minded, and run multiple processes at the same time, you must use the Concurrency Technology.
The Concurrency Technology is quite complex. The easiest thing to understand is the "time slice rotation process scheduling algorithm ".
The idea is briefly introduced as follows:
Under the management of the operating system, all running processes use the CPU in turn, and each process is allowed to occupy
CPU time is very short (for example, 10 ms), so that the user does not feel that the CPU is in turn
Multiple process services, as if all processes are running continuously. But in fact
Only one process occupies the CPU Within a period of time. If a computer has multiple CPUs, the situation is different.
If the number of processes is smaller than the number of CPUs, different processes can be allocated to different CPUs for running,
Multiple processes are actually running at the same time, which is parallel. However, if the number of processes is greater than the number of CPUs
Use the Concurrency Technology. In Windows, CPU allocation is based on threads. A process may
It is composed of multiple threads, and the situation is more complicated. But simply put, there is a relationship as follows:
Total number of threads <= number of CPUs: Parallel Operation
Total threads> CPU count: Concurrent Operation
The efficiency of parallel operation is obviously higher than that of concurrent operation. Therefore, in multi-CPU computers, the efficiency of multi-task operations
Relatively high. However, if you run only one process (thread) on multiple CPU computers
CPU advantages. It is worth noting that Windows 9x does not support multiple CPU Systems.
Windows 9x is installed on, and a lot of CPU is useless.

Q: What is "preemptible multitasking "?
A: The process has A priority. If the priority of a running process is higher than that of a running process
High level, the system can forcibly deprive the CPU of the running process, so that the high-priority process runs first.
It can be seen how powerful the privileged ideology of human society is in the computer world. :-)
In practice, the operating system generally combines the time slice idea with the idea of CPU occupation for CPU allocation.
There are many advantages for preemptible multitasking. For example, if a process cannot run unexpectedly
The entire system is paralyzed because the early Windows 3.1 does not
Is a preemptible multitasking system, so Windows 3.1 is very unreliable.

Q: Will multiple processes conflict with each other during concurrent or parallel operation?
A: If there is no protection mechanism, it will certainly. This type of conflict usually occurs in the competition for resources.
Obviously, if a horse road is narrow enough to pass only one carriage, when two carriages want to pass at the same time,
A rickshaw driver must carry forward his style first. Otherwise, the result is definitely a result.
The operating system carefully manages all of this to avoid conflicts between processes.
Carefully write programs according to certain established rules for operating system management.
More specific methods and principles have far exceeded the acceptable level for beginners. I will skip them.
Right.

Q: What is virtual memory?
A: virtual storage is A very important storage management technology. Its core idea is to use A huge hard disk.
Space to make up for the actual memory space. Under virtual memory management, applications can use
The storage space is much larger than the actual memory size. The memory actually installed on a computer is called
Physical storage, which is much larger than the actual memory space through virtual storage technology
Become a virtual memory. The implementation of the virtual storage technology is also very complicated.
It is thankless. Here we only mention the simplest idea. The memory unit is numbered in the computer.
Memory Address. If your computer has 1 m physical memory (days, 286 said? Haha,
For example, the address range of the physical memory is 0 to 1048575 (1024x1024-1 ).
If you want to access a unit with the address of 1048576, it is obviously not possible, because the maximum is only 1048575
. However, if I save everything in the physical memory to the hard disk
The method maps 1048576 to a physical storage unit with the address 0, and I don't get another whole
M storage space? When the program wants to access the unit with the address 0, I
The content can be transferred back to the physical memory. This idea is clever enough. It is the core of the virtual storage technology.
Mind. So I can get n 1 m space. Real virtual storage management
It is much more complex and clever. It enables different processes to run in different address spaces (that is
Make each process think that it occupies all the storage space and can be used as needed without having to care about
How other processes use buckets. This is like running different processes on different computers)
And consider the optimal memory usage efficiency.

Q: What happens if a process accesses a storage unit that is not in its own address space?
A: In Windows, you will surely see an "The program has performed an illegal operation and is about to be closed ......"
And so on. It is often frustrating to see such a dialog box, but this is required by the operating system.
We call it "storage protection ". The purpose of storage protection is to protect system processes from being used.
User process destruction. process read/write is not allowed in its own region. The truth is very simple: the exam
You are only allowed to answer your questions.
If you modify the content on others' examination papers, you will "Perform Illegal Operations". It must be "disabled" by invigilators"
(The premise is that invigilators work normally, otherwise they will be messed up and have serious consequences ).
Note: In Windows, the system shuts down a process for many reasons, except for illegal read/write operations.
In addition to the process storage area (out-of-address), If you execute ring0 that can only be executed by the operating system
Commands, programs with a divisor of 0, and so on.

Q: What is a hard disk partition?
A: At the earliest stage, the operating system could not manage large hard disk space, so it would take A large hard disk space.
It can be divided into several smaller areas for ease of management. In addition, you sometimes need to install multiple operating systems in the system
System, you also need to divide the hard disk into different areas, so that different operating systems are managed separately, do not interfere with each other.
There is no possibility of partitioning hard disks because the operating system cannot manage large hard disks.
But we still partition the hard disk. In addition to installing multiple operating systems
It is easier to manage various files.
The operating system assigns different drive letters to different hard disk partitions, so that a large hard disk is logically stored.
Divided into multiple small hard disks.

Q: What is the Master Boot Record of a hard disk partition?
A: The Main Boot Record is the lifeblood of each hard disk partition. The hard disk occupied by A partition is null.
Location and other important information. If the primary Boot Record of a partition is destroyed, this partition is used
Finished.

Q: What is an active partition?
A: The active partition is A partition with the ability to bootstrap the system after the system is powered on.
There is a main boot program in the Main Boot Record. Every time the system starts, this program is transferred to the memory
Run to boot the operating system that is saved on the hard disk. Different Operating System guides
The main Bootstrap program varies with the operating system installed on the system.

Q: How does one store Disk Files in Windows?
A: First, Windows uses hard disk space in the unit of "cluster. According to the size of the hard disk space
The cluster size is different. Generally, the smaller the cluster, the larger the utilization rate of the hard disk space, the larger the cluster,
The faster the storage speed. Each file must be divided into multiple blocks in the unit of cluster size and then stored in
Hard Disk. To this end, a table is required to record the clusters on the hard disk where all the blocks in a file are stored.
In Win9x, this table is a FAT table. The FAT table is also stored on the hard disk. Therefore, the FAT table is a file.
The system is destroyed and all files on a disk are used up. Therefore, in addition
A fat table is used to back up a table.

Q: What is a file directory table?
A: The file directory table is equally important as the FAT table. It records the file names, attributes, and
The starting position in the FAT table. When you need to read and write a file, find it from the file directory table in Windows.
If this file is found, follow the instructions in the file directory table to start the file in the FAT table.
Read the storage information related to this file in the FAT table to read and write the file.

Q: What is a virtual device?
A: different I/O devices are fast and slow. In the operating system
A high-speed device is used to simulate a low-speed device.
A typical example in Windows is a printer. We can hardly find that the printer does not
Work, but the hard disk is ringing, and all the printed documents are in the print queue and queued for printing. Before
When a document is still printed on the printer, the next document has entered the print queue. Submit this
The document process can continue to process other tasks without waiting for the printer to print the document.
This is because Windows uses a hard disk to simulate a printer. All the printing work is actually "printed"
Hard Disk. The hard disk speed is much faster than that of the printer, so it was done at once. There is another process.
Reads printed data from the hard disk and prints the data to the actual printer. This process works in the background,
Other processes at the front-end are not affected.

Q: What is device independence )?
A: There are many external devices for computers. The same type of devices have different manufacturers and models. This
Some products are slightly different. This makes it very difficult to write the application, because
Applications cannot take into account the compatibility of all hardware. Therefore, the operating system
The slave database is isolated from the entire system, including specific hardware operations and hardware-related compatibility issues.
The device driver is used to solve the problem. At the same time, the operating system provides unified device control methods to applications,
The application only needs to call the functions provided by the operating system according to the routine.
This is unrelated to the device.
In this way, you only need to install the corresponding driver every time you add or modify the hardware on the system.

Q: What is buffering technology?
A: Buffer technology should be used when data arrives at A location that does not match the departure speed. The buffer technology is like
If a reservoir has too much upstream water and the downstream is too late to be discharged, the reservoir will play a "Buffering" role,
Let the water stop in the reservoir for some time, wait for the downstream to continue drainage, and then send the water to the downstream.
Generally, the speed of the CPU is much faster than that of the I/O device, so you can set the buffer.
CPU data is first placed in the buffer zone, and then the device can slowly read data from the buffer zone.
Operating System Principle

This is a long story. Although I am not a computer professional, I am a computer enthusiast. Let me tell you what I understand:
When it comes to computer operating systems, we certainly think of Microsoft. In fact, it is equivalent to a decoder, which exists on computer hardware. The original system is composed of many original codes. These original codes are composed of binary, and each program is composed of a series of code packages. These codes are packaged in layers to facilitate computer calls. What we see is that some software or files on the computer are also made up of binary. The operating system only analyzes and processes their code to get the desired effect. You can think of it as an Analysis Tool Composed of binary code, which analyzes commands composed of binary code. Then, output the analysis result.
There are many operating systems, and their development history is quite long. We are familiar with XP, window7, and so on. In addition, a very distinctive operating system requires AIX (LINUX) the operating system. It is mainly used in large enterprises, and other operations are quite slow, but the security factor is extremely high. This is why large enterprises choose it.



Operating System Principle

This is a long story. Although I am not a computer professional, I am a computer enthusiast. Let me tell you what I understand:
When it comes to computer operating systems, we certainly think of Microsoft. In fact, it is equivalent to a decoder, which exists on computer hardware. The original system is composed of many original codes. These original codes are composed of binary, and each program is composed of a series of code packages. These codes are packaged in layers to facilitate computer calls. What we see is that some software or files on the computer are also made up of binary. The operating system only analyzes and processes their code to get the desired effect. You can think of it as an Analysis Tool Composed of binary code, which analyzes commands composed of binary code. Then, output the analysis result.
There are many operating systems, and their development history is quite long. We are familiar with XP, window7, and so on. In addition, a very distinctive operating system requires AIX (LINUX) the operating system. It is mainly used in large enterprises, and other operations are quite slow, but the security factor is extremely high. This is why large enterprises choose it.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.