?? mymsgq.c
字號:
/* In this example, task t1 creates the message queue and sends a message
* to task t2. Task t2 receives the message from the queue and simply
* displays the message.
*/
/* includes */
#include "vxWorks.h"
#include "msgQLib.h"
/* defines */
#define MAX_MSGS (10)
#define MAX_MSG_LEN (100)
MSG_Q_ID myMsgQId;
task3(void)
{
/* create message queue */
if ((myMsgQId = msgQCreate (MAX_MSGS, MAX_MSG_LEN, MSG_Q_PRIORITY))
== NULL)
return (ERROR);
}
task2 (void)
{
char msgBuf[MAX_MSG_LEN];
/* get message from queue; if necessary wait until msg is available */
if (msgQReceive(myMsgQId, msgBuf, MAX_MSG_LEN, WAIT_FOREVER) == ERROR)
return (ERROR);
/* display message */
printf ("Message from task 1:\n%s\n", msgBuf);
}
#define MESSAGE "Greetings from Task 1"
task1 (void)
{
if (msgQSend (myMsgQId, MESSAGE, MAX_MSG_LEN, WAIT_FOREVER,
MSG_PRI_NORMAL) == ERROR)
return (ERROR);
/* send a normal priority message, blocking if queue is full
if (msgQSend (myMsgQId, MESSAGE, sizeof (MESSAGE), WAIT_FOREVER,
MSG_PRI_NORMAL) == ERROR)
return (ERROR);
*/
}
void mymsgQ(void)
{
taskSpawn("t3",100,0,0x20000,(FUNCPTR)task3,0,0,0,0,0,0,0,0,0,0);
taskSpawn("t2",100,0,0x20000,(FUNCPTR)task2,0,0,0,0,0,0,0,0,0,0);
taskSpawn("t1",100,0,0x20000,(FUNCPTR)task1,0,0,0,0,0,0,0,0,0,0);
}
myprint()
{
printf("Hello world\n");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -