Shop OBEX P1 Docs P2 Docs Learn Events
Atomic reads and writes? — Parallax Forums

Atomic reads and writes?

John AbshierJohn Abshier Posts: 1,116
edited 2006-04-19 21:04 in Propeller 1
I am trying to understand Propeller multiprocessing.· I have multiple cogs running.· At any one time only one cog can address main memory.· In Spin is a read and a write an atomic operation?· In other words if cog1 is writing a value to memory (an assignment statement) and cog2 wants to read that value, is this operation safe for bytes? 32bit words?· Or will cog2 get part of the old value mixed with the new value?

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-04-16 19:54
    The hub controls access to the main memory from each cog. Each takes a turn. A data transfer is 4 bytes (32-bit) so if you do not exceed that size a complete write by one cog will be done before another cog reads it. This is very powerful for multiple cogs passing information to be processed!

    If you use an array, you will probably need to use either an I/O or another memory location to indicate when writes are complete.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • cgraceycgracey Posts: 14,133
    edited 2006-04-17 11:21
    You can read and write longs (32 bits), words (16 bits), and bytes (8 bits).

    The HUB singulates accesses by the COGs so that there are no simultaneous access collisions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • NameName Posts: 3
    edited 2006-04-19 18:15
    Hi Everyone,

    Okay.· How about semaphores?· For example, how would one Cog grab a semaphore while the others miss?·

    Thanks,
    Bye,

    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-04-19 19:13
    Read my explanation in this thread: http://forums.parallax.com/showthread.php?p=572185

    Its up to each cog to obey the fact that a semaphore is locked.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
  • NameName Posts: 3
    edited 2006-04-19 19:55
    Hi Everyone,

    I read your response in the other thread. Thank you!

    Does anyone know when the full documentation is going to be released?
    For example, their HLL is cute (yet another HHL) but what do the actual opcodes look like?


    Thanks,
    Bye,
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-04-19 20:01
    They are very similiar to other RISC processors (with about a dozen or so unique instructions), the documents will likely be released the day of shipping. Almost all the unique instructions have a direct analog to a similar instruction in spin (wait instructions, hub operations etc).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10
  • NameName Posts: 3
    edited 2006-04-19 21:04
    Thank you for the speedy reply.

    Bye
Sign In or Register to comment.