Texas Instruments TMS320 User Manual page 171

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

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
#define TIMEOUT
typedef struct MsgObj {
Int
id;
Char
val;
} 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 */
}
3
/* number of messages */
10
/* writer task id */
/* message value */
Thread Scheduling
Mailboxes
4-67

Advertisement

Table of Contents
loading

Table of Contents