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.

How to make a task wait?

Other Parts Discussed in Thread: SYSBIOS

Hello,


I'm using TI-RTOS, and I would like to make some tasks to stop (while i'm not needing them) and then make them wake-up again.


Can someone tell if that is possible? And if so, how? I saw the functin osi_SyncObjWait / lock, and unlock, But i don't know what to send tot the function  how how should I use it.

Thanks

  • It depends on your use case.
    If you know you want the task to resume every few milliseconds or so, you can call Task_sleep() with the amount of clock ticks you want your Task to sleep. If all your tasks are the same priority, and you want to cycle through them, you can call Task_yield().

    Alternatively, if you want to wake up a task from another task or interrupt, it may be better to use a semaphore. With a semaphore, you can call Semaphore_pend() on the task you want to stop (it will enter a blocking state), and Semaphore_post() to remove the block. That's a bit of an overview, so you may want to consult the SYSBIOS API guide or User Guide to get more details about creating and using semaphores. A copy of both are provided in the docs folder in your SYSBIOS install, or the copy of SYSBIOS provided in the products directory of your TIRTOS install.

    Regards,
    Gilbert
  • But in the osi.h there are some functions like: ObjCreate, ObjWait, ObjLock and ObjUnlock, this cannot be used for what I want?

    Like when creating the function I can create an handler, and then pass the handle of the task to the ObjCreate, and after that use ObjLock and Unlock?

    Thanks
  • For someone struggling with this question like I was, here a very brief explanation:

    You should first create and object to every task you want to suspend and resume. To do that use the osi_ObjCreate(OBJECT_NAME) function.

    Then, in all the tasks you should use the function:

    osi_ObjWait(ObjectName, OSI_WAIT_FOREVER);

    This way the function will be suspended until you give a signal to it.

    To give a signal you should use:

    osi_SyncObjSignal(ObjectName);

    Bassically it sends a signal to all the tasks waiting for the object

    To suspend the tasks use:

    osi_SyncObjClear(ObjectName);

    Hope it's beeen usefull to anyone struggling like I was.