View previous topic :: View next topic |
Author |
Message |
dansimon
Joined: 12 Feb 2007 Posts: 2
|
How can I time out during an rtos task? |
Posted: Mon Feb 12, 2007 8:00 am |
|
|
I have an rtos task that I need to exit if it takes too long. I tried using the rtos_overrun function to see if it takes too long, but it does not seem to work unless I first yield to the rtos, in which case my task will not re-enter until it is next scheduled. I can use a timer but then I have to keep track of my oscillator frequency and the number of timer rollovers, which is okay but not that clean. Any ideas? Thanks. |
|
|
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
|
Posted: Mon Feb 12, 2007 8:08 am |
|
|
The timer method popped into my head when I saw the title of your post and it seems a good solution. Can you give an estimate about the normal execution time of the task and the time after which you can consider it timed out? |
|
|
dansimon
Joined: 12 Feb 2007 Posts: 2
|
|
Posted: Mon Feb 12, 2007 8:21 am |
|
|
One task needs to time out after about 100 ms, another after about 30 sec. So if I set up Timer1, say, to roll over every 100 ms, then one rollover would timeout my first task, and 300 rollovers would timeout my second task. I think that would work fine, but with all of the built-in rtos functions that CCS has I thought there would be some more automatic way to do it. This is the first time I am using the rtos. |
|
|
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
|
Posted: Mon Feb 12, 2007 3:06 pm |
|
|
Yes, timers would do the job. Easy to implement.
CCS' RTOS is a rather simple cooperative multitasking scheduler, mostly because of the limitations of the PIC's architecture, but it does it's job very well. You can't ask too much from it though.
rtos_overrun() is for checking if a task has exceeded its allocated execution time. I don't see how you can use that here. |
|
|
|