vxworks中关于关于RTP的工程

wr_workbench_vxworks_users_guide_3.0和vxworks_application_programmers_guide_6.6

RTP工程生成的可执行代码是vxe类似exe文件,入口时main函数,默认的RTP工程是main函数结束,就把该main创建的所有任务也都结束,如果不想结束,就用在main函数最后加上taskExit(1);


运行方式

1、       rtpSp "/ata0a/RTPtest2.vxe"(shell或超级终端)或rtpSp"/ata0a/RTPtest2.vxe \"100\" \"0x10000\""

2、       应用程序(工程类型downloadable kernel project)

const char * argv[] = {"/ata0a/RTPtest.vxe", NULL};

rtpSpawn (argv[0], argv, NULL, 100, 0x10000, 0, 0);

例子:

#include "vxWorks.h"
#include "taskLib.h"
#include "msgQLib.h"
#include "stdio.h"


static void producer();
static void consumer();


#define MSG_SIZE 16
#define MSG_WAIT 60
#define TASK_WAIT 50


static MSG_Q_ID myQ;
static int myFlag = 0; /* for trigger use */


void main(int argc,char *argv[])
{
myQ = msgQCreate(5, MSG_SIZE, MSG_Q_PRIORITY);


taskSpawn("tProducer", 80, 0, 0x1000, (FUNCPTR)producer, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);


taskSpawn("tConsumer", 80, 0, 0x1000, (FUNCPTR)consumer, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
taskExit(1);
}


void producer()
{
static int sid = 0;
char *buffer;
  
while (1) {
buffer = malloc(MSG_SIZE);
*(unsigned int *)buffer = ++sid;


if (msgQSend(myQ, buffer, MSG_SIZE, MSG_WAIT, 0) != OK) {
printf("Producer: Can not send message,\t sid = %d\n\r", sid);
} else {
printf("Producer: Message sent,\t\t sid = %d\n\r", sid);
}


/* free(buffer); */ /* cause memory leakage */
taskDelay(TASK_WAIT);
}
}


void consumer()
{
static int sid = 0;
char buffer[MSG_SIZE];


while (1) {
if (msgQReceive(myQ, buffer, MSG_SIZE, MSG_WAIT) == ERROR) {     
printf("Consumer: Can not receive message,\t sid = %d\n\r", 
sid + 1);
} else {
sid = *(unsigned int *)buffer;
printf("Consumer: Message received,\t sid = %d\n\r\n\r", sid);
}
}
}


void myPrint()
{
int i;


printf("\n-------------------------\n");
for (i = 0; i < 5; i++)
printf("myPrintf called\n");
printf("\n-------------------------\n");
}


  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

woquNOKIA

谢谢老板!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值