3
votes

I would like to design and implement a bare metal, OS-like simple and safe scheduler.

The mechanism should handle IRQ context (USB and SDH), and 3-4 main subroutines two of them manipulate both USB and SDH controllers and all have some CPU usage.

What is the best and most efficient direction to go with for ARM cortex A12 single core, in order to implement a safe scheduling mechanism runs all the subroutines (all on privileged mode) and can handle the IRQ context?

1
Have you written any code? Do you have a more specific question? There are plenty of free real-time executives out there that you could look at for examples.Carl Norum
I am trying to figure out the correct design and then try to implement it by myself, I am not sure I took all the right considerations yet. I have all the subroutines and irq handler implemented, long code, but I want to wrap them and scheduling them in the right way. thanks0x90
It definitely requires an opinion. A clear design criteria is pre-emptive vs non-preemptive. As well, I would assume no MMU? If it is non-preemptive (or co-operative), you don't need to save any registers on a context switch and code your ISR in assembler; that makes the scheduler very efficient. I think best is the over-loaded portion of your question you need to address.artless noise
Maybe Simon Tatham coroutines are interesting to you. See also Coroutine at wikipedia or Donald Knuth's books if you have them.artless noise
Basically, you have one co-routine thread that processes USB. When there is no more data to process, it yeilds and either the SDH user thread runs or a higher layer USB routine. Your ISRs would feed the co-routines. I guess the routines are processing different layers. When you have a big enough chunk, you can proceed to the next layer. This helps cache locality and you should get better I/O performance, if structured correctly.artless noise

1 Answers

0
votes

If cooperative threading is enough for you, you could try Lua language, it has native support for coroutines and it interfaces easily with C code. There is also a port for embedded processors: see eLua.