Exemplo n.º 1
0
int func(void* arg)
	{
	int retval=0;
	ThreadData* pData = (ThreadData*) arg;

	retval = SemTryWait(pData);
	retval = PostSignal(pData);
	if(retval == 0)
		{
		StopThread(pData);
		}
	return retval;
	}
Exemplo n.º 2
0
int func1(void* arg)
	{
	int retval=0;
	ThreadData* pData = (ThreadData*) arg;
	
	retval = SemTryWait(pData);
	retval= VerifyErrno(pData,EAGAIN);
	retval = PostSignal(pData);
	if(retval == 0)
		{
		StopThread(pData);
		}
	return retval;
	}
Exemplo n.º 3
0
void *user(void *arg)		//子线程 用以获取用户的命令 判断
{
	while(1)
	{
		strcpy(SteelKey,pipe_read());
		if(strcmp(SteelKey,"back")==0)		//关闭程序
		{
			nend=0;
			pipe_write("close");
			break;
		}
		readINIFile("./SteelKeyV2.ini",find_key_config);	//解析.ini文件
		if(nSK)
		{
			printf("This SteelKey is false\n\n");
			pipe_write("SteelKey");
			continue;
		}
		steelLine_flag = 1;
		while(steelLine_flag)
		{
			strcpy(steelLine,pipe_read());
			if(strcmp(steelLine,"back")==0)		//返回上一级
			{
				steelLine_flag = 0;
				pipe_write("BTSK");
				continue;
			}
			for(j=1;j<11;j++)
			{
				if(strcmp(steelLine,SteelKey_config[j].steelLine)==0)
				{
					nLine = 0;
					break;
				}
			}
			if(nLine)		//Line值不存在
			{
				pipe_write("Line");
				printf("Thie SteelLine is fail\n\n");
				continue;
			}
			AD_proc_flag = 1;
			nLine = 1;
			pipe_write("find");		//找到line
			while(AD_proc_flag)
			{
				strcpy(steelAD,pipe_read());
				if(strcmp(steelAD,"a")==0)	//返回上一级
				{
					AD_proc_flag = 0;
					pipe_write("back");
					continue;
				}
				else if(strcmp(steelAD,"b")==0)	//返回方向盘
				{
					steelLine_flag = 0;
					AD_proc_flag = 0;
					pipe_write("BTSK");
					continue;
				}
				PostSignal(&AD_mutex,&user_cond,&bl);
			}
		}
		
		
		nSK=1;
	}
}