Miosix  2.0alpha1
Kernel

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 ()
 

Detailed Description

Enumeration Type Documentation

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.

Function Documentation

bool miosix::areInterruptsEnabled ( )
Returns
true if interrupts are enabled
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)

void miosix::fastDisableInterrupts ( )
inline

Fast version of disableInterrupts().
Despite faster, it has a couple of preconditions:

  • calls to fastDisableInterrupts() can't be nested
  • it can't be used in code that is called before the kernel is started
void miosix::fastEnableInterrupts ( )
inline

Fast version of enableInterrupts().
Despite faster, it has a couple of preconditions:

  • calls to fastDisableInterrupts() can't be nested
  • it can't be used in code that is called before the kernel is started, because it will (incorreclty) lead to interrupts being enabled before the kernel is started
long long miosix::getTick ( )

Returns the current kernel tick.
Can be called also with interrupts disabled and/or kernel paused.

Returns
current kernel tick
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.

Returns
true if kernel is running (started && not paused)
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.