As I understand it, everything is moving towards "many small but weak nuclei". Do I understand correctly that each kernel can have its own execution context?

How long does a context switch take? In the sense that if the processor (let's take ARM) 8 cores for interest, can we say that it will be able to perform more tasks at the same time (for example, maintenance of network connections) than a more powerful dual core i5?

After all, in theory, on a dual-core i5, with an increase in the number of tasks, will the time increase to switch between tasks, and on the 8-core ARM, can this be spent 4 times less time?

Is there some kind of numeric comparison for time-consuming context switches? In terms of planning the optimal number of threads.

In what cases the model of asynchronous processing using fayber (light streams) will be neither effective? When there will be many cores or when the tasks will be "heavy". Then I do not understand the term "difficult task". After all, in theory, for each stream, all the same, only a certain time quantum is given; the flow really needed to be perechelkivaniya. Those. roughly speaking, the scheduler gave the flow 10 milliseconds, but it worked for 1. And the rest of the time it will be idle.

Am I thinking correctly?

  • 2
    Take a specific processor and find a technical description on it. Processor developers in the documentation indicate how many clock cycles this or that operation is performed, including context switching. Usually, it is about hundreds of clock cycles when switching, while most of the normal operations occur in 1 clock cycle. And the scheduler gives for example up to 10 ms, if the stream took less time, more will get to others. And do not think that context switching occurs only when the process / scheduler is wanted. There are also hardware interrupts in which the context switches to love - Mike
  • And what do hundreds of bars take? And there it is correct to speak about cycles or about milliseconds? How do the faybers (which are in D and Go)? Do they cause a context switch? - Dmitry Bubnenkov
  • one
    I didn’t see what a fayber is, the question is who controls them, if the OS is used, then the context switch will be loved because the level of privileges when accessing the memory is different. Because of this, actually a lot of time. It is necessary to preserve the state of all registers in the current stack, load segment registers, with checking the effective rights. In ms it is hardly appropriate to count. ms = 1 / 1000s, clock frequency 1 GHz = 1 billion clocks per second - Mike
  • And modern cores change the real clock frequency on the move, the same operations can be performed at different times, so you need to read in cycles - Mike

1 answer 1

Full cores have their own execution context - their IP (instrustion pointer), set of registers and set of ALUs. Many processors also have their own unshared cache. HyperTreading cores have only their own IP and set of registers. This means that if a process uses a lot of arithmetic and / or intensively works with memory and uses a lot of cache memory, then two such processes on neighboring HT-cores will actively interfere with each other and may in the worst case work together slower than one.

But how things will be in a particular case - it depends strongly on the process, of course.