To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 496
495  |  497
Subject: 
Re: Two motors at the same time... It is possible?
Newsgroups: 
lugnet.robotics.nxt
Date: 
Mon, 19 Feb 2007 02:29:53 GMT
Viewed: 
13521 times
  
In this case you have two threads running concurrently which both call
into the same subroutine.  That's a recipe for disaster.  Exactly what
will happen when two threads simultaneously call the same subroutine
is undefined.


I understand his confusion. Not allowing separate threads to call the
same subroutine is certainly unexpected. The concept of "thread"
conventionally involves separate stacks for local variables (and a
shared global state -- unlike separate processes that keeps both
separate -- and I'm sidestepping shared memory and other fancy stuff
at the moment.)

Having to keep threads from calling the same subroutine (I'm having a
flashback to pre-stack OS360 FORTRAN :-) makes creating reliable code
_very_ difficult. Essentially it prevents the use of _any_ library
functions in threaded code! (Unless you _know_ it is safe... sigh...
scratch that... that level of flow analysis in realtime code is beyond
amateur programmers and probably most professional ones as well. At
least without heavy duty tools to assist.)

No critique against NXC, but I'm reminded of Monty Python's "Crunchy Frog" skit:

...................
Inspector Praline: [...]
         Now how about this one. (superintendent enters)
         It was number five, wasn't it? (superintendent nods) Number five,
         ram's bladder cup. (exit superintendent) What kind of confection
         is this?

Milton:  We use choicest juicy chunks of fresh Cornish ram's bladder,
         emptied, steamed, flavoured with sesame seeds whipped into
         a fondue and garnished with lark's vomit.

Praline: Lark's vomit?

Milton:  Correct.

Praline: Well it don't say nothing about that here.

Milton:  Oh yes it does, on the bottom of the box, after monosodium
         glutamate.

Praline: (looking) Well I hardly think this is good enough. I think it
         would be more appropriate if the box bore a large red label
         warning lark's vomit.
...................

So, maybe a large red label warning saying "threads may not call the
same subroutine simultaneously"?


--j



Message has 2 Replies:
  Re: Two motors at the same time... It is possible?
 
(...) Or maybe just wrap the calls inside a mutex, so at least the behaviour is defined, if not optimum. Many of the NBC/NXC macros do exactly that, maybe all of them should? ROSCO (18 years ago, 19-Feb-07, to lugnet.robotics.nxt)
  Re: Two motors at the same time... It is possible?
 
(...) Hi Johan, While you're dealing with very practical questions here, I thought I'd throw a paper into the mix: (URL) was presented in the ACM conference on Programming Language Design and Implementation (PLDI) in 2005. It's a nice paper (...) (18 years ago, 19-Feb-07, to lugnet.robotics.nxt)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in NXT programmable brick

 
Verified and Trusted Team of Hackers
12 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR