| Author |
Message |
stevech
Joined: 23 Feb 2006
|
|
Posted: 20 September 2006, 5:37 AM Post subject: TCB links |
|
|
Don
If you would, please point out my error in this code which attempts to walk the list of active tasks. It prints out poo-poo in an infinite loop. I assume that the list ends with a null pointer.
| Code: | sub showTaskList()
dim p1 as unsignedinteger, p2 as unsignedinteger
p1 = register.TaskMain ' TCB address
Do
debug.print cStrHex(p1);" ";
p1 = ramPeekWord(p1+3)
loop while p1<>0
debug.print
end sub |
EDIT update: looks like end of list is not a zero but rather a pointer to the head of the list. So I found the answer. Now to figure a way to print a task name (sub name). I guess that's up to my own devices.
| Code: | sub showTaskList()
dim p1 as unsignedinteger, p2 as unsignedinteger
p1 = register.TaskMain
p2 = p1
Do
debug.print cStrHex(p1);" ";
p1 = ramPeekWord(p1+3)
loop while (p1 <> p2)
debug.print
end sub |
Last edited by stevech on 20 September 2006, 6:04 AM; edited 1 time in total |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 20 September 2006, 6:01 AM Post subject: Re: TCB links |
|
|
| stevech wrote: | | looks like end of list is not a zero but rather a pointer to the head of the list. |
Yes, that is the way that it is documented. The task list is a circular linked list. The application note AN-209 contains similar code that displays the status of all existing tasks. Basically, you have to record where you started and iterate until you return to that spot.
| Code: | sub showTaskList()
dim p1 as unsignedinteger, p2 as unsignedinteger
p1 = register.TaskMain ' TCB address
Do
debug.print cStrHex(p1);" ";
p1 = ramPeekWord(p1+3)
loop while p1<>register.TaskMain
debug.print
end sub |
|
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
|
|
Posted: 20 September 2006, 6:05 AM Post subject: |
|
|
Ah, thanks.
I updated the top of this thread.
I'll go read that AN.
read before leaping, I must remind myself! |
|
| Back to top |
|
 |
|