Execute the command stops when os is idle
What is an idle CPU process doing?
Looking at the source of I found the use of the clone flag, which is described there as:
On closer inspection, I found that, while the kernel doesn't handle this flag, it actually uses it during startup to create inactive processes (which should all have PID 0) for each CPU on the computer. ie a machine with 8 CPUs has at least 7 (see question below) such processes "running" (pay attention to the quotation marks).
Now that leads me to a couple of questions about what this "idle" process actually does. I'm assuming the NOP operation will run continuously until the time frame expires and the kernel assigns a real process to run or reassign the idle process (when the CPU is not in use). However, that's a complete guess. In order to:
Are such idle processes generated on a machine with, for example, 8 CPUs 7? (and a CPU is held by the kernel itself while no userspace work is done?)
Is the idle process really just an infinite stream of NOP operations? (or a loop that does the same).
Is CPU usage simply calculated from how long the idle process has been on the CPU and how long it has been absent for a given period of time?
PS Chances are a lot of this question stems from the fact that I don't fully understand how a CPU works. That is, I understand the assembly, the timeframes and the interrupts, but I don't know how a CPU, for example, uses more or less power depending on how it is executed. I would be grateful if someone could enlighten me too.
The idle task is used for process billing and to reduce energy consumption. Under Linux, an inactive task is created for each processor and bound to this processor. If no other process can run on this CPU, the inactive task is scheduled. The time spent on inactive tasks is recorded in tools such as (The operating time is calculated differently.)
Unix always seems to have had an idle loop (but not necessarily an idle task itself, see Gilles' answer), and even in V1 it used an instruction that halted the processor until an interrupt occurred (it stood for "wait for") "). Some other operating systems used busy loops, DOS, OS / 2, and earlier versions of Windows in particular. CPUs have been using this type of" wait "statement for some time to reduce their energy consumption and heat generation. They can have several implementations of idle tasks, for example in the Linux kernel: the basic one just calls The other implementations handle various bugs or inefficiencies ( z. B. on some CPUs instead of).
All of this is completely independent of idle states in processes when they are waiting for an event (I / O, etc.).
If there is no process to be planned in a process planner's textbook design (that is, if all processes are blocked and waiting for input), the planner waits for a processor interruption. The interrupt can indicate input from a peripheral (user action, network packet, read from disk completed, etc.) or it can be a timer interrupt that sets a timer in a process.
The Linux scheduler has no special code for when there is nothing to be done. Instead, it encrypts the undone case as a special process, the idle process. The idle process is only scheduled if no other process can be scheduled (it actually has an infinitely low priority). The inactive process is in fact part of the kernel: it is a kernel thread, which is a thread that executes code in the kernel rather than code in a process. (More specifically, there is such a thread for each CPU.) When the idle process is running, it performs the wait-for-interrupt operation.
How the interruption wait works depends on the capabilities of the processor. The most basic processor design is just a busy loop.
The processor will forever execute a branch instruction that does nothing. Most modern operating systems only do this when they're running on a processor that doesn't have anything better on them, and most processors have something better. Ideally, the processor should be turned off rather than just using energy to heat the room. So the kernel is executing code that tells the processor to shut down itself, or at least most of the processor. At least one small part must remain switched on, the interrupt controller. When a peripheral device triggers an interrupt, the interrupt controller sends a wake-up signal to the main processor (part of it).
In practice, modern CPUs like Intel / AMD and ARM have many complex settings for power management. The operating system can estimate how long the processor will remain in idle mode and select different energy-saving modes based on this. The modes offer different tradeoffs between idle power consumption and the time it takes to enter and exit idle mode. On some processors, the operating system can also slow the processor clock speed if it determines that processes are not consuming much CPU time.
No, an inactive task does not waste CPU cycles. The scheduler simply does not select an inactive process to run. An idle process is waiting for an event to occur so that it can continue. For example, it can wait for input in a system call.
The kernel is not a separate process, by the way. Kernel code is always executed in the context of a process (well, with the exception of the special case of a kernel thread), so it is incorrect to say that "and a CPU is held by the kernel itself while no userspace work is done" .
- What does a brassy cough sound like?
- Colored raine whatever swatch sistem
- Tudor Trust Liquidators Wholesale
- Yasmine Nemazee Doctor, the Wiki
- How to complete a Tok presentation plan
- Aunt Martha's flour sack, towels wholesale
- What is agricultural architecture
- How to auto number in Word 2010
- Marit larsen when the morning comes zip
- Who is jesse t graham 9999 years
- When was Gugger Petter born this way
- When does Skyrush open in Hershey Park
- How to talk to your friend about exercise
- How to say namaste in Rajasthani language
- What is a shapeshifter weakness
- Who Owns Broetchen Royce rrr17
- Gniazdka elektryczne chowane w blacie kuchennym
- In variety of diaboli descargar whatsapp
- Actress who played diane sterling ncis
- Change the world's best cat litter how often
- Telugu are called teachers who slept with students
- How to dab without a rig
- What do you want a medal meme
- How to Play Faithful Nashville Chords
- What does traces of pelvic fluid mean?
- What happened to Blueberry Buckle Baby Food
- What happened to the tvfreeload forum
- Top 50 female athletes who are bitches
- When does Skyrush open in Hershey Park
- What happened to Faye Chrisley's roommate
- Suzuki dogezaemon the princess who loved insects
- Instructions for Tying the Ratchet Strap Clamp
- Who owns Woroco petrol stations