change thread sleep setting

Hello.The API doesn’t specify if it’s possible to/how change the sleep time in a thread. case: Thread1 sleeps for 100 ms, Thread2 need Thread1 to execute asap, is it possible for Thread 2 to change the sleep time from 100 (or what the current current sleep time is on Thread1) to 0, so that Thread1 will start to execute asap ?

more … Is the sleep_time defined in TX_THREAD_STRUCT ? what parameter defines sleep time ? TX_INTERNAL_TIMER tx_thread_timer;?

Maybe there’s a good reason, but why don’t you simply implement the sleep by waiting for an event with a timeout of 100 mS. When you need to wake thread 1 you simply signal the event from the other thread. Other signals like semaphore can also be used.

Isn’t there a wake() function that can be used to wake up a sleeping thread? sleep() should also return a unique value when a thread gets woke up.

As Thomas mentioned the best solution is to use eventflags for this problem. See the tx_event_flags_* routines in the kernel guide. The return value from tx_event_flags_get will tell you if the thread was “awaken” by the other thread or if was a timeout.

Another wait is to use tx_thread_wait_abort function call. It will abort the sleep currently on the specified thread. Note that it dont work if the thread has been paused with the suspend call. But for the sleep mentioned it works fine. I use it in my code some places.