Smp support, Name, Description – Comtrol eCos User Manual

Page 35: System startup, Scheduling

Advertising
background image

SMP Support

Name

SMP

— Support Symmetric Multiprocessing Systems

Description

eCos contains support for limited Symmetric Multi-Processing (SMP). This is only available on selected architec-
tures and platforms. The implementation has a number of restrictions on the kind of hardware supported. These are
described in

the Section called SMP Support in Chapter 9

.

The following sections describe the changes that have been made to the eCos kernel to support SMP operation.

System Startup

The system startup sequence needs to be somewhat different on an SMP system, although this is largely transparent
to application code. The main startup takes place on only one CPU, called the primary CPU. All other CPUs, the
secondary CPUs, are either placed in suspended state at reset, or are captured by the HAL and put into a spin as
they start up. The primary CPU is responsible for copying the DATA segment and zeroing the BSS (if required),
calling HAL variant and platform initialization routines and invoking constructors. It then calls

cyg_start

to enter

the application. The application may then create extra threads and other objects.

It is only when the application calls

cyg_scheduler_start

that the secondary CPUs are initialized. This routine

scans the list of available secondary CPUs and invokes

HAL_SMP_CPU_START

to start each CPU. Finally it calls an

internal function

Cyg_Scheduler::start_cpu

to enter the scheduler for the primary CPU.

Each secondary CPU starts in the HAL, where it completes any per-CPU initialization before calling into the kernel
at

cyg_kernel_cpu_startup

. Here it claims the scheduler lock and calls

Cyg_Scheduler::start_cpu

.

Cyg_Scheduler::start_cpu

is common to both the primary and secondary CPUs. The first thing this code does

is to install an interrupt object for this CPU’s inter-CPU interrupt. From this point on the code is the same as for
the single CPU case: an initial thread is chosen and entered.

From this point on the CPUs are all equal, eCos makes no further distinction between the primary and secondary
CPUs. However, the hardware may still distinguish between them as far as interrupt delivery is concerned.

Scheduling

To function correctly an operating system kernel must protect its vital data structures, such as the run queues,
from concurrent access. In a single CPU system the only concurrent activities to worry about are asynchronous
interrupts. The kernel can easily guard its data structures against these by disabling interrupts. However, in a multi-
CPU system, this is inadequate since it does not block access by other CPUs.

The eCos kernel protects its vital data structures using the scheduler lock. In single CPU systems this is a simple
counter that is atomically incremented to acquire the lock and decremented to release it. If the lock is decremented
to zero then the scheduler may be invoked to choose a different thread to run. Because interrupts may continue to
be serviced while the scheduler lock is claimed, ISRs are not allowed to access kernel data structures, or call kernel

35

Advertising