Mailboxes
Thread Scheduling
4-67
Example 4-15.
MBX Example With Two Types of Tasks
/*
* ======== mbxtest.c ========
* Use a MBX mailbox to send messages from multiple writer()
* tasks to a single reader() task.
* The mailbox, reader task, and 3 writer tasks are created
* statically.
*
* This example is similar to semtest.c. The major differences
* are:
* - MBX is used in place of QUE and SEM.
* - the ‘elem’ field is removed from MsgObj.
* - reader() task is *not* higher priority than writer task.
* - reader() looks at return value of MBX_pend() for timeout
*/
#include <std.h>
#include <log.h>
#include <mbx.h>
#include <tsk.h>
#define NUMMSGS 3 /* number of messages */
#define TIMEOUT 10
typedef struct MsgObj {
Int id; /* writer task id */
Char val; /* message value */
} MsgObj, *Msg;
/* Mailbox created with Config Tool */
extern MBX_Obj mbx;
/* "trace" Log created with Config Tool */
extern LOG_Obj trace;
Void reader(Void);
Void writer(Int id);
/*
* ======== main ========
*/
Void main()
{
/* Does nothing */
}
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...