This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSP/BIOS Mailbox Bug?

Other Parts Discussed in Thread: CCSTUDIO

Hi.

 

First, I'm using DSP/BIOS 5.41 and EVMDM6437 Board.

And I've used the mailbox source provided by TI.

THIS IS MY SOURCE PATH : C:\CCStudio_v3.3\bios_5_41_01_09\packages\ti\bios\examples\basic\mailbox

 

But I can't be sure, I think there is a bug in the mailbox module.

 

In that source, basically mailbox has 2 length object property in GCONF.

But when I changed this from 2 to 3 length, then compiled it and run it, It's behavior is abnormal I think.

 

This is result(LOG) when i excuted this program which has mailbox 3 length.

0   (0) writing 'a' ...

1   (0) writing 'b' ...

2   (0) writing 'c' ...

3   writer (0) done.

4   read 'a' from (0).

5   read 'b' from (0).

6   read 'c' from (0).

7   (1) writing 'a' ...

8   (1) writing 'b' ...

9   (2) writing 'a' ...

10   read 'a' from (1).

11   read 'b' from (1).

12   read 'a' from (2).

13   (1) writing 'c' ...

14   writer (1) done.

15   (2) writing 'b' ...

16   (2) writing 'c' ...

17   writer (2) done.

18   read 'c' from (1).

19   read 'b' from (2).

20   read 'c' from (2).

21   timeout expired for MBX_pend()

22   reader done.

 

 

As you can see line from 7 to 14, this is weired.

I've thought that Writer 1 have to write all characters("a,b,c") to a mailbox buffer before Writer 2 writes its characters.

And One Reader Task must read all buffer data that is received by writer 1 task.

 

But the line no.9 show that writer 1 task is preempted by writer 2 task.

I think, the preemption is not possible in this condition(because Writer 1, Writer 2, Writer 3, Reader have all same priority of 1)

 

So, I tested some cases through changing mailbox length property from 1 to 7.

and I found out that only when I set length value to 3, this mailbox example has a problem.

another cases have no problem i can't expect.

 

This is Reader and Writer Sources. And the program has 3 writer tasks and 1 reader task.

and one mailbox object(mbx)

 

 

 

Regards,

Zizek

  • Hi Zizek --

    Can you try adding another print statement before the calls to MBX_post()?   I think MBX is working correctly, but the placement of the print statements makes it confusing.  MBX uses a semaphore internally.  I think that the writer1 and writer2 run and call MBX_post() before the reader task runs the first time.  writer1 and writer2 are both pending on the semaphore within MBX.  When the reader reads the first message, it posts the "free" semaphore and writer1 owns a free slot.  When the reader reads the second message, it posts the free semaphore and writer2 owns a free slot.   So, the count is only 1 when the reader blocks and the scheduler switches to writer1.  This allows writer1 to finish it's first put and output the print message.  writer1 then loops around and successfully calls put a 2nd time (which the free semaphore to 0).  The 3rd call to put, blocks and writer2 comes in and finishes it's first put.  

    Hope that makes sense.   I think adding an additional print statement before the MBX_put() will make things clearer.  And changing the strings before/after to say  "calling put with %d", and "put complete with %d".

    -Karl-

  • Thank you so much, karl~

    you have been very helpfullll!!

     

    TI's example sources have some bugs...but not significant.

    because of you and co-workers..