Shop OBEX P1 Docs P2 Docs Learn Events
Cogs trampling over one another? — Parallax Forums

Cogs trampling over one another?

HughHugh Posts: 362
edited 2013-07-03 03:09 in Propeller 1
What are the possible ways that one cog could trample over others and stop them working? If I start a cog with COGNEW, '6' is returned (so I haven't run out of Cogs) but other processes in other Cogs appear to be halted/not start.

Both referencing the same pin?
Both referring to the same variables?

Anything else?

Thanks
Hugh

Comments

  • cavelambcavelamb Posts: 720
    edited 2013-07-02 13:24
    With so little to go by, most likely, lack of stack space...
  • HughHugh Posts: 362
    edited 2013-07-03 00:38
    If I uncomment the line marked 'This line', below, the other cogs appear to stop.

    I have pared the declared stacks to the bone. Stack/Free is 4584 longs according to the F8 ObjectInfo (Program 2907 longs, Variables 697 longs)

    Having started all of the cogs I need to, '6' is returned so I haven;'t run out of cogs.

    I have deleted 50 longs worth of code.

    Even having freed up more space, uncommenting the line marked 'This line' stops everything. In fact, even a waitcnt in that line stops things.
    [B]dira[/B][PinShoData]~~                                       'Used to drive an LED
        [B]dira[/B][PinData]~                                          ' Input
        fastFlash(PinShoData, 10)                         ' PUB that flashes LED ten times. This works
        
        repeat 5
            '![B]outa[/B][PinShoData]                                 '<------- This line
         
    

    I have added the following PUB and called this via COGNEW before any other cogs are started:
    [B]PUB [/B]Donothing | HWN
    
    
    HWN := 3
    

    The number returned by the last cog to start is still 6?

    Is there a 'head-scratching' icon?
  • kuronekokuroneko Posts: 3,623
    edited 2013-07-03 00:45
    Hugh wrote: »
    Stack/Free is 4584 longs according to the F8 ObjectInfo (Program 2907 longs, Variables 697 longs)
    This is only relevant for the primary cog (usually the main program). All other started SPIN cogs require unique, sufficiently sized VAR/DAT based stacks. It would really help to see the code ...
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-03 01:08
    My favorite way of letting cogs trample each other is to set dira or outa high with one cog and then start another cog which attempts to set the same pins as input or low.

    I've learned to make it a general policy to only set pins from a single cog.

    Are you using any video display objects? I know there's at least one video object that doesn't declare all the memory it uses.

    As usual, I agree with kuroneko. It would really help if you posted your code.
  • HughHugh Posts: 362
    edited 2013-07-03 01:21
    OK - I am an idiot... [Head-slapping icon]

    Having called COGNEW several times I forgot to take into account that 'FullDuplexSerial' (called twice) starts a new cog - there won't be one available.

    Does anyone know if 'Simple_serial' starts a new cog (it doesn't say it does)?

    Off to kick myself - hard!

    Thanks
    Hugh
  • HughHugh Posts: 362
    edited 2013-07-03 02:36
    Hugh wrote: »
    Does anyone know if 'Simple_serial' starts a new cog (it doesn't say it does)?

    No, it doesn't and everything works fine now.

    Schoolboy error...
  • Heater.Heater. Posts: 21,230
    edited 2013-07-03 03:09
    If you are running out of COGs there is a serial port object in OBEX that will drive 4 serial ports.
Sign In or Register to comment.