vxworks的启动任务taskSpawn

vxworks启动线程任务的api接口和linux有所不同,vxworks采用的是taskSpawn。

如下代码所示:


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <loglib.h>
#include <stddef.h>
#include <time.h>
#include <tasklib.h>

LOCAL int tidThis;
LOCAL int tidThat;

#define STACK_SIZE 1000

void* thisRoutine(void* args)
{
	int ii = 0;
	for (ii = 0; ii < 100; ii++)
	{
		printf("task 1\n");
		sleep(1);
	}
}

void* thatRoutine(void* args)
{
	int ii = 0;
	for (ii = 0; ii < 100; ii++)
	{
		printf("task 2\n");
		sleep(1);
	}
}

STATUS func(void)
{
	tidThis = taskSpawn("taskThis", 200, 0, STACK_SIZE, (FUNCPTR)thisRoutine, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	tidThat = taskSpawn("taskThat", 220, 0, STACK_SIZE, (FUNCPTR)thatRoutine, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	
	if (tidThis == ERROR || tidThat == ERROR)
	{
		return ERROR;
	}
	
	return OK;
}


STATUS main(int argc, char* argv[])
{
	int iRet;
	int ii = 0;

	printf("welcome to workbench for vxworks6.6\n");
	
	iRet = func();
	if (iRet == ERROR)
	{
		return ERROR;
	}
	
	for (ii = 0; ii < 10; ii++)
	{
		printf("main task\n");
		sleep(1);
	}
	
	taskDelete(tidThis);
	taskDelete(tidThat);

	return 0;
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值