1

The other day I was thinking about how the scheduler works in multi-threaded environments and how the load is distributed among the processor cores. I read about the green threads in JVM that the implementation of multithreading may not depend on the OS kernel. The threads on the same processor are more related to context switching, which creates the illusion of parallelism. Are threads an abstraction for concurrency?

The question is, how is the load distributed in multi-core processors? Does the processor itself do this automatically or programmatically (OS kernel, virtual machine)? who decides on which core the instructions of the current context will be executed?

In windows 10 task manager you can set which cores are allowed for a task. How it work

Where can I read about it

AntLet
  • 11
  • 2
  • 1
    Modern systems don't use green threads, at least not exclusively. Most modern systems use one OS-scheduled task per user thread. Or an N:M thread model with some user threads sharing an OS task, but enough OS tasks to get scheduled on all the cores if you create enough user threads. As for scheduling tasks to cores, on each core separately, the kernel's scheduler code will grab a task from the available set of tasks waiting to run. It's a distributed algorithm. You can override the thread affinity to only allow some cores to run that task. – Peter Cordes May 24 '23 at 16:51
  • Also near duplicates: [How are multiple CPU cores used by the OS](https://stackoverflow.com/q/26760361) and [How Linux scheduler schedules processes on multi-core processors?](https://stackoverflow.com/q/20143143) and [How does one core get work in a multi-core system?](https://stackoverflow.com/q/62135601) . Scheduling tasks is done in software. – Peter Cordes May 24 '23 at 16:57

0 Answers0