Hacker News new | ask | show | jobs
by andy_threos_io 932 days ago
My view that, this code is nice, however IMO there are several ways to make it more portable, and programer friendly, specially the ported assembly code part.

Example.

In file threadx-master/ports/cortex_a7/gnu/src/tx_thread_schedule.S

in this code

    /* Increment the run count for this thread.  */

    LDR     r2, [r0, #4]                    // Pickup run counter
    LDR     r3, [r0, #24]                   // Pickup time-slice for this thread
    ADD     r2, r2, #1                      // Increment thread run-counter
    STR     r2, [r0, #4]                    // Store the new run counter
the indexes to the data structures are really hard to modify, so you can't make modifications to the structures easy, the C structures and the assembly code indexes must be in sync, or the system will crash. And there are literally 100s of files with assembly indexes in the code.

But it can be made it easier, with another layer and macro preprocessing. So make a header one for the assembly and one for the C code, and define the struct with the macro. The assembly code can be compiled with C preprocessor, so the macros will work.

This way the C and the ASM stay sync. Only drawback, that the struct must be defined with this macros. But this is only for the structures that are used both in assembly and C or higher level.

Anyway if the indexes in the assembly code would be macros, that would be also much easier to modify.