5

Will a process switch between different cores to increase performance? If the process does jump between cores, which components are shared across cores? L1-L3 cache, registers or memory?

1
  • Note that a Process is just a memory structure. One or more threads are bootstraped during process creation, and they execute using the processes memory structure as a resource, but a process doesn't execute; the threads associated with it do. Mar 29, 2018 at 15:18

3 Answers 3

3

Let's imagine a busy single CPU with 2 cores system, where the load is nearing 100%.

A process with PID 1234 has only one thread (e.g. console application doing monothread audio compression).

For this kind of process, the system will try its best to run the thread on the same core, to minimize cache faults. However, if the system is really busy, similar other processes may also try to run on the same cores. In this case, in principle, your single thread process may run first on core #1, then on core #2, and so on and so forth.

1
  • Is there a technical source for this? Or is it just a guess?
    – coolaj86
    Dec 2, 2022 at 0:00
1

Will Process switch between different cores to increase the performance?

This depends on whether the process is a multi-threading process or not. The process itself is basically just a "container" for threads, it needs to have at least one to run. Each thread can use a core of CPU, so if your process has 2 threads (a GUI- and a working thread), it will run on 2 cores of CPU.

The question "will Process switch between different cores" is not exactly correct because such switching is scheduled by operating system (OS), NOT by process itself!

3
  • Thanks duDE. If OS schedule process A to continue Core B when Core A is busy, how can OS (Linux) make sure all variables, state, and operation is transfer across and how? Mar 29, 2018 at 14:05
  • This is so called "context switch" and is managed by OS, take a look: en.wikipedia.org/wiki/Context_switch Mar 29, 2018 at 14:07
  • Note that context switches are requested by the OS when desired, but are performed completely in the CPU hardware, at the CPUs discretion (look up interrupt handling for example). Mar 29, 2018 at 15:16
1

Process switch between CPUs will hurt performance, because the switch will mean storing the process information and registers in memory, then loading it on the other CPU.

These store and load commands are among the slowest commands on the CPU, although they will not be noticed if executed very infrequently.

This process is exactly the same as when a process terminates its time slice and is suspended by the operating system, then restarted with a new time slice.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .