Shop OBEX P1 Docs P2 Docs Learn Events
Does a PUB function be called from two cogs at the same time? — Parallax Forums

Does a PUB function be called from two cogs at the same time?

jmbertoncelli@USAjmbertoncelli@USA Posts: 48
edited 2008-10-19 21:00 in Propeller 1
Hello,

Does a "PUB" function be called from two cogs at the same time?
If yes does this mean that the local variables are allocated on the STACK? and of course each "call" will have local function variables allocated on a different memory location....?

Thanks.
·


·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-19 20:52
    Any function in Spin can be called from two cogs at the same time. Any local variables will be allocated in that cog's stack as well as things like return addresses, parameters, etc. Clearly, if the function (method) uses any global variables, care will need to be taken so that simultaneous access to these will work as expected. The LOCKxxx statements can be used as well as other techniques well known in multiprocessor programming (like single producer/ single consumer).
  • jmbertoncelli@USAjmbertoncelli@USA Posts: 48
    edited 2008-10-19 21:00
    Thanks! I was expecting something like that...

    have a great day.

    jm
Sign In or Register to comment.