June 22, 2018

Kyu multicore support

The H3 chip on the Orange Pi has 4 cores, and it is now possible to use them with Kyu. Multicore support is not yet integrated with the thread scheduling system, so don't attempt to launch threads, use semaphores, or time delays. This is a work in progress.

The board comes up with only core 0 active. The other cores are left powered off until needed to conserve power and reduce heat generation. To start up a core, do this:

    new_core ( core, func, arg );
Here "core" is an integer, 1, 2, or 3 indicating which core to start up. The argument "func" is a function pointer to the code that should be run. It will be called as:
    func ( int core, void *arg );

Spin locks

It seems that the ARM exclusive monitor facility does not work with the memory system on the H3 chip, but the H3 provides special spin lock hardware with 32 locks.
    h3_spin_lock ( lock );
    h3_spin_unlock ( lock );
Where "lock" is an integer from 0 - 31.

Interrupts

It is possible for one core to generate an interrupt that is received by another core. This uses the SGI (software generated interrupt) facility of the ARM GIC. An interrupt is generated by:
    gic_soft ( sgi, core );
Where "sgi" is the software interrupt number (0-15) and "core" is the target core (0-3). As usual under Kyu, the receiver sets up a callback function to handle the interrupt via:
    irq_hookup ( IRQ_SGI_2, handler, void *arg );
Here "IRQ_SGI" is the IRQ number of the SGI (by coincidence identical to the SGI number since the first 16 IRQ are assigned to SGI).


Have any comments? Questions? Drop me a line!

Kyu / tom@mmto.org