[En-Nut-Discussion] Should drivers yield explicit?

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Mon Jul 16 12:14:54 CEST 2012


>>>>> "Ole" == Ole Reinhardt <ole.reinhardt at embedded-it.de> writes:

    Ole> Hi Uwe,
    >> in my CANBUS driver for the STM32, the normal case is that the
    >> message gets loaded to the fifo and the function return immediate. In
    >> that case, there is no scheduling point and the calling thread keeps
    >> control.  Should a NutSleep(O) or NutThreadYield() get inserted in
    >> that case?

    Ole> I don't see any reason why? But you should implement the case where
    Ole> the FIFO is full and your calling thread has to wait until there is
    Ole> a free buffer available again.

    Ole> Anyway I would vote to mark functions with possible scheduling
    Ole> point in the documentation but don't have a good idea yet how this
    Ole> could be done in an intelligent way...

The code yields while waitimg:

    while ((rc = StmCanSendMsg(bus, frame)) == CAN_TXBUF_FULL)
    {
        NutEventWait(&(ci->can_tx_rdy), NUT_WAIT_INFINITE);
    };

-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------


More information about the En-Nut-Discussion mailing list