Process and thread

zhaozj2021-02-16  58

Process: Products of multi-tasking systems

I haven't had a process for a long time. At that time, the operating system can only put the work you have to do, do this, then do the next one, and add a priority, which relationship is good. Which one is So those programmers who think about listening to songs while writing procedures, start repairing that operating system, making it more running multiple programs. So the process will appear: it is an execution in a program on the data collection.

Because suddenly become more porridge, there is only some extra things to do every process: Pack your things before using it, and then put it out next time. In order to save these additional things, the structure of the process has also changed. A process is divided into three parts: code segments, data segments, and PCBs (process control blocks).

In more PCBs, we saved the following information:

l Process identifier (operating system is used to identify the unique identity of the process)

l Processor status (mainly universal registers, instruction registers, PSW, and user stack pointers)

l Process scheduling information (status, priority, blocked reasons and other messy things)

l Process Control Information (Synchronization Information, Code Segment and Data Section Information, Resource List and Pointer to the Next PCB)

The operating system is managing these multiple processes through the PCB. In such a system, the process is both an independent unit of operating system independent scheduling and dispatch, and is an independent unit that can have resources.

Thread: The process of the process

Ok, now the programmer can usually listen to the song and write the program. But unfortunate or is lucky, the new problem appeared. If you use a lot of the same data between multiple processes, it is too wasteful. Of course we can't allow such things to continue, so the thread appears. Under the same process, you can have multiple threads, and they share the resources of this process, and the switching between them no longer requires the PCB, but only a little resource is required. In such an operating system, the thread becomes the basic unit of system scheduling and dispatch.

Simply put the process and threads are different:

l Process can have resources, thread sharing processes have resources

l Switch between processes must save the PCB, switch between multiple threads of the same process, do not have to be so troublesome

Finally, we come as an example of this article:

When you open two QQ on a PC, every QQ is a process; and when you chat with multiple people on a QQ, every chat window is a thread.

转载请注明原文地址:https://www.9cbs.com/read-25657.html

New Post(0)