Threads


Classes

class  miosix::Thread

Functions

char miosix::cpu_load ()
void miosix::pause_kernel ()
void miosix::restart_kernel ()
bool miosix::is_kernel_running ()
unsigned long long miosix::get_tick ()

Detailed Description

Miosix multithreading 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.


Function Documentation

char miosix::cpu_load (  ) 

It returns a number between 0 and 100 representing cpu load in the last 100 ticks.
Only available if WITH_CPU_METER is defined.

unsigned long long miosix::get_tick (  ) 

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

Returns:
current kernel tick

bool miosix::is_kernel_running (  ) 

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

Pause the kernel.
Interrupts will continue to occur, but no preemption is possible. Call to this function are cumulative: if you call pause_kernel() two times, you need to call restart_kernel() 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::restart_kernel (  ) 

Restart the kernel.
This function will yield immediately if a tick has been missed. Since calls to pause_kernel() are cumulative, if you call pause_kernel() two times, you need to call restart_kernel() two times.
This function is safe to be called even before the kernel is started. In this case it has no effect.


Generated on Fri Jun 19 15:19:04 2009 for Miosix by  doxygen 1.5.6