Questions tagged [cpu]

The central processing unit or "processor" inside a computer which executes the instructions in a computer program.

The central processing unit (CPU) is the portion of a computer system that carries out the instructions of a computer program, and is the primary element carrying out the computer's functions. The central processing unit carries out each instruction of the program in sequence, to perform the basic arithmetical, logical, and input/output operations of the system. This term has been in use in the computer industry at least since the early 1960s. The form, design and implementation of CPUs have changed dramatically since the earliest examples, but their fundamental operation remains much the same.

Source: Wikipedia

4662 questions
105
votes
4 answers

User CPU time vs System CPU time?

Could you explain more about "user CPU time" and "system CPU time"? I have read a lot, but I couldn't understand it well.
user472221
  • 3,014
  • 11
  • 35
  • 42
97
votes
2 answers

What does "rep; nop;" mean in x86 assembly? Is it the same as the "pause" instruction?

What does rep; nop mean? Is it the same as pause instruction? Is it the same as rep nop (without the semi-colon)? What's the difference to the simple nop instruction? Does it behave differently on AMD and Intel processors? (bonus) Where is the…
Denilson Sá Maia
  • 47,466
  • 33
  • 109
  • 111
96
votes
8 answers

How is CPU usage calculated?

On my desktop, I have a little widget that tells me my current CPU usage. It also shows the usage for each of my two cores. I always wondered, how does the CPU calculate how much of its processing power is being used? Also, if the CPU is hung up…
Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
95
votes
8 answers

Linux Process States

In Linux, what happens to the state of a process when it needs to read blocks from a disk? Is it blocked? If so, how is another process chosen to execute?
Blair
  • 3,671
  • 4
  • 29
  • 40
85
votes
6 answers

Is setInterval CPU intensive?

I read somewhere that setInterval is CPU intensive. I created a script that uses setInterval and monitored the CPU usage but didn't notice a change. I want to know if there is something I missed. What the code does is check for changes to the hash…
Ryuku
  • 853
  • 1
  • 6
  • 5
85
votes
9 answers

Which is faster: x<<1 or x<<10?

I don't want to optimize anything, I swear, I just want to ask this question out of curiosity. I know that on most hardware there's an assembly command of bit-shift (e.g. shl, shr), which is a single command. But does it matter (nanosecond-wise, or…
Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434
82
votes
6 answers

Accurate calculation of CPU usage given in percentage in Linux?

It's a question which has been asked many times, however there is no well supported answer I could find. Many people suggest the use of top command, but if you run top once (because you have a script for example collecting Cpu usage every 1 second)…
Vangelis Tasoulas
  • 3,109
  • 3
  • 23
  • 36
81
votes
2 answers

What happened to clockless computer chips?

Several years ago, the 'next big thing' was clockless computers. The idea behind it was that without a clock, the processors would run significantly faster. That was then, this is now and I can't find any info on how it's been coming along or if…
GeoffreyF67
  • 11,061
  • 11
  • 46
  • 56
81
votes
5 answers

What is a cache hit and a cache miss? Why would context-switching cause cache miss?

From the 11th Chapter(Performance and Scalability) and the section named Context Switching of the JCIP book: When a new thread is switched in, the data it needs is unlikely to be in the local processor cache, so a context-switch causes a flurry…
Geek
  • 26,489
  • 43
  • 149
  • 227
78
votes
2 answers

Why are GPUs more powerful than CPUs

How are GPUs more faster then CPUs? I've read articles that talk about how GPU's are much faster in breaking passwords than CPUs. If thats the case then why can't CPUs be designed in the same way as GPUs to be even in speed?
Faisal Abid
  • 8,900
  • 14
  • 59
  • 91
77
votes
9 answers

How to get the number of CPUs in Linux using C?

Is there an API to get the number of CPUs available in Linux? I mean, without using /proc/cpuinfo or any other sys-node file... I've found this implementation using sched.h: int GetCPUCount() { cpu_set_t cs; CPU_ZERO(&cs); sched_getaffinity(0,…
Treviño
  • 2,999
  • 3
  • 28
  • 23
76
votes
1 answer

When are x86 LFENCE, SFENCE and MFENCE instructions required?

Ok, I have been reading the following Qs from SO regarding x86 CPU fences (LFENCE, SFENCE and MFENCE): Does it make any sense instruction LFENCE in processors x86/x86_64? What is the impact SFENCE and LFENCE to caches of neighboring cores? Is the…
user997112
  • 29,025
  • 43
  • 182
  • 361
73
votes
12 answers

Which Java thread is hogging the CPU?

Let's say your Java program is taking 100% CPU. It has 50 threads. You need to find which thread is guilty. I have not found a tool that can help. Currently I use the following very time consuming routine: Run jstack , where pid is the process…
Gene Vayngrib
  • 833
  • 1
  • 8
  • 8
73
votes
5 answers

Whole one core dedicated to single process

Is there any way in Linux to assign one CPU core to a particular given process and there should not be any other processes or interrupt handlers to be scheduled on this core? I have read about process affinity in Linux Binding Processes to CPUs…
akp
  • 1,753
  • 3
  • 18
  • 26
70
votes
1 answer

VisualVM and Self Time

I've been searching all over for a consistent and clear explanation of what 'self time' actually refers to in the VisualVM context and how does it differ to 'self time (cpu)'. Also does 'self time [%]' refer to self time or self time cpu. There…
AndyF
  • 1,074
  • 1
  • 12
  • 19