Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
TCB links

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
stevech



Joined: 23 Feb 2006
Posts: 656

Posted: 20 September 2006, 5:37 AM    Post subject: TCB links Reply with quote

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
Posts: 2493
Location: Portland, OR

Posted: 20 September 2006, 6:01 AM    Post subject: Re: TCB links Reply with quote

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
Posts: 656

Posted: 20 September 2006, 6:05 AM    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group