OSTimeSly parameter
OSTimeSly parameter
Hello all,
Something I cant understand when using the OSTimeDly, my issue is if I pass the value 0 ticks, the thread will go from the running state to a ready state (where in my understanding is OSTimeDly(0), will make the thread to sleep for 0 tick).
Can someone explain to me when I am not understanding right.
Thank you in advance
Something I cant understand when using the OSTimeDly, my issue is if I pass the value 0 ticks, the thread will go from the running state to a ready state (where in my understanding is OSTimeDly(0), will make the thread to sleep for 0 tick).
Can someone explain to me when I am not understanding right.
Thank you in advance
Re: OSTimeSly parameter
you cannot sleep for 0 ticks. minimum is 1.(where in my understanding is OSTimeDly(0), will make the thread to sleep for 0 tick
Re: OSTimeSly parameter
Yeah I found that in the documentation, but my sleep is calculated. this is why i have to sleep to 0 ticks sometimes.
this is what happened when i slept to 0 ticks , the thread changed the state to ready. is this what it says in the doc cuz i could not find such a thing.
Thanks
this is what happened when i slept to 0 ticks , the thread changed the state to ready. is this what it says in the doc cuz i could not find such a thing.
Thanks
Re: OSTimeSly parameter
If you need to sleep for 0 ticks, it sounds like you might want to consider changing you code to perform the same task but in a different way to avoid this.but my sleep is calculated. this is why i have to sleep to 0 ticks sometimes.
Maybe if you explain what you are doing, we can help you get around this.
Re: OSTimeSly parameter
seulater wrote:If you need to sleep for 0 ticks, it sounds like you might want to consider changing you code to perform the same task but in a different way to avoid this.but my sleep is calculated. this is why i have to sleep to 0 ticks sometimes.
Maybe if you explain what you are doing, we can help you get around this.
I was just trying to understand why this happens when i sleep for 0 ticks, thanks for your help.
Re: OSTimeSly parameter
Maybe someone else can explain it. But be aware to use OSTimeDly(0) is not recommended.I was just trying to understand why this happens when i sleep for 0 ticks, thanks for your help.
Re: OSTimeSly parameter
In all the other OS calls, semaphore, fifo, mbox etc... 0 is the flag to wait forever.....
So OSTimeDly(0); is wait forever.....
The time tick timeouts for all RTOS waits are all handled with exactly the same code....
If the timeout value is 0, do nothing, if it decrements from 1 to 0 then wake the task.....
Actual code that does this is in nburn\system\ucos.c in Function
OSTimeTick()
.
.
.
if ( ptcb->OSTCBDly != 0 )
{
if ( --ptcb->OSTCBDly == 0 )
{
/* then release the task control block... */
}
}
So OSTimeDly(0); is wait forever.....
The time tick timeouts for all RTOS waits are all handled with exactly the same code....
If the timeout value is 0, do nothing, if it decrements from 1 to 0 then wake the task.....
Actual code that does this is in nburn\system\ucos.c in Function
OSTimeTick()
.
.
.
if ( ptcb->OSTCBDly != 0 )
{
if ( --ptcb->OSTCBDly == 0 )
{
/* then release the task control block... */
}
}
- Chris Ruff
- Posts: 222
- Joined: Thu Apr 24, 2008 4:09 pm
- Location: topsail island, nc
- Contact:
Re: OSTimeSly parameter
Paul
so does OSTimeDly(0) do:
1. release the task immediately (context release)
2. absolutely nothing
or
3. lock up the task forever
?
Chris
so does OSTimeDly(0) do:
1. release the task immediately (context release)
2. absolutely nothing
or
3. lock up the task forever
?
Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
Re: OSTimeSly parameter
OSTimeDly(0)
->>>> lock up the task forever
Now if you call
void OSChangeTaskDly( WORD task_prio, WORD newticks );
You can wake it up again....
So if you need a pool of worker tasks one might do that, but semaphore is probably cleaner...
->>>> lock up the task forever
Now if you call
void OSChangeTaskDly( WORD task_prio, WORD newticks );
You can wake it up again....
So if you need a pool of worker tasks one might do that, but semaphore is probably cleaner...
Re: OSTimeSly parameter
thank you guys i really understand it better now
. thanks again
