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

This commit is contained in:
gdisirio 2009-03-10 15:31:58 +00:00
parent a2bab9c63d
commit da4f9beaee
12 changed files with 47 additions and 21 deletions

View File

@ -194,7 +194,7 @@ static msg_t ShellThread(void *arg) {
else if (stricmp(lp, "time") == 0) { else if (stricmp(lp, "time") == 0) {
if (checkend(sd)) if (checkend(sd))
continue; continue;
sprintf(line, "Time: %d\r\n", chSysGetTime()); sprintf(line, "Time: %d\r\n", chTimeNow());
PrintLineFDD(sd, line); PrintLineFDD(sd, line);
} }
else if (stricmp(lp, "hello") == 0) { else if (stricmp(lp, "hello") == 0) {

View File

@ -34,9 +34,9 @@
* @section naming Naming Conventions * @section naming Naming Conventions
* ChibiOS/RT APIs are all named following this convention: * ChibiOS/RT APIs are all named following this convention:
* @a ch\<group\>\<action\>\<suffix\>(). * @a ch\<group\>\<action\>\<suffix\>().
* The possible groups are: @a Sys, @a Sch, @a VT, @a Thd, @a Sem, @a Mtx, * The possible groups are: @a Sys, @a Sch, @a Time @a VT, @a Thd, @a Sem,
* @a Cond, @a Evt, @a Msg, @a IQ, @a OQ, @a HQ, @a FDD, @a HDD, @a Dbg, * @a Mtx, @a Cond, @a Evt, @a Msg, @a IQ, @a OQ, @a HQ, @a FDD, @a HDD,
* @a Heap, @a Pool. * @a Dbg, @a Heap, @a Pool.
* *
* @section api_suffixes API Names Suffixes * @section api_suffixes API Names Suffixes
* The suffix can be one of the following: * The suffix can be one of the following:

View File

@ -46,7 +46,7 @@ msg_t my_thread(void *param) {
* @code * @code
msg_t my_thread(void *param) { msg_t my_thread(void *param) {
systick_t time = chSysGetTime(); /* T0 */ systick_t time = chTimeNow(); /* T0 */
while (TRUE) { while (TRUE) {
time += MS2ST(1000); /* Next deadline */ time += MS2ST(1000); /* Next deadline */
do_something(); do_something();

View File

@ -75,7 +75,13 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*** 1.1.2unstable *** *** 1.1.2unstable ***
- FIX: Fixed priority inheritance problem with condvars (bug 2674756) and - FIX: Fixed priority inheritance problem with condvars (bug 2674756) and
added a specific test case to the test suite (backported in stable branch). added a specific test case to the test suite (backported in stable branch).
- FIX: Fixed a wrong parameter check in chVTSetI() (bug 2679155).
- FIX: Build error with options CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
(bug 2678928).
- FIX: Removed unused chSysPuts() macro (bug 2672678). - FIX: Removed unused chSysPuts() macro (bug 2672678).
- FIX: Renamed function chSysInTimeWindow() as chTimeIsWithin() and renamed
the macro chSysGetTime() in chTimeNow(), the old names are still recognized
but marked as deprecated (fixes the bug 2678953 but goes a bit further).
- Removed testcond.c|h and moved the test cases into testmtx.c. Mutexes and - Removed testcond.c|h and moved the test cases into testmtx.c. Mutexes and
condvars have to be tested together. condvars have to be tested together.
- Added architecture diagram to the documentation. - Added architecture diagram to the documentation.

View File

@ -110,14 +110,18 @@ void chSysTimerHandlerI(void) {
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED #if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
void chSysLock(void) { void chSysLock(void) {
chDbgAssert(currp->p_locks >= 0, "chinit.c, chSysLock()"); chDbgAssert(currp->p_locks >= 0,
"chSysLock(), #1",
"negative nesting counter");
if (currp->p_locks++ == 0) if (currp->p_locks++ == 0)
port_lock(); port_lock();
} }
void chSysUnlock(void) { void chSysUnlock(void) {
chDbgAssert(currp->p_locks > 0, "chinit.c, chSysUnlock()"); chDbgAssert(currp->p_locks > 0,
"chSysUnlock(), #1",
"non-positive nesting counter");
if (--currp->p_locks == 0) if (--currp->p_locks == 0)
port_unlock(); port_unlock();
} }

View File

@ -290,7 +290,7 @@ void chThdSleep(systime_t time) {
void chThdSleepUntil(systime_t time) { void chThdSleepUntil(systime_t time) {
chSysLock(); chSysLock();
if ((time -= chSysGetTime()) > 0) if ((time -= chTimeNow()) > 0)
chThdSleepS(time); chThdSleepS(time);
chSysUnlock(); chSysUnlock();
} }

View File

@ -19,7 +19,7 @@
/** /**
* @file chvt.c * @file chvt.c
* @brief Time related code. * @brief Time and Virtual Timers related code.
* @addtogroup Time * @addtogroup Time
* @{ * @{
*/ */
@ -58,8 +58,8 @@ void vt_init(void) {
void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) { void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) {
VirtualTimer *p; VirtualTimer *p;
chDbgCheck((vtp != NULL) && (vtfunc != NULL) && chDbgCheck((vtp != NULL) && (vtfunc != NULL) && (time != TIME_INFINITE),
(time != TIME_IMMEDIATE) && (time != TIME_INFINITE), "chVTSetI"); "chVTSetI");
vtp->vt_par = par; vtp->vt_par = par;
vtp->vt_func = vtfunc; vtp->vt_func = vtfunc;
@ -103,9 +103,9 @@ void chVTResetI(VirtualTimer *vtp) {
* @retval TRUE current time within the specified time window. * @retval TRUE current time within the specified time window.
* @retval FALSE current time not within the specified time window. * @retval FALSE current time not within the specified time window.
*/ */
bool_t chSysInTimeWindow(systime_t start, systime_t end) { bool_t chTimeIsWithin(systime_t start, systime_t end) {
systime_t time = chSysGetTime(); systime_t time = chTimeNow();
return end >= start ? (time >= start) && (time < end) : return end >= start ? (time >= start) && (time < end) :
(time >= start) || (time < end); (time >= start) || (time < end);
} }

View File

@ -171,6 +171,10 @@ extern "C" {
#endif #endif
void chSysInit(void); void chSysInit(void);
void chSysTimerHandlerI(void); void chSysTimerHandlerI(void);
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
void chSysLock(void);
void chSysUnlock(void);
#endif /* CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -104,7 +104,7 @@ extern "C" {
void vt_init(void); void vt_init(void);
void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par); void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par);
void chVTResetI(VirtualTimer *vtp); void chVTResetI(VirtualTimer *vtp);
bool_t chSysInTimeWindow(systime_t start, systime_t end); bool_t chTimeIsWithin(systime_t start, systime_t end);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -118,8 +118,20 @@ extern "C" {
* @note The counter can reach its maximum and then returns to zero. * @note The counter can reach its maximum and then returns to zero.
* @note This function is designed to work with the @p chThdSleepUntil(). * @note This function is designed to work with the @p chThdSleepUntil().
*/ */
#define chSysGetTime() (vtlist.vt_systime) #define chTimeNow() (vtlist.vt_systime)
/**
* Provided for backward compatibility.
* @deprecated Will be removed in 1.2.0.
*/
#define chSysGetTime() chTimeNow()
/**
* Provided for backward compatibility.
* @deprecated Will be removed in 1.2.0.
*/
#define chSysInTimeWindow(start, end) chTimeIsWithin(start, end)
#endif /* _VT_H_ */ #endif /* _VT_H_ */
/** @} */ /** @} */

View File

@ -146,7 +146,7 @@ bool_t _test_assert_sequence(char *expected) {
bool_t _test_assert_time_window(systime_t start, systime_t end) { bool_t _test_assert_time_window(systime_t start, systime_t end) {
return _test_assert(chSysInTimeWindow(start, end), "time window error"); return _test_assert(chTimeIsWithin(start, end), "time window error");
} }
/* /*
@ -171,8 +171,8 @@ void test_wait_threads(void) {
void test_cpu_pulse(unsigned ms) { void test_cpu_pulse(unsigned ms) {
systime_t duration = MS2ST(ms); systime_t duration = MS2ST(ms);
systime_t start = chSysGetTime(); systime_t start = chTimeNow();
while (chSysInTimeWindow(start, start + duration)) { while (chTimeIsWithin(start, start + duration)) {
#if defined(WIN32) #if defined(WIN32)
ChkIntSources(); ChkIntSources();
#endif #endif
@ -182,7 +182,7 @@ void test_cpu_pulse(unsigned ms) {
systime_t test_wait_tick(void) { systime_t test_wait_tick(void) {
chThdSleep(1); chThdSleep(1);
return chSysGetTime(); return chTimeNow();
} }
/* /*

View File

@ -77,7 +77,7 @@ static void evt1_execute(void) {
chEvtInit(&es2); chEvtInit(&es2);
chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es2, &el2, 4); chEvtRegisterMask(&es2, &el2, 4);
target_time = chSysGetTime() + MS2ST(50); target_time = chTimeNow() + MS2ST(50);
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread, "A"); threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread, "A");
m = chEvtWaitAll(5); m = chEvtWaitAll(5);
test_assert_time_window(target_time, target_time + ALLOWED_DELAY); test_assert_time_window(target_time, target_time + ALLOWED_DELAY);

View File

@ -86,7 +86,7 @@ static void sem2_execute(void) {
msg= chSemWaitTimeout(&sem1, TIME_IMMEDIATE); msg= chSemWaitTimeout(&sem1, TIME_IMMEDIATE);
test_assert(msg == RDY_TIMEOUT, "#1"); test_assert(msg == RDY_TIMEOUT, "#1");
target_time = chSysGetTime() + MS2ST(5 * 500); target_time = chTimeNow() + MS2ST(5 * 500);
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
test_emit_token('A' + i); test_emit_token('A' + i);
msg = chSemWaitTimeout(&sem1, MS2ST(500)); msg = chSemWaitTimeout(&sem1, MS2ST(500));