Saturday, May 16, 2009

SMP preemption -> UP preemption

Sometimes, a SMP environment can turn into a UP environment via per-CPU data structure. Such as unified trace ring buffer is a per-CPU data structure, so the mutual exclusion can be considered in UP model for each per-CPU buffer.

Preemption in UP

There are 3 kinds of contexts in UP environment.

  1. Process context
  2. IRQ context
  3. NMI context

Where 1 can be preempted by 1, 2 or 3; 2 can be preempted by 2 or 3; 3 can not be preempted.

If preempt is off in 1, 1 can only be preempted by 2 or 3. And there is no interleave between contexts, that is, if 1 is preempted by 2, 1 will not be resumed until 2 is finished, so do 2 and 3. This can be used to develop more efficient synchronization algorithm.

If IRQ is off in 1 and 2, 1 and 2 can only be preempted by 3, without interleave.

No comments: