git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@25 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2007-09-28 18:42:04 +00:00
parent 95b238fc86
commit 9a0ef300bc
11 changed files with 163 additions and 98 deletions

View File

@ -23,7 +23,7 @@
#include "lpc214x_serial.h" #include "lpc214x_serial.h"
#include "buzzer.h" #include "buzzer.h"
static BYTE8 waThread1[UserStackSize(16)]; static BYTE8 waThread1[UserStackSize(32)];
static t_msg Thread1(void *arg) { static t_msg Thread1(void *arg) {
@ -40,7 +40,7 @@ static t_msg Thread1(void *arg) {
return 0; return 0;
} }
static BYTE8 waThread2[UserStackSize(16)]; static BYTE8 waThread2[UserStackSize(32)];
static t_msg Thread2(void *arg) { static t_msg Thread2(void *arg) {
@ -53,7 +53,7 @@ static t_msg Thread2(void *arg) {
return 0; return 0;
} }
static BYTE8 waThread3[UserStackSize(16)]; static BYTE8 waThread3[UserStackSize(32)];
static t_msg Thread3(void *arg) { static t_msg Thread3(void *arg) {

View File

@ -4,7 +4,7 @@
# Project related configuration options # Project related configuration options
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
PROJECT_NAME = ChibiOS/RT PROJECT_NAME = ChibiOS/RT
PROJECT_NUMBER = "0.2.1 alpha" PROJECT_NUMBER = "0.3.0 beta"
OUTPUT_DIRECTORY = . OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English OUTPUT_LANGUAGE = English
@ -26,7 +26,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO FULL_PATH_NAMES = NO
STRIP_FROM_PATH = "C:/Documents and Settings/Administrator/" STRIP_FROM_PATH = "C:/Documents and Settings/Administrator/"
STRIP_FROM_INC_PATH = STRIP_FROM_INC_PATH =
SHORT_NAMES = NO SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO MULTILINE_CPP_IS_BRIEF = NO
@ -34,7 +34,7 @@ DETAILS_AT_TOP = YES
INHERIT_DOCS = NO INHERIT_DOCS = NO
SEPARATE_MEMBER_PAGES = NO SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2 TAB_SIZE = 2
ALIASES = ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO BUILTIN_STL_SUPPORT = NO
@ -64,11 +64,11 @@ GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS = ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30 MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = NO SHOW_USED_FILES = NO
SHOW_DIRECTORIES = NO SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER = FILE_VERSION_FILTER =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to warning and progress messages # configuration options related to warning and progress messages
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -78,7 +78,7 @@ WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text" WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE = WARN_LOGFILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the input files # configuration options related to the input files
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -115,15 +115,15 @@ FILE_PATTERNS = *.c \
*.py \ *.py \
*.ddf *.ddf
RECURSIVE = YES RECURSIVE = YES
EXCLUDE = EXCLUDE =
EXCLUDE_SYMLINKS = NO EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = EXCLUDE_PATTERNS =
EXAMPLE_PATH = EXAMPLE_PATH =
EXAMPLE_PATTERNS = * EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO EXAMPLE_RECURSIVE = NO
IMAGE_PATH = IMAGE_PATH = ./img
INPUT_FILTER = INPUT_FILTER =
FILTER_PATTERNS = FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO FILTER_SOURCE_FILES = NO
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to source browsing # configuration options related to source browsing
@ -141,20 +141,20 @@ VERBATIM_HEADERS = NO
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5 COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX = IGNORE_PREFIX =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the HTML output # configuration options related to the HTML output
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
GENERATE_HTML = YES GENERATE_HTML = YES
HTML_OUTPUT = html HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html HTML_FILE_EXTENSION = .html
HTML_HEADER = HTML_HEADER =
HTML_FOOTER = HTML_FOOTER =
HTML_STYLESHEET = HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO GENERATE_HTMLHELP = NO
CHM_FILE = CHM_FILE =
HHC_LOCATION = HHC_LOCATION =
GENERATE_CHI = NO GENERATE_CHI = NO
BINARY_TOC = NO BINARY_TOC = NO
TOC_EXPAND = NO TOC_EXPAND = NO
@ -171,8 +171,8 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO COMPACT_LATEX = NO
PAPER_TYPE = a4wide PAPER_TYPE = a4wide
EXTRA_PACKAGES = EXTRA_PACKAGES =
LATEX_HEADER = LATEX_HEADER =
PDF_HYPERLINKS = NO PDF_HYPERLINKS = NO
USE_PDFLATEX = NO USE_PDFLATEX = NO
LATEX_BATCHMODE = NO LATEX_BATCHMODE = NO
@ -184,8 +184,8 @@ GENERATE_RTF = NO
RTF_OUTPUT = rtf RTF_OUTPUT = rtf
COMPACT_RTF = NO COMPACT_RTF = NO
RTF_HYPERLINKS = NO RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE = RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE = RTF_EXTENSIONS_FILE =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options related to the man page output # configuration options related to the man page output
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -198,8 +198,8 @@ MAN_LINKS = NO
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
GENERATE_XML = NO GENERATE_XML = NO
XML_OUTPUT = xml XML_OUTPUT = xml
XML_SCHEMA = XML_SCHEMA =
XML_DTD = XML_DTD =
XML_PROGRAMLISTING = YES XML_PROGRAMLISTING = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output # configuration options for the AutoGen Definitions output
@ -211,16 +211,16 @@ GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX = PERLMOD_MAKEVAR_PREFIX =
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the preprocessor # Configuration options related to the preprocessor
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES SEARCH_INCLUDES = YES
INCLUDE_PATH = INCLUDE_PATH =
INCLUDE_FILE_PATTERNS = INCLUDE_FILE_PATTERNS =
PREDEFINED = __JUST_STUBS__ \ PREDEFINED = __JUST_STUBS__ \
__DOXIGEN__ \ __DOXIGEN__ \
CH_USE_VIRTUAL_TIMERS \ CH_USE_VIRTUAL_TIMERS \
@ -242,18 +242,18 @@ PREDEFINED = __JUST_STUBS__ \
CH_USE_MESSAGES \ CH_USE_MESSAGES \
CH_USE_MESSAGES_TIMEOUT \ CH_USE_MESSAGES_TIMEOUT \
CH_USE_MESSAGES_EVENT CH_USE_MESSAGES_EVENT
EXPAND_AS_DEFINED = EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES SKIP_FUNCTION_MACROS = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration::additions related to external references # Configuration::additions related to external references
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
TAGFILES = TAGFILES =
GENERATE_TAGFILE = GENERATE_TAGFILE =
ALLEXTERNALS = NO ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl PERL_PATH = /usr/bin/perl
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the dot tool # Configuration options related to the dot tool
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES HIDE_UNDOC_RELATIONS = YES
@ -270,8 +270,8 @@ CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png DOT_IMAGE_FORMAT = png
DOT_PATH = DOT_PATH =
DOTFILE_DIRS = DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000 MAX_DOT_GRAPH_DEPTH = 1000
@ -280,6 +280,6 @@ DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES GENERATE_LEGEND = YES
DOT_CLEANUP = YES DOT_CLEANUP = YES
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration::additions related to the search engine # Configuration::additions related to the search engine
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
SEARCHENGINE = NO SEARCHENGINE = NO

View File

@ -47,8 +47,77 @@
* memory image.</li> * memory image.</li>
* <li>Almost totally written in C with little ASM code required for ports.</li> * <li>Almost totally written in C with little ASM code required for ports.</li>
* </ul> * </ul>
*
* ChibiOS/RT architecture:<br><br>
* @subpage Concepts
*/ */
/**
* @page Concepts Concepts
* @{
* @section naming Naming Conventions
* ChibiOS/RT APIs are all named following this convention:
* \a ch\<group\>\<action\>\<suffix\>().
* The possible groups are: \a Sys, \a Sch, \a VT, \a Thd, \a Sem, \a Evt,
* \a Msg, \a IQ, \a OQ, \a HQ,\a FDD, \a HDD.
* The suffix is not present for normal APIs but can be one of
* the following: "I" for APIs meant to be invoked from an interrupt handler
* or within the system mutex zone but not from user code, "S" for APIs only
* useable from within the system mutex zone but not from interrupt handlers
* or user code. The APIs without suffix can be invoked only from the user
* code.<br>
* Examples: \p chThdCreate(), \p chSemSignalI(), \p chIQGetTimeout().
*
* @section scheduling Scheduling
* The strategy is very simple the currently ready thread with the highest
* priority is executed. If more than one thread with equal priority are
* eligible for execution then they are executed in a round-robin way, the
* CPU time slice constant is configurable. The ready list is a double linked
* list of threads ordered by priority.
* @image html readylist.png
* Note that the currently running thread is not in the ready list, the list
* only contains the threads ready to be executed but still actually waiting.
*
* @section warea Thread Working Area
* Each thread has its own stack, a Thread structure and a registers dump
* structure. All the structures are allocated into a "Thread working area",
* a thread private heap, usually allocated in a char array declared in your
* code, there is not a central threads table or list, this means you can
* have as many threads you want as long you have enough available RAM
* memory. The threads do not use any memory outside the allocated working
* area.<br>
* @image html workspace.png
* <br>
* Note that the registers dump is only present when the Thread is not
* running, the context switching is done by pushing the registers on the
* stack of the switched-out thread and popping the registers of the
* switched-in thread from its stack.
*
* @section sysmutex System Mutex Zone
* It is the code within the OS that cannot be preempted, this code is
* everything between the \p chSysLock() and \p chSysUnlock() API calls.
* The implementation of the APIs in most cases just enables/disables the
* interrupts. Of course the code in the system mutex zone must be as short
* and efficient possible as it affects the RT performance of the whole
* system. The worst case response time is affected by the longest code
* path in the system mutex zone or interrupt handler.
* @code
* // User code, not critical, preemption possible.
* chSysLock();
* ...
* // System critical code, preemption delayed.
* ...
* chSysUnlock();
* // User code, preemption possible again.
* @endcode
* Applications usually do not need to put code into the system mutex zone
* unless you are implementing device drivers or special synchronization
* primitives, everything else can be implemented by using semaphores,
* messages or events.
*/
/** @} */
/** /**
* @defgroup Kernel Kernel * @defgroup Kernel Kernel
* @{ * @{

BIN
docs/img/readylist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
docs/img/workspace.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -32,6 +32,15 @@ LPC214x-GCC - ChibiOS/RT port for ARM7 LPC2148, the demo targets the
*** Releases *** *** Releases ***
***************************************************************************** *****************************************************************************
*** 0.3.0 ***
- ChibiOS/RT goes beta.
- Diet for the threads code, some simple APIs become macros.
- Thread Local Storage implemented as a single API: chThdLS().
The API simply returns a pointer into the thread working area, see the
documentation on the web site.
- Moved some documentation and images from the web site into the Doxigen
generated HTMLs.
*** 0.2.1 *** *** 0.2.1 ***
- Optimizations in the RT semaphores subsystem. The support for this - Optimizations in the RT semaphores subsystem. The support for this
subsystem should still be considered experimental and further changes may subsystem should still be considered experimental and further changes may

View File

@ -62,11 +62,11 @@ t_time chSysGetTime(void) {
* option is enabled in \p chconf.h. * option is enabled in \p chconf.h.
*/ */
void chThdSleepUntil(t_time time) { void chThdSleepUntil(t_time time) {
VirtualTimer t; VirtualTimer vt;
chSysLock(); chSysLock();
chVTSetI(&t, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp); chVTSetI(&vt, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp);
chSchGoSleepI(PRSLEEP); chSchGoSleepI(PRSLEEP);
chSysUnlock(); chSysUnlock();

View File

@ -129,17 +129,6 @@ Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
return tp; return tp;
} }
/**
* Verifies if the specified thread is in the \p PREXIT state.
* @param tp the pointer to the thread
* @return \p TRUE if the thread is ended else \p FALSE. \p TRUE ensures that
* a subsequent call to \p chThdWait() would not block.
*/
BOOL chThdTerminated(Thread *tp) {
return tp->p_state == PREXIT;
}
#ifdef CH_USE_RESUME #ifdef CH_USE_RESUME
/** /**
* Resumes a thread created with the \p P_SUSPENDED option. * Resumes a thread created with the \p P_SUSPENDED option.
@ -176,17 +165,6 @@ void chThdTerminate(Thread *tp) {
chSysUnlock(); chSysUnlock();
} }
/**
* Verifies if the current thread has a termination request pending.
* @return \p TRUE if the termination was requested. The thread should terminate
* as soon it is ready to do so.
*/
BOOL chThdShouldTerminate(void) {
return currp->p_flags & P_TERMINATE ? TRUE : FALSE;
}
#endif #endif
/** /**
@ -234,31 +212,4 @@ t_msg chThdWait(Thread *tp) {
} }
#endif /* CH_USE_WAITEXIT */ #endif /* CH_USE_WAITEXIT */
#ifdef CH_USE_EXIT_EVENT
/**
* Returns the exit event source for the specified thread. The source is
* signaled when the thread terminates.
* @param tp the pointer to the thread
* @note When registering on a thread termination make sure the thread
* is still alive, if you do that after the thread termination
* then you would miss the event. There are two ways to ensure
* this:<br>
* <ul>
* <li>Create the thread suspended, register on the event source
* and then resume the thread (recommended).</li>
* <li>Create the thread with a lower priority then register on it.
* This does not work if the hardware is capable of multiple
* physical threads.</li>
* </ul>
* @note You dont need to unregister from a terminated thread because
* the event source becomes inactive.
* @note The function is available only if the \p CH_USE_EXIT_EVENT
* option is enabled in \p chconf.h.
*/
EventSource *chThdGetExitEventSource(Thread *tp) {
return &tp->p_exitesource;
}
#endif /* CH_USE_EXIT_EVENT */
/** @} */ /** @} */

View File

@ -182,19 +182,55 @@ static INLINE void enqueue(Thread *tp, ThreadsQueue *tqp) {
/* /*
* Threads APIs. * Threads APIs.
*/ */
#define chThdSelf() currp
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace, Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
t_size wsize, t_tfunc pf, void *arg); t_size wsize, t_tfunc pf, void *arg);
void chThdResume(Thread *tp); void chThdResume(Thread *tp);
void chThdTerminate(Thread *tp);
BOOL chThdShouldTerminate(void);
BOOL chThdTerminated(Thread *tp);
void chThdExit(t_msg msg); void chThdExit(t_msg msg);
/** Returns the pointer to the \p Thread currently in execution.*/
#define chThdSelf() currp
/** Returns the pointer to the \p Thread local storage area, if any.*/
#define chThdLS() (void *)(currp + 1)
/** Verifies if the specified thread is in the \p PREXIT state.*/
#define chThdTerminated(tp) ((tp)->p_state == PREXIT)
#ifdef CH_USE_TERMINATE
/**
* Verifies if the current thread has a termination request pending.
*/
#define chThdShouldTerminate() (currp->p_flags & P_TERMINATE)
void chThdTerminate(Thread *tp);
#endif
#ifdef CH_USE_WAITEXIT #ifdef CH_USE_WAITEXIT
t_msg chThdWait(Thread *tp); t_msg chThdWait(Thread *tp);
#endif #endif
#ifdef CH_USE_EXIT_EVENT #ifdef CH_USE_EXIT_EVENT
EventSource *chThdGetExitEventSource(Thread *tp); /**
* Returns the exit event source for the specified thread. The source is
* signaled when the thread terminates.
* @param tp the pointer to the thread
* @note When registering on a thread termination make sure the thread
* is still alive, if you do that after the thread termination
* then you would miss the event. There are two ways to ensure
* this:<br>
* <ul>
* <li>Create the thread suspended, register on the event source
* and then resume the thread (recommended).</li>
* <li>Create the thread with a lower priority then register on it.
* This does not work if the hardware is capable of multiple
* physical threads.</li>
* </ul>
* @note You dont need to unregister from a terminated thread because
* the event source becomes inactive.
* @note The function is available only if the \p CH_USE_EXIT_EVENT
* option is enabled in \p chconf.h.
*/
#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource)
#endif #endif
#endif /* _THREADS_H_ */ #endif /* _THREADS_H_ */

View File

@ -37,7 +37,7 @@
void chSysPause(void) {} void chSysPause(void) {}
/** /**
* Abonormal system termination handler. Invoked by the ChobiOS/RT when an * Abonormal system termination handler. Invoked by the ChibiOS/RT when an
* abnormal unrecoverable condition is met. * abnormal unrecoverable condition is met.
*/ */
void chSysHalt(void) {} void chSysHalt(void) {}

View File

@ -39,7 +39,7 @@ struct stackregs {
} }
/** /**
* Enters the ChobiOS/RT system mutual exclusion zone, the implementation is * Enters the ChibiOS/RT system mutual exclusion zone, the implementation is
* architecture dependent, on single core systems usually this function * architecture dependent, on single core systems usually this function
* just disables the interrupts. * just disables the interrupts.
* @note The code in the system mutual exclusion zone must be as light and * @note The code in the system mutual exclusion zone must be as light and
@ -50,7 +50,7 @@ struct stackregs {
#define chSysLock() #define chSysLock()
/** /**
* Leaves the ChobiOS/RT system mutual exclusion zone, the implementation is * Leaves the ChibiOS/RT system mutual exclusion zone, the implementation is
* architecture dependent, on single core systems usually this function * architecture dependent, on single core systems usually this function
* just enables the interrupts. * just enables the interrupts.
* @note The code in the system mutual exclusion zone must be as light and * @note The code in the system mutual exclusion zone must be as light and