Wenn es sich bei einem Thread nur um einen anderen Prozess handelt, wie reduziert er die Arbeitslast der CPU und behandelt Thrashing?

444
Vimugdh Lall

Was bedeutet es, wenn sie sagen, dass ein Faden ein leichter Prozess ist ? Wenn es sich nur um einen anderen Prozess handelt, wie wird die CPU-Auslastung reduziert?

-1
Arbeitsaufwand der CPU im Vergleich zu was reduzieren? Und warum sollte die Reduzierung der CPU-Arbeitslast ein Ziel sein? Wurden die CPUs nicht * verwendet *? Andrew Henle vor 6 Jahren 0
Ich meinte weniger Arbeitsaufwand, um Thrash zu vermeiden. Durch die Verringerung der Arbeitslast könnte mehr Prozesse verarbeitet werden, sodass die CPU besser "verwendet" wird. Vimugdh Lall vor 6 Jahren 0

1 Antwort auf die Frage

2
LMiller7

A thread is not just another process. Once you understand what processes and thread are your question should be answered.

A process can be compared to a human family and the threads are it's members. The process proves the environment and manages the resources used by the threads. In itself a process can do nothing, everything it does is done by it's member threads. A process is just the home in which the threads live and work. A process cannot exist unless it has at least one thread. When the last thread of a process terminates the OS will destroy the process and free all the resources it was using. There is no such thing as an independent thread. It must be a member of a process.

Typically an application would consist of one process which would itself consist of one or more threads. Large applications sometimes have multiple processes. The OS tries very hard to isolate processes from each other to prevent accidental or malicious interference. The OS gives each process the illusion that it is running alone in the computer. It has to do some real work to even learn of the existence of others. Processes can share resources and work together but the developer must work to accomplish this. It is not the natural state.

Threads are designed to share resources and work together. A process with just one thread is easiest to manage but multiple threads provide greater flexibility and capabilities. Large applications almost always use multiple threads. This requires work on the part of the developer to ensure they work in harmony and not interfere with each other. An example of this would be one thread reading data while another was modifying it. The results of that would be unpredictable.

Threads are lighter weight than processes because they lack the process overhead. This overhead is mostly memory and makes little difference to the CPU except when the process is created and that only happens once. It is usually more efficient to create a new thread in a process than to create an entire new process. But for practical reasons the latter is often necessary.

Ich vermute, ich habe Fäden falsch verstanden. Wie auch immer, danke, dass Sie mir geholfen haben, es besser zu verstehen und den Fehler in meiner Assimilation zu beseitigen. :) Vimugdh Lall vor 6 Jahren 0