Linux process (von Neumann architecture, operating system, process)


1. Von Neumann architecture:

1. Basic concepts:

Most of our common computer equipment follows the von Neumann architecture.
Please add image description

  • Storage: Memory Input device: disk, network card, keyboard, microphone, camera...
  • Output device: disk, network card, monitor, audio...
  • Central processor : CPU
  • Operator: arithmetic operations, logical operations
  • Controller: The CPU responds to external events and coordinates external readiness events, such as copying data to memory.

2. Why is it designed like this:

2.1.Optimization of running speed:

CPU&&Register> Memory> Disk> Optical Disc> Tape
According to the barrel principle, how much water a bucket can hold depends on its shortest piece board.
Insert image description here
If the CPU and disk are directly allowed to interact, the running speeds of the two are too different.
The addition of memory creates a gap between memory and CPU, memory and peripherals. The running speed is reduced by orders of magnitude, and through software optimization, data can be loaded into the memory in advance, greatly improving the running speed.

2.2. Cost:

If all disks are replaced with memory, the operating efficiency will be greatly improved, but the cost will undoubtedly be very high, and magnetic devices such as disks can still store data after power is turned off, which cannot be done by memory, so the von Neumann architecture The design also reduces costs while improving efficiency.

3. Summary:

  1. When the CPU reads data (data + code), it reads it from the memory, and then writes it to the memory after processing.
  2. To process data, the CPU must first load the data from the peripherals into the memory. The CPU only deals with the memory.

2. Operating system:

1. Basic concepts:

The operating system is software that manages software and hardware resources.

  • Kernel (process management, memory management, file management, driver management)
  • Other programs (such as function libraries, shell programs, etc.)

Insert image description here

2. The role of the operating system:

  1. Right: Reduce usage costs for users and provide users with a good usage environment.
  2. Next: Interact with hardware->Manage software and hardware resources. Ensure a stable environment for the system.

3. What is management:

In the entire computer software and hardware architecture, the operating system is positioned as: a pure "management" software. How is the operating system managed?

In real life, managers and the managed do not necessarily interact directly:
For example: the principal manages students through counselors and head teachers.
Insert image description here
Managers obtain the information of the managed through executors, and then make management decisions by "describing first, then organizing". That is, the organization is described through a series of data structures.

For example: write an algorithm for ranking students' grades:
The objects can be organized into arrays of structures: in this way, the management of students becomes the addition, deletion, checking and modification of the array.

3. Process:

When we start a software, we actually start a process.
Under Linux, when ./xxx is run, a process is actually created at the system level.

1. Basic concepts:

  • A running program is called a process.
  • Linux can have a large number of processes in the system at the same time.
  • Does the Linux operating system need to manage these processes? must!
  • How does manage these processes? The answer is: describe first and then organize

2. Process management:

People understand various things through their “attributes”.
By "describing first and then organizing", process = corresponding code and data + PCB structure corresponding to the process !

struct PCB
{
    
    
	//进程所有的属性数据
	struct PCB *next;
	struct PCB *prev;
}

Insert image description here

3.PCB—Process Description:

  • Process information is placed in a data structure called a process control block, which can be understood as a collection of process attributes.
  • It is called PCB (process control block) in the textbook. The PCB under the Linux operating system is: task_struct.

task_ struct content classification:

  • Identifier: A unique identifier that describes this process and is used to distinguish other processes.
  • Status: Task status, exit code, exit signal, etc.
  • Priority: Priority relative to other processes.
  • Program Counter: The address of the next instruction to be executed in the program.
  • Memory pointers: including pointers to program code and process-related data, as well as pointers to memory blocks shared with other processes
  • Context data: The data in the processor's registers when the process is executed [example of leave of absence, please add the figure of CPU, registers].
  • I/O status information: includes displayed I/O requests, I/O devices assigned to the process and a list of files used by the process.
  • Accounting information: may include total processor time, total number of clocks used, time limits, accounting accounts, etc.
  • other information

Summarize

The above is the content related to Linux processes that I talked about today, including the basic concepts of von Neumann architecture, operating systems, and processes. I hope it will be helpful to you who have just read this blog!

Guess you like

Origin blog.csdn.net/weixin_61661271/article/details/127154386