Shop OBEX P1 Docs P2 Docs Learn Events
Float32Full Question — Parallax Forums

Float32Full Question

jagrifenjagrifen Posts: 36
edited 2011-06-16 11:12 in Propeller 1
Does anyone know what happens when multiple cogs make use of one instance of Float32Full at the same time? I guess I am asking if Float32Full has any collision avoidance built in? Any good suggestions on dealing with this other than calling two instances of Float32Full (which would require two cogs)? I've also considered switching to F32. Does that work any better?
Thanks for your help.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-16 07:09
    None of the floating point objects have any locking built in to prevent problems with use from several cogs at once. You're responsible for doing that. It's generally left out because it adds a small amount of overhead, both in terms of execution time and memory, but more if it's added in a generalized way, and it's rarely needed. The Propeller Manual shows how to use the various LOCKxxx calls in Spin, but the details of how and where to put the calls depends on what your program is doing and how the cogs interact.
  • jagrifenjagrifen Posts: 36
    edited 2011-06-16 07:20
    Thanks, Mike. That's what I figured. I guess it's time I got around to learning how to use the LOCK commands.
  • jagrifenjagrifen Posts: 36
    edited 2011-06-16 08:50
    So I think I understand the Lockset and Lockclr commands but I am a little unclear on the locknew command. Assuming I am only going to create one lock and I have multiple cogs and one instance of Float32Full, would it be correct to just say something like

    VAR byte SemID

    PUB Initialize
    SemID := Locknew
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-16 08:54
    Yes.

    The primary reason to have LOCKNEW at all is that you might use library objects which use a lock internally and you don't necessarily know which one or even if it does or not. Using LOCKNEW, the hardware keeps track of which locks are in use so you don't have to do it.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-06-16 11:12
    Float32Full is so last decade.

    Try Lonesock's F32.

    It's drop-in compatible, only uses one cog and is faster than Float32Full. It also keeps the inside of your Propeller chip clean.

    Duane
Sign In or Register to comment.