Tarefas em segundo plano na máquina Multicore?

0

Digamos que eu tenha uma CPU dual core executando linux.

Se eu iniciar dois processos de thread único (nodejs) em segundo plano, como eles estão agendados?

Posso supor que o sistema operacional funcionará da melhor maneira possível, tentar fazer com que cada processo seja executado em diferentes núcleos, ou eu fiz algo diferente?

    
por Alan 24.05.2013 / 09:08

1 resposta

1

Sim, ele agendará o trabalho nos núcleos sem nenhuma configuração extra sua.

A partir deste excelente aritculo no Linux SMP em ibm.com (minha ênfase):

In the early days of Linux 2.0, SMP support consisted of a "big lock" that serialized access across the system. Advances for support of SMP slowly migrated in, but it wasn't until the 2.6 kernel that the power of SMP was finally revealed.

The 2.6 kernel introduced the new O(1) scheduler that included better support for SMP systems. The key was the ability to load balance work across the available CPUs while maintaining some affinity for cache efficiency. For cache efficiency, recall from Figure 4 that when a task is associated with a single CPU, moving it to another CPU requires the cache to be flushed for the task. This increases the latency of the task's memory access until its data is in the cache of the new CPU.

The 2.6 kernel maintains a pair of runqueues for each processor (the expired and active runqueues). Each runqueue supports 140 priorities, with the top 100 used for real-time tasks, and the bottom 40 for user tasks. Tasks are given time slices for execution, and when they use their allocation of time slice, they're moved from the active runqueue to the expired runqueue. This provides fair access for all tasks to the CPU (and locking only on a per CPU basis).

With a task queue per CPU, work can be balanced given the measured load of all CPUs in the system. Every 200 milliseconds, the scheduler performs load balancing to redistribute the task loading to maintain a balance across the processor complex. For more information on the Linux 2.6 scheduler, see the Resources section.

    
por 24.05.2013 / 09:25