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?

  • 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. – Frank Thomas Mar 29 '18 at 15:18
2

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.

| improve this answer | |
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!

| improve this answer | |
  • 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? – FunctionBlock Mar 29 '18 at 14:05
  • This is so called "context switch" and is managed by OS, take a look: en.wikipedia.org/wiki/Context_switch – Leo Chapiro Mar 29 '18 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). – Frank Thomas Mar 29 '18 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.