Manual chSchRescheduleS() neccessary?

Discussions and support about ChibiOS/RT, the free embedded RTOS.
ulikoehler
Posts: 71
Joined: Tue Mar 17, 2015 2:32 am
Location: Munich, Germany
Been thanked: 3 times

Manual chSchRescheduleS() neccessary?

Postby ulikoehler » Thu Apr 02, 2015 5:15 am

Hi,
I've written a SC16IS752IPW driver (2ch UART expander) for ChibiOS 2.x some time ago.
Todo I've tried it out with ChibiOS 3.x trunk.

It uses a custom SerialDriver object. New incoming bytes cause an event flag notification in the RX/TX thread.

When I use the 2.x code, I trigger this assertion:

Code: Select all

  /* The following condition can be triggered by the use of i-class functions
     in a critical section not followed by a chSchResceduleS(), this means
     that the current thread has a lower priority than the next thread in
     the ready list.*/
  chDbgAssert((ch.rlist.r_queue.p_next == (thread_t *)&ch.rlist.r_queue) ||
              (ch.rlist.r_current->p_prio >= ch.rlist.r_queue.p_next->p_prio),
              "priority violation, missing reschedule");


I had to modify my code like this:

Code: Select all

static void txQueueNotifyA(io_queue_t* q) {
    (void)q;
    chEvtSignalI(sc16Thread, EVENT_TXA);
    //Since ChibiOS 3
    chSchRescheduleS();
}


I believe the manual reschedule call should not really be neccessary. Just like with chEvtSignal(), chEvtSignalI() should automatically reschedule. Maybe this is a corner case that has not been considered yet. As far as I know there are no tests (I searched the testhal and test folder) involving sdObjectInit().

Is there a better way to solve this?

Best regards, Uli

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Manual chSchRescheduleS() neccessary?

Postby Giovanni » Thu Apr 02, 2015 8:03 am

It is correct, those notification functions are called from thread context so rescheduling does not happen automatically for I-Class functions, manual rescheduling is required.

The difference between 2.6 and 3.0 is that 3.0 complains about it with an assertion, it is much more stringent on this kind of subtle issues.

Note that I-class functions never reschedule, ISRs are rescheduled at their end if necessary.

Giovanni

pascalhuerst
Posts: 1
Joined: Tue Feb 06, 2018 3:41 pm
Has thanked: 1 time

Re: Manual chSchRescheduleS() neccessary?

Postby pascalhuerst » Tue Feb 06, 2018 3:48 pm

Hey everyone,

probably I missed something, but how am I supposed to reschedule if there is no I-class variant of chSchReschedule_() ?

Or put differently, if I use I-class variant of chEvtSignalI() / chThdResumeI() I seem to be in ISR-Context, but there is no I-class variant to reschedule, how do I do that?


Kind regards
Pascal

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Manual chSchRescheduleS() neccessary?

Postby Giovanni » Tue Feb 06, 2018 3:59 pm

Hi,

Rescheduling is done automatically on ISR exit, if required, in the epilogue code.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 10 guests