diff --git a/demos/STM32/RT-STM32L476-DISCOVERY/main.c b/demos/STM32/RT-STM32L476-DISCOVERY/main.c index 4741341a7..e8381a231 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY/main.c +++ b/demos/STM32/RT-STM32L476-DISCOVERY/main.c @@ -70,7 +70,7 @@ int main(void) { */ while (true) { if (palReadLine(LINE_JOY_CENTER)) { -// test_execute((BaseSequentialStream *)&SD2, &rt_test_suite); + test_execute((BaseSequentialStream *)&SD2, &rt_test_suite); test_execute((BaseSequentialStream *)&SD2, &oslib_test_suite); } chThdSleepMilliseconds(500); diff --git a/os/oslib/include/chjobs.h b/os/oslib/include/chjobs.h index 9a616e1e2..0fcdd0bf6 100644 --- a/os/oslib/include/chjobs.h +++ b/os/oslib/include/chjobs.h @@ -42,11 +42,6 @@ /* Module constants. */ /*===========================================================================*/ -/** - * @brief Job identifier that does nothing except cycle the dispatcher. - */ -#define JOB_NULL ((msg_t)0) - /** * @brief Dispatcher return code in case of a @p JOB_NUL has been received. */ @@ -340,8 +335,11 @@ static inline msg_t chJobDispatch(jobs_queue_t *jqp) { /* Waiting for a job.*/ msg = chMBFetchTimeout(&jqp->mbx, &jmsg, TIME_INFINITE); if (msg == MSG_OK) { - if (jmsg != JOB_NULL) { - job_descriptor_t *jp = (job_descriptor_t *)jmsg; + job_descriptor_t *jp = (job_descriptor_t *)jmsg; + + chDbgAssert(jp != NULL, "is NULL"); + + if (jp->jobfunc != NULL) { /* Invoking the job function.*/ jp->jobfunc(jp->jobarg); @@ -374,8 +372,11 @@ static inline msg_t chJobDispatchTimeout(jobs_queue_t *jqp, /* Waiting for a job or a timeout.*/ msg = chMBFetchTimeout(&jqp->mbx, &jmsg, timeout); if (msg == MSG_OK) { - if (jmsg != JOB_NULL) { - job_descriptor_t *jp = (job_descriptor_t *)jmsg; + job_descriptor_t *jp = (job_descriptor_t *)jmsg; + + chDbgAssert(jp != NULL, "is NULL"); + + if (jp->jobfunc != NULL) { /* Invoking the job function.*/ jp->jobfunc(jp->jobarg); diff --git a/readme.txt b/readme.txt index aa399b571..390077cea 100644 --- a/readme.txt +++ b/readme.txt @@ -74,6 +74,7 @@ ***************************************************************************** *** Next *** +- LIB: Added support for asynchronous jobs queues to OSLIB. - LIB: Added support for delegate threads to OSLIB. - NIL: Improvements to messages, new functions chMsgWaitS(), chMsgWaitTimeoutS(), chMsgWaitTimeout(). diff --git a/test/oslib/configuration.xml b/test/oslib/configuration.xml index 535471b65..a467f47df 100644 --- a/test/oslib/configuration.xml +++ b/test/oslib/configuration.xml @@ -1151,15 +1151,23 @@ for (i = 0; i < 8; i++) { - Sending null jobs to make thread exit. + Sending two null jobs to make threads exit. jobfunc = NULL; +jdp->jobarg = NULL; +chJobPost(&jq, jdp); +jdp = chJobGet(&jq); +jdp->jobfunc = NULL; +jdp->jobarg = NULL; +chJobPost(&jq, jdp); (void) chThdWait(tp1); (void) chThdWait(tp2); test_assert_sequence("abcdefgh", "unexpected tokens"); diff --git a/test/oslib/source/test/oslib_test_sequence_004.c b/test/oslib/source/test/oslib_test_sequence_004.c index 709243adc..525f9aae1 100644 --- a/test/oslib/source/test/oslib_test_sequence_004.c +++ b/test/oslib/source/test/oslib_test_sequence_004.c @@ -84,7 +84,7 @@ static THD_FUNCTION(Thread1, arg) { * - [4.1.1] Initializing the Jobs Queue object. * - [4.1.2] Starting the dispatcher threads. * - [4.1.3] Sending jobs with various timings. - * - [4.1.4] Sending null jobs to make thread exit. + * - [4.1.4] Sending null jobs to make threads exit. * . */ @@ -138,11 +138,19 @@ static void oslib_test_004_001_execute(void) { } test_end_step(3); - /* [4.1.4] Sending null jobs to make thread exit.*/ + /* [4.1.4] Sending null jobs to make threads exit.*/ test_set_step(4); { - chJobPost(&jq, JOB_NULL); - chJobPost(&jq, JOB_NULL); + job_descriptor_t *jdp; + + jdp = chJobGet(&jq); + jdp->jobfunc = NULL; + jdp->jobarg = NULL; + chJobPost(&jq, jdp); + jdp = chJobGet(&jq); + jdp->jobfunc = NULL; + jdp->jobarg = NULL; + chJobPost(&jq, jdp); (void) chThdWait(tp1); (void) chThdWait(tp2); test_assert_sequence("abcdefgh", "unexpected tokens");