Shop OBEX P1 Docs P2 Docs Learn Events
lockset stalls? — Parallax Forums

lockset stalls?

TinkersALotTinkersALot Posts: 535
edited 2013-04-30 20:15 in Propeller 1
Hi -- Here is what I am doing (wrong?).

1. I have an object "B" that is started in a cog that calls "locknew" in its "start" function. All this is fine -- no worries
2. "B" has a long variable that is declared in the VAR block for the object.
3. The object "B" has a "getter" and a "setter" for the variable that uses "repeat until not lockset..." , then variable access (read or write), followed by "lockclr"
4. This variable should be "periodically set" by the "initial program" running in cog 0 it attempts to do this by using the "setter" described above.

What I think I am seeing are exceedingly long stalls (on the order of tens of seconds") when the two cogs are running. If I disable the "set" from the cog 0 program, then the "B" object (running in its own cog) runs at full tilt -- so the code in the "getter" and "setter" should be good in so far as how they lock is treated. So what could account for these stalls? Is there something special that needs to be done with regard to how this "shared memory" is declared ?

Any hints would be greatly appreciated.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-04-30 12:33
    Could you attach your code?

    This probably isn't the problem, but as I've recently discovered, a locknew does not guarantee a lock that is in the false (clear) state. Instead, it could be in either state.
  • TinkersALotTinkersALot Posts: 535
    edited 2013-04-30 12:56
    I can't attach it now, but I will try later this evening (PST -- GMT - 8 ) -- but you've got me thinking -- I am assuming that locknew is returning a valid index (as this is the only lock in the system) -- that could be an error?
  • TinkersALotTinkersALot Posts: 535
    edited 2013-04-30 19:46
    okay this is solved. Made 2 changes and now we are golden. First change: (probably not the fix) was to check for a valid lock ID from the call to locknew. Second change: (could this be the weaknesses of weakly typed languages rearing its head?) changed the var type for the lock id from long to byte (my wager is on this one)
  • kuronekokuroneko Posts: 3,623
    edited 2013-04-30 20:15
    Second change: (could this be the weaknesses of weakly typed languages rearing its head?) changed the var type for the lock id from long to byte (my wager is on this one)
    Lock IDs only use 3 bits (0..7) so long vs byte doesn't make a difference here (not counting a check against -1). Anyway, post your code so this can be sorted out.
Sign In or Register to comment.