task give up it's time tick in uc/os

I want to konw if there's a method in uc/os to make a task give up i'ts tick to a lower priority task?

I have a hight prioriy task that must be run 1 time pre ms. but after it finish, I want it give remain tick times to the lower priority task.

can uc/os do that and how? $B!J(Bsorry for my poor english!$B!K(B

Reply to
vinge.ven
Loading thread data ...

Presumably after the task has executed it makes an API call to say "run me again 1ms after I last started" (in FreeRTOS this would be vTaskDelayUntil(), I don't know what the uCOS equivalent is). Once this function is called the calling task would be placed in a Blocked state and not consume any more processing time until its delay period expired - so what you want to happen will happen automatically.

I'm not even sure that uCOS will implement a time slicing scheme in any case as each task must have a unique priority - so timeslicing would not make any sense. Again this is different to FreeRTOS where you can assign unique priorities to each task, or allow tasks to share priorities - also you can choose to use time slicing or not.

--
Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for microcontrollers.  More than 7000 downloads per month.

+ http://www.SafeRTOS.com
Certified by TUV as meeting the requirements for safety related systems.
Reply to
FreeRTOS.org

Many methods are available. Simplest may be to do a delay for 1 ms. This assumes your tick rate OS_TICKS_PER_SECOND has enough resolution, at least

1000 ticks per second. If this is the case then an OSTimeDly(1) would be a 1 ms delay. During the delay the task is in a NOT ready state, so any lower priority task will run.

A second approach may be to have a timer generate an interrupt on a 1 ms interval. The ISR could then signal a semaphore (or about any other mechanism) OSSemPost(semaphore1) that the high priority task is pending on. Such as OSSemPend(semaphore1). Make sure to create the semaphore before trying to use it.

Scott

Reply to
Not Really Me

This is a very common job that a real time kernel must handle. If you want the high priority task to run in lock-step with the 1ms clock, then make some process that runs in interrupt-land set a semaphore on the 1ms clock (I'm not sure if Mucos uses "semaphore", "event", "flag" or some other terminology -- I'll leave that as an exercise for you). Then make the high-priority task pend on that semaphore.

The consequence of this will be that when the 1ms clock pops off the semaphore will be set, the high-priority task will run, then when it calls the OS to pend on the semaphore again it will block. Then other, lower priority, tasks will be able to run.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

or use an OS_timer

Reply to
bigbrownbeastiebigbrownface

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.