PrefaceThe usage of the Acorn kernel is quite simple and straightforward - consider the kernel as a framework onto which you build up your tasks. The driving force behind its design is "The beauty is in simplicity"!
- Kernel.inc - defines main kernel and user API.
- Kernel.asm - defines the kernel initialization and start up sequence
- INTERRUPTS.asm - defines the interrupts that your system will need. Timer 0 and Timer 1 overflow interrupts are reserved for system usage.
- Tasks.asm - entry point for your tasks.
- 16bitMath.inc - 16 bit arithmetic.
Task structure:Each task consists of 2 parts:
- Initialization - the part between the task label and the beginnig of the internal task loop.It is executed only once.As the name implies - it is used mainly for initialization.
- Task body: - the part between the internal task loop.It must be noted that the task never exits - it could be suspended if not used.
Interrupt processingInterrupt processing in the very interrupt handler should be as short as possible since it blocks all other interrupts including the task scheduler therefor the ultimate objective is to lower the execution logical level to user mode(where the task execution reside).
There are 3 major framework behaviors in regard to the interrupt processing.
- Use Event notification in the interrupt handler to let the listening task do the interrupt processing - it is not known how many scheduling quantum it will take so that the waiting task could become active and respond to the interrupt. Not a real time response scenario!
- Use Dispatch to extension to escape from interrupt handler kernel level and enter the arbitrary task context that was interrupted - the interrupt processing is done in an arbitrary context so use CPU resources with care. It is not known how long the the task will be active which implies that the extension code could be descheduled. To some extent this could be considered a real time scenario response.
- Use Interrupt Dispatching to make the interrupt processing task active on behalf of the interrupted task. It takes some time to dischedule the current interrupted task and make the interrupt processing task active. The interrupt is processed in its dedicated context and at a higher privilege.
Hardware dependencyThe kernel uses 2 timers configured during the system reset. Timer registers name could differ from one CPU to another.Consult the CPU documentation to solve the problem.