Miosix
2.01
|
Classes | |
class | miosix::InterruptDisableLock |
class | miosix::InterruptEnableLock |
class | miosix::FastInterruptDisableLock |
class | miosix::FastInterruptEnableLock |
class | miosix::PauseKernelLock |
class | miosix::RestartKernelLock |
class | miosix::Thread |
class | miosix::LowerPriority |
Enumerations | |
enum | miosix::Thread::Options { miosix::Thread::DEFAULT =0, miosix::Thread::JOINABLE =1<<0 } |
Functions | |
void | miosix::disableInterrupts () |
void | miosix::enableInterrupts () |
void | miosix::fastDisableInterrupts () |
void | miosix::fastEnableInterrupts () |
void | miosix::pauseKernel () |
void | miosix::restartKernel () |
bool | miosix::areInterruptsEnabled () |
bool | miosix::isKernelRunning () |
long long | miosix::getTick () |
Miosix kernel API
The most useful part of this API is the Thread class that allows to create and manage threads.
A note on IRQ functions/methods:
Functions and methods that do not begin with IRQ cannot be called inside IRQ or when interrupts are disabled.
Functions and methods that begin with IRQ cannot be called outside IRQ or when interrupts are enabled.
When the kernel is paused, you must read the comment of the function to see if it can be called since there is no general rule.
Starting from Miosix 1.53 functions designed to be called with kernel paused are marked with the PK prefix.
Thread options, can be passed to Thread::create to set additional options of the thread. More options can be specified simultaneously by ORing them together. The DEFAULT option indicates the default thread creation.
Enumerator | |
---|---|
DEFAULT |
Default thread options. |
JOINABLE |
Thread is joinable instead of detached. |
bool miosix::areInterruptsEnabled | ( | ) |
void miosix::disableInterrupts | ( | ) |
Disable interrupts, if interrupts were enable prior to calling this function.
Please note that starting from Miosix 1.51 disableInterrupts() and enableInterrupts() can be nested. You can therefore call disableInterrupts() multiple times as long as each call is matched by a call to enableInterrupts().
This replaced disable_and_save_interrupts() and restore_interrupts()
disableInterrupts() cannot be called within an interrupt routine, but can be called before the kernel is started (and does nothing in this case)
void miosix::enableInterrupts | ( | ) |
Enable interrupts.
Please note that starting from Miosix 1.51 disableInterrupts() and enableInterrupts() can be nested. You can therefore call disableInterrupts() multiple times as long as each call is matched by a call to enableInterrupts().
This replaced disable_and_save_interrupts() and restore_interrupts()
enableInterrupts() cannot be called within an interrupt routine, but can be called before the kernel is started (and does nothing in this case)
|
inline |
Fast version of disableInterrupts().
Despite faster, it has a couple of preconditions:
|
inline |
Fast version of enableInterrupts().
Despite faster, it has a couple of preconditions:
long long miosix::getTick | ( | ) |
Returns the current kernel tick.
Can be called also with interrupts disabled and/or kernel paused.
bool miosix::isKernelRunning | ( | ) |
Return true if kernel is running, false if it is not started, or paused.
Warning: disabling/enabling interrupts does not affect the result returned by this function.
void miosix::pauseKernel | ( | ) |
Pause the kernel.
Interrupts will continue to occur, but no preemption is possible. Call to this function are cumulative: if you call pauseKernel() two times, you need to call restartKernel() two times.
Pausing the kernel must be avoided if possible because it is easy to cause deadlock. Calling file related functions (fopen, Directory::open() ...), serial port related functions (printf ...) or kernel functions that cannot be called when the kernel is paused will cause deadlock. Therefore, if possible, it is better to use a Mutex instead of pausing the kernel
This function is safe to be called even before the kernel is started. In this case it has no effect.
void miosix::restartKernel | ( | ) |
Restart the kernel.
This function will yield immediately if a tick has been missed. Since calls to pauseKernel() are cumulative, if you call pauseKernel() two times, you need to call restartKernel() two times.
This function is safe to be called even before the kernel is started. In this case it has no effect.