Added support for asynchronous jobs queues to OSLIB.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13205 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
a1f7bbd4b6
commit
2f2b7d22fd
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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().
|
||||
|
|
|
@ -1151,15 +1151,23 @@ for (i = 0; i < 8; i++) {
|
|||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Sending null jobs to make thread exit.</value>
|
||||
<value>Sending two null jobs to make threads exit.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value></value>
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[
|
||||
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");
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue