We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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?
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.
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?
There are several limitations with the bit-band method:
- the semaphore data are limited to bit type. With exclusive accesses you can have byte, halfword and word size. (For simple mutex operations bit data is fine).
- Since bit band data is limited to 32-bit, and use each bit for each application task, so limited to 32 tasks to share the data. Exclusive accesses don't have this limitation.
- Bit band can only be used in bit band regions. Exclusive accesses can be used in other memory space.
- Bit band is not supported in Cortex-M7 processor (chip designer can add bit band on the peripheral space using additional bus level component).
In terms of cost and speed they are fairly similar. Given that semaphore and mutex don't happen frequenctly, even if one of the methods is faster the benefit is small.
In terms of complextity, you can do bit band easily with C, and for exclusive accesses you need to use intrinsic functions.
Hope this helps.
regards,
Joseph
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.
Thanks. Understood.
I think you have gotten answered by Joseph. If it is correct, please click "Correct Answer" for the Joseph's answer and close this post.
Note: If you don't have Bit Band, then you can still use 4 bytes of a 32-bit word as a 'mini bitband' functionality.
There is also another option which was not mentioned: You could disable interrupts, modify the value and enable interrupts.
Disabling interrupts will of course disturb the program flow, but it will not stop timers, etc; it'll just postpone the execution of the interrupt.
The pending bits will still be set, so you will not lose any interrupt servicing.