• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revision13205 (tree)
Time2019-12-03 18:40:30
Authorgdisirio

Log Message

Added support for asynchronous jobs queues to OSLIB.

Change Summary

Incremental Difference

--- trunk/demos/STM32/RT-STM32L476-DISCOVERY/main.c (revision 13204)
+++ trunk/demos/STM32/RT-STM32L476-DISCOVERY/main.c (revision 13205)
@@ -70,7 +70,7 @@
7070 */
7171 while (true) {
7272 if (palReadLine(LINE_JOY_CENTER)) {
73-// test_execute((BaseSequentialStream *)&SD2, &rt_test_suite);
73+ test_execute((BaseSequentialStream *)&SD2, &rt_test_suite);
7474 test_execute((BaseSequentialStream *)&SD2, &oslib_test_suite);
7575 }
7676 chThdSleepMilliseconds(500);
--- trunk/os/oslib/include/chjobs.h (revision 13204)
+++ trunk/os/oslib/include/chjobs.h (revision 13205)
@@ -43,11 +43,6 @@
4343 /*===========================================================================*/
4444
4545 /**
46- * @brief Job identifier that does nothing except cycle the dispatcher.
47- */
48-#define JOB_NULL ((msg_t)0)
49-
50-/**
5146 * @brief Dispatcher return code in case of a @p JOB_NUL has been received.
5247 */
5348 #define MSG_JOB_NULL ((msg_t)-2)
@@ -340,9 +335,12 @@
340335 /* Waiting for a job.*/
341336 msg = chMBFetchTimeout(&jqp->mbx, &jmsg, TIME_INFINITE);
342337 if (msg == MSG_OK) {
343- if (jmsg != JOB_NULL) {
344- job_descriptor_t *jp = (job_descriptor_t *)jmsg;
338+ job_descriptor_t *jp = (job_descriptor_t *)jmsg;
345339
340+ chDbgAssert(jp != NULL, "is NULL");
341+
342+ if (jp->jobfunc != NULL) {
343+
346344 /* Invoking the job function.*/
347345 jp->jobfunc(jp->jobarg);
348346
@@ -374,9 +372,12 @@
374372 /* Waiting for a job or a timeout.*/
375373 msg = chMBFetchTimeout(&jqp->mbx, &jmsg, timeout);
376374 if (msg == MSG_OK) {
377- if (jmsg != JOB_NULL) {
378- job_descriptor_t *jp = (job_descriptor_t *)jmsg;
375+ job_descriptor_t *jp = (job_descriptor_t *)jmsg;
379376
377+ chDbgAssert(jp != NULL, "is NULL");
378+
379+ if (jp->jobfunc != NULL) {
380+
380381 /* Invoking the job function.*/
381382 jp->jobfunc(jp->jobarg);
382383
--- trunk/test/oslib/source/test/oslib_test_sequence_004.c (revision 13204)
+++ trunk/test/oslib/source/test/oslib_test_sequence_004.c (revision 13205)
@@ -84,7 +84,7 @@
8484 * - [4.1.1] Initializing the Jobs Queue object.
8585 * - [4.1.2] Starting the dispatcher threads.
8686 * - [4.1.3] Sending jobs with various timings.
87- * - [4.1.4] Sending null jobs to make thread exit.
87+ * - [4.1.4] Sending null jobs to make threads exit.
8888 * .
8989 */
9090
@@ -138,11 +138,19 @@
138138 }
139139 test_end_step(3);
140140
141- /* [4.1.4] Sending null jobs to make thread exit.*/
141+ /* [4.1.4] Sending null jobs to make threads exit.*/
142142 test_set_step(4);
143143 {
144- chJobPost(&jq, JOB_NULL);
145- chJobPost(&jq, JOB_NULL);
144+ job_descriptor_t *jdp;
145+
146+ jdp = chJobGet(&jq);
147+ jdp->jobfunc = NULL;
148+ jdp->jobarg = NULL;
149+ chJobPost(&jq, jdp);
150+ jdp = chJobGet(&jq);
151+ jdp->jobfunc = NULL;
152+ jdp->jobarg = NULL;
153+ chJobPost(&jq, jdp);
146154 (void) chThdWait(tp1);
147155 (void) chThdWait(tp2);
148156 test_assert_sequence("abcdefgh", "unexpected tokens");
--- trunk/test/oslib/configuration.xml (revision 13204)
+++ trunk/test/oslib/configuration.xml (revision 13205)
@@ -1151,7 +1151,7 @@
11511151 </step>
11521152 <step>
11531153 <description>
1154- <value>Sending null jobs to make thread exit.</value>
1154+ <value>Sending two null jobs to make threads exit.</value>
11551155 </description>
11561156 <tags>
11571157 <value></value>
@@ -1158,8 +1158,16 @@
11581158 </tags>
11591159 <code>
11601160 <value><![CDATA[
1161-chJobPost(&jq, JOB_NULL);
1162-chJobPost(&jq, JOB_NULL);
1161+job_descriptor_t *jdp;
1162+
1163+jdp = chJobGet(&jq);
1164+jdp->jobfunc = NULL;
1165+jdp->jobarg = NULL;
1166+chJobPost(&jq, jdp);
1167+jdp = chJobGet(&jq);
1168+jdp->jobfunc = NULL;
1169+jdp->jobarg = NULL;
1170+chJobPost(&jq, jdp);
11631171 (void) chThdWait(tp1);
11641172 (void) chThdWait(tp2);
11651173 test_assert_sequence("abcdefgh", "unexpected tokens");
--- trunk/readme.txt (revision 13204)
+++ trunk/readme.txt (revision 13205)
@@ -74,6 +74,7 @@
7474 *****************************************************************************
7575
7676 *** Next ***
77+- LIB: Added support for asynchronous jobs queues to OSLIB.
7778 - LIB: Added support for delegate threads to OSLIB.
7879 - NIL: Improvements to messages, new functions chMsgWaitS(),
7980 chMsgWaitTimeoutS(), chMsgWaitTimeout().
Show on old repository browser