This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SEM_post() and SEM_ipost()



Hello everybody!

I've got a simple question about the SEM_post() and SEM_ipost() functions. In the BIOS 5.x api documentation the old SEM_ipost() function is no longer mentioned, but we still call SEM_ipost() in ISR contexts and it seems to work. Are we allowed to use the old SEM_ipost() function or should we replace it by the new SEM_post(). What exactly is the difference between those two functions. We also call SEM_ipost() in a task context. Does this harm our system?

Thanks

  • In earlier version of BIOS (4.9 and earlier, I believe, but don't quote me on the version), SEM_ipost() was a special API that could only be called from ISR context.  It was slightly faster than SEM_post() since it assumed it was called from ISR context and was therefore able to save a couple of 'if' tests.    It was _not_ safe to call SEM_ipost() from TSK level!  User had to be very careful which context they were running in and decide which API to call.   SEM_post(), on the other hand, can be called from any context (HWI, SWI, or TSK).

    Because we had several cases where users were not using SEM_ipost() correctly, we decide to remove this API from the documentation and only document SEM_post().  The few cycles of saving that SEM_ipost() provides were not worth documenting and debugging the special case.

    I think the only downside of calling SEM_ipost() from TSK level is that the semaphore post will not happen immediately.  SEM_ipost() queues up the post until the ISR returns.  If you call from TSK level, the post will be deferred until the next system call.  So, if you post a semaphore using ipost(), the semaphore won't be posted until another interrupt is taken or the calling TSK makes a system call.

    I would recommend changing all of your calls to 'SEM_post()' to avoid these special cases and associated confusion.

    Thanks,
    -Karl-