This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What is better as mutex on Cortex-M4 - Bitband or LDREX/STREX

The two options are available.

What is the difference in respect of "cost" "speed" and "complexity" for the two method?

When we need more than few mutexs like that, say 100, is the answer different?

Parents
  • Hi amiry,

    is there an example to use the bitband for the synchronization? I think the bitband would not be used for the synchronization because we could not know the previous value of the bitband target area although the bitband initiates a read-modify-write transaction (i.e. atomic access). The previous value would show the transaction had succeeded or failed.

    Best regards,
    Yasuhiko Koumoto.

Reply
  • Hi amiry,

    is there an example to use the bitband for the synchronization? I think the bitband would not be used for the synchronization because we could not know the previous value of the bitband target area although the bitband initiates a read-modify-write transaction (i.e. atomic access). The previous value would show the transaction had succeeded or failed.

    Best regards,
    Yasuhiko Koumoto.

Children
  • As bitband performs RMW I guess it can serve as primitive mutex.

    You are right about don't know what was happend before, however, think of:

    Startup:

    Select a word and Assign bit1 to Task1, Assign bit2 to Task2...and so on

    Task1:

    Read all word, if <> 0 resource is taken

    Write task1 bit, atomic

    Read all word again

    if == excactly Task1.bit --> all well. resource is taken by task1.

    if <> excactly Task1.bit --> bad. not mine. Clear task1 bit, atomic

    try again.

    Ha?

  • Hi amiry,

    ok, thank you. I understood your method. It seems to be performed successfully. However the number of read and write times will be bigger than LDREX/STREX method. As Joseph Yiu said, the benefit of the bitband method would be small.

    Best regards,

    Yasuhiko Koumoto.