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
  • 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?

Reply
  • 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?

Children
  • 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.