182 votes

Does it ever make sense to use more concurrent processes than processor cores?

The canonical time when you use far, far more processes than cores is when your processes aren't CPU bound. If your processes are I/O bound (either disk or more likely network), then you can ...
Philip Kendall's user avatar
95 votes
Accepted

How does a single thread run on multiple cores?

The operating system offers time slices of CPU to threads that are eligible to run. If there is only one core, then the operating system schedules the most eligible thread to run on that core for a ...
Erik Eidt's user avatar
  • 33.8k
62 votes
Accepted

In software programming, would it be possible to have both CPU and GPU loads at 100%?

Theoretically yes, but practically it's rarely worth it. Both CPUs and GPUs are turing-complete, so any algorithm which can be calculated by one can also be calculated by the other. The question is ...
Philipp's user avatar
  • 23.3k
59 votes

Does it ever make sense to use more concurrent processes than processor cores?

Short answer: Yes. Longer answer: Set your magic number stupid high, benchmark it, set it low, benchmark it again, and keep doing that until you have your answer. The number of moving parts here is ...
Iron Gremlin's user avatar
  • 1,115
41 votes

Why is multithreading not used everywhere?

Why multithreading isn't everywhere? Because … I understand that multi-threading is hard to implement and has drawbacks if number of threads is less than expected.
Jörg W Mittag's user avatar
36 votes

In software programming, would it be possible to have both CPU and GPU loads at 100%?

It is not related to game programming. Some scientific code can also use both the GPU and the CPU. With careful -and painful- programming, e.g. by using OpenCL or CUDA, you could load both your GPU ...
Basile Starynkevitch's user avatar
29 votes

How does a single thread run on multiple cores?

There is no such thing as a single thread running on multiple cores simultaneously. It doesn't mean, however, that instructions from one thread cannot be executed in parallel. There are mechanisms ...
Frax's user avatar
  • 1,844
29 votes

How does a single thread run on multiple cores?

summary: Finding and exploiting the (instruction-level) parallelism in a single-threaded program is done purely in hardware, by the CPU core it's running on. And only over a window of a couple ...
Peter Cordes's user avatar
29 votes
Accepted

Why is multithreading not used everywhere?

The proliferation of multi-core CPUs is predominantly driven by supply, not by demand. You're right that many programmers don't bother decomposing their systems so that they can profit from multiple ...
Kilian Foth's user avatar
26 votes

Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?

As you may have noticed, there's a category of application that tries really hard to avoid input lag and only occasionally fails at doing so: games. Even then it's not uncommon for players to notice ...
pjc50's user avatar
  • 13.4k
25 votes

Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?

I would like to answer this question from more of a high-level, marketing perspective than a more low-level, technical one. All of the current mainstream Operating Systems are so-called general ...
Jörg W Mittag's user avatar
23 votes

Why is multithreading not used everywhere?

Why multithreading isn't everywhere? Frame challenge: but it is everywhere. Let's see, let's name some platforms: Desktops/laptops: one of the most common applications today is the browser. And to ...
Vilx-'s user avatar
  • 5,320
20 votes
Accepted

How does sleeping a thread work?

There is much more involved in running a program than just the code within that program. Any program that runs in a multi-process OS is under the control of the OS's scheduler, and the scheduler does ...
Kilian Foth's user avatar
20 votes

Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?

Why can't (or why don't) operating systems absolutely prioritise user input (and repainting thereof) in threading and process scheduling? Even if the operating system tells the application about the ...
Caleth's user avatar
  • 10.9k
19 votes
Accepted

Why do compilers typically only generate executables for the platform they are installed on?

what makes it difficult for say the visual C++ compiler on windows to generate a linux binary executable file? Other than an unwillingness to do that on Microsoft's part, absolutely nothing. The ...
Blrfl's user avatar
  • 20.4k
18 votes

How does sleeping a thread work?

As Doc Brown mentioned in a comment, interrupts are the key, and not just for sleeping. An interrupt is a hardware signal that the processor should stop what it's doing and run a piece of code. ...
kdgregory's user avatar
  • 5,250
13 votes
Accepted

Why can less precise data like float be faster than larger, more precise data like double?

For intuitively the same reason why it's faster to calculate 2 + 2 by hand than it is to calculate 3685 + 2193: there's simply less data to work your way through.
Mason Wheeler's user avatar
12 votes
Accepted

Is it possible to update exactly 1 byte in RAM?

The internet. When you have multiple computers networked together there is no such thing as "the word size". Every computer has its own idea how big it's bus is. But they all agree on bytes (even if ...
candied_orange's user avatar
12 votes

Does it ever make sense to use more concurrent processes than processor cores?

In A.I. it is common for people to observe super-linear speedups when they write parallel algorithms (that is, > K times speedup with K processes running on K cores). This is because you are often ...
Chris Jefferson's user avatar
11 votes

In software programming, would it be possible to have both CPU and GPU loads at 100%?

From a supercomputing viewpoint it is better not to think in CPU/GPU load in percentage but rather determine how many operations your problem at hand needs and then compare that to the peak ...
Martin Ueding's user avatar
11 votes
Accepted

The difference between accumulator-based and register-based CPU architecture?

A register-based CPU architecture has one or more general purpose registers (where "general purpose register" excludes special purpose registers, like stack pointer and instruction pointer). An ...
Brendan's user avatar
  • 3,925
11 votes
Accepted

What happens to multiple parallel tasks running on a server when CPU hits 100% usage?

My question is if the CPU hits 100% usage, are the 10 instances still being parallel processed? Yes. Or Does the CPU start sequencing them instead of parallel processing them? Your processor ...
Erik Eidt's user avatar
  • 33.8k
11 votes
Accepted

How is it possible for a process to use less than 100% CPU?

The % usage you see, for example, in the Windows task manager, is an average value over a certain time period. And indeed, processing on a one-CPU machine works basically the way you already sketched ...
Doc Brown's user avatar
  • 207k
11 votes

Why can't we vertically scale a system infinitely?

Vertical Scaling does have limitations. Those limitations are called Physics, and Engineering. Turns out that Physics doesn't like performing to much work in a single place, and our current ...
Kain0_0's user avatar
  • 16.2k
11 votes

Why is multithreading not used everywhere?

I want to emphasize a point you made that multithreading is hard to implement. Some problems are naturally broken into independent parts that are easily parallelizable ("embarrassingly parallel&...
qwr's user avatar
  • 343
11 votes

Does it ever make sense to use more concurrent processes than processor cores?

You can take the example of compiled Linux distributions (like Gentoo): to optimize the compilation time, it is obviously using parallel compilation using more processes than the number of available &...
Philippe Verdy's user avatar
11 votes

Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?

In my experience, on most computers I have ever used, this is usually caused by inappropriate swapping to disk. Every other cause (such as operating system locks) is significantly less common. When ...
user253751's user avatar
  • 4,873
10 votes

How does a CPU load multiple bytes at once if memory is byte addressed?

Because the width of the data bus and the size of the smallest addressable unit are two separate things. Just because you can specify addresses at the byte level, does not mean you have to have an 8 ...
8bittree's user avatar
  • 5,656
9 votes

How does an OS limit a program capabilities, if it's working directly with the cpu?

Modern CPUs have privilege modes that are used by the operating system lock out certain instructions.  For example in user mode the instructions that modify (raise) the privilege mode or access system ...
Erik Eidt's user avatar
  • 33.8k
8 votes

Byte addressable vs bit addressable

The reason why the hardware isn't bit addressable is the cost and complexity to address to that level of granularity isn't justified. You need more wires the more accurately you address. A lot of ...
Alex's user avatar
  • 3,922

Only top scored, non community-wiki answers of a minimum length are eligible