 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-MR32R-020901D
Notes on Real-Time OS M3T-MR32R
|
Please take note of the following items in using real-time OS M3T-MR32R for the M32R family of MCUs:
- Problem on using the tsnd_mbf and snd_mbf system calls
- Elaboration on Section 3.5.8 "Messagebuffer" in the user's manual
- Problem on Using the tsnd_mbf and snd_mbf System Calls
- 1.1 Versions Concerned
- All the versions from M3T-MR32R V.3.00 Release 1 through M3T-MR32R V.3.40 Release 1
- 1.2 Description
- When system call tsnd_mbf or snd_mbf is issued, M3T-MR32R writes a transmit message into the ring buffer. At this time, M3T-MR32R may corrupt data in memory by writing the transmit message across the buffer boundary. If data has been corrupted, issuing system call rcv_mbf, trcv_mbf, or prcv_mbf to receive a message will result in an incorrect message being read.
- 1.3 Conditions
- This problem occurs if the following three conditions are satisfied:
| (1) |
When system call tsnd_mbf or snd_mbf is issued, task A enter the waiting state for writing a transmit message into the ring buffer provided that the available buffer capacity is not enough to accommodate the message. |
| (2) |
Task B's reception of messages releases task A from its waiting state by increasing the available buffer capacity. |
| (3) |
However, task A writes a transmit message across the end of the buffer area. |
|
| [Note] |
The beginning address of the buffer area (4-byte data) and the offset value of the address at which the next transmit message (including size information) is written from the beginning address of the buffer area (also 4-byte data) are given by the contents of the memory locations referenced by
__D_MBF_BASE[ID number - 1] and
__MBF_write[ID number - 1] respectively. |
- 1.4 Example
- If the write of a transmit message reaches the end of the buffer area, the remaining message is not written from the beginning of the buffer but written across the buffer boundary.

- Note, however, that the two cases shown below do not meet Condition 3 above, so that the problem does not arise.
- [Case 1]
- When the write of a message is completed at the end of the buffer area, the next transmit message is properly written from the beginning of the buffer area.

- [Case 2]
- When the write of size info begins 4 bytes before the end of the buffer area, the message body is properly written from the beginning of the buffer area.

- 1.5 Workaround
- This problem will be circumvented in either of the following ways:
| (1) |
Send messages such a way that messages can just fill the buffer area. When sending messages each of which is shorter than 24 bytes wide, for example, transmit each as a 24-byte message.
At this time, buffer size must be (24 + 4 [size info]) * n bytes, where n is an arbitrary integer.
For example, when n is 4, buffer size occupies 112 bytes. |
| (2) | Use system call psnd_mbf instead of snd_mbf or tsnd_mbf. |
- 1.6 Schedule of Fixing the Problem
- We plan to fix this problem in our next release.
- Elaboration on Section 3.5.8 "Messagebuffer" in the user's manual
- 2.1 Manuals Concerned
- The user's manuals included with all the versions from M3T-MR32R V.3.00 Release 1 through M3T-MR32R V.3.40 Release 1
- 2.2 Description of Elaboration
- When sending a message using message buffer functions, M3T-MR32R writes 4-byte size information first and then the message body into the ring buffer. If the previously transmitted message did not end at a 4-byte boundary, the size info of the message next to be sent is written from the next 4-byte boundary.
So, a transmit message consumes alignment adjust + 4-byte size info + message body (in bytes) in the buffer memory. Note that no receive messages contain size information.
- [Example]
When message B of 12 bytes wide is sent after message A that was not completed at a 4-byte boundary, the size info of message B is first written from the next 4-byte boundary and then the body of message B is written successively.
|
 |