Shop OBEX P1 Docs P2 Docs Learn Events
Question: PASM, COG, and Static methods — Parallax Forums

Question: PASM, COG, and Static methods

Mike GMike G Posts: 2,702
edited 2011-03-03 02:49 in Propeller 1
I have PASM running in a COG. I'd like to share the COG process across multiple objects, like a static method. I'd have to carve out HUB memory so the other methods could access the PASM process through interface pointers. That would create dependencies between objects at run time.

I'm thinking that I'll have to have as many instances of the PASM processes (COGs) as I have PASM consumer objects. Is that correct?

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2011-03-02 06:01
    Create an object for the PASM image, with a method that returns the address of the PASM image. You can then include that object in as many objects as you want, but only one instance of the PASM image DAT block will be written to the Hub RAM image.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-02 14:24
    If I understand you correctly:
    You have one piece of PASM-code. This uses some HUB RAM to check what it should do - let's call that the PASM interface RAM. And now you want this to be used by several objects.

    Well ... it's not necessary to have n PASM COGs for n "users".
    1. For example you could use locks to synchronize the access to the PASM interface RAM.
    2. Or you could have n "PASM interface RAM" sections. The PASM simply checks these one after another. Each object only works with it's own interface.
  • Mike GMike G Posts: 2,702
    edited 2011-03-02 17:27
    Thanks All;

    I was struggling with how to implement the interface to a single COG. localroger, that makes sense, I just need to create some test code to solidify my understanding.

    MagIO2, yeah I'll have to lock memory.
  • agsags Posts: 386
    edited 2011-03-02 17:35
    localroger wrote: »
    Create an object for the PASM image, with a method that returns the address of the PASM image. You can then include that object in as many objects as you want, but only one instance of the PASM image DAT block will be written to the Hub RAM image.

    Help, I'm horribly lost. What does it mean to create an object with a PASM image? Does that mean the object consists of nothing but a DAT block?
    And what is the address of a PASM image? The PASM image is in cog RAM, and that's not accessible by SPIN code. Do you mean proving the address of the first symbol (or entry point) in the DAT block in hub RAM? How would one use that for this purpose?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-03 02:49
    PASM image = DAT section which holds the PASM program. Unless you did not start the PASM program the code is ONLY available in HUB RAM and is accessible by SPIN. When doing a COGNEW the PASM code is copied from HUB RAM into COG RAM. This copy is no longer accessible by other COGs, which includes the COG that's running SPIN.

    For each object you need at least one PUB. In this case it would be a getPASMAdr function which then returns the address of the PASM-code.
    All the programs which use this object can then call getPASMAdr and do a COGNEW on their own.

    But as told above, this requires one COG to run the PASM code per "user".
Sign In or Register to comment.