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
Multiple tasking question
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
twesthoff



Joined: 17 Mar 2006
Posts: 199
Location: Fredericksburg, VA

Posted: 16 October 2007, 20:14 PM    Post subject: Doc correction Reply with quote

Don,
FYI, in the manual on the ResetProcessor page, under Compatibility it says:
BasicX does not support Register.ResetFlags.
Tom
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 16 October 2007, 20:44 PM    Post subject: Re: Doc correction Reply with quote

twesthoff wrote:
BasicX does not support Register.ResetFlags.

I believe that it is true that the BasicX compiler does not support Register.ResetFlags and that Register.ResetFlags is not available in BasicX compatibility mode of the ZBasic compiler. Do you have any information to the contrary?
Back to top
twesthoff



Joined: 17 Mar 2006
Posts: 199
Location: Fredericksburg, VA

Posted: 16 October 2007, 21:07 PM    Post subject: Multiple tasking question Reply with quote

dkinzer wrote:
Do you have any information to the contrary?
It seemed to me that it was not applicable to that page, since it it did not mention it anywhere on that page. The title of the page is ResetProcessor, not Register.ResetFlags. I thought you meant it did not support ResetProcessor. There is nothing on the page that would indicate they are related except the word Reset is common to both of them.
I just thought it may have been a typo and you would like to know about it.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR

Posted: 16 October 2007, 21:29 PM    Post subject: Re: Multiple tasking question Reply with quote

twesthoff wrote:
It seemed to me that it was not applicable to that page, since it it did not mention it anywhere on that page.
Actually, it does mention it specifying that Register.ResetFlags will indicate that a watchdog reset has occurred.
Back to top
twesthoff



Joined: 17 Mar 2006
Posts: 199
Location: Fredericksburg, VA

Posted: 16 October 2007, 22:15 PM    Post subject: Multiple tasking question Reply with quote

dkinzer wrote:
Actually, it does mention it specifying that Register.ResetFlags will indicate that a watchdog reset has occurred.
My mistake, it just didn't seem consistant. I didn't know that ResetProcessor was supported in BasicX. Of course I have quit using all of my BX stuff long ago, so it doesn't matter.
Back to top
pjc30943



Joined: 02 Dec 2005
Posts: 220

Posted: 26 February 2008, 2:24 AM    Post subject: Reply with quote

Just updating this thread based on a new question of mine, to not require a new post when it's virtually the same as the present one.

Let's say two tasks call sub Common(), which should never be accessed more than once at the same time. Unfortunately this function is still called again while another task already has access to it, despite semaphore usage.

Any thoughts on what I'm doing incorrectly?

main:
Code:

public CommonSem as boolean
CommonSem = false


Code:

sub Common()
  debug.print "O"
  ...
  debug.print "F"
end sub


Both Task #1 and task #2 have this code:
Code:

...
do
  ...
  do until ( semaphore(CommonSem) )
    sleep 0.0
  loop
  call Common()
  CommonSem = false
  ...
loop


This seems like it should adequately lock Common(), yet the following string is still seen in the terminal--indicating a second call before the first one terminates. When correct, the pattern should always be OFOF only, if Common was called strictly in succession.
Code:

...
O
O
F
F
...


EDIT: since common() exits before all characters in the queue are physically sent out to the terminal, "OOFF" may not indicative of what happens--though queue order should still be preserved. Either way, other symptoms also show that both tasks are accessing at the same time.
Back to top
mikep



Joined: 24 Sep 2005
Posts: 771
Location: Austin, TX

Posted: 26 February 2008, 2:55 AM    Post subject: Reply with quote

pjc30943 wrote:
Just updating this thread based on a new question of mine, to not require a new post when it's virtually the same as the present one.
I could not reproduce the problem using the sample code you gave. Perhaps you can give a cutdown example that shows the problem. I suggest starting a different thread.
Back to top
Don_Kirby



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 26 February 2008, 2:57 AM    Post subject: Reply with quote

It seems to me that your usage is correct. My suggestion is to add some delay (perhaps 0.5 second) after each call to Debug.Print to give the queue time to empty, and to slow the process down to a more human speed. It may help to uncover the problem.

Code:
sub Common()
  debug.print "O"
  Call Sleep(0.5)
   ...
  debug.print "F"
  Call Sleep(0.5)
end sub


Alternatively, you could wait for only the amount of time needed to empty the queue, therefore negating any effect of baud rate.

Code:
sub Common()
   debug.print "O"
   Do While StatusQueue(Register.TxQueue)
      Call Sleep(0)
   Loop
   debug.print "F"
   Do While StatusQueue(Register.TxQueue)
      Call Sleep(0)
   Loop
end sub


-Don
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
Goto page Previous  1, 2
Page 2 of 2

 


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