share.c

来自「经典的psos编程实例源码」· C语言 代码 · 共 41 行

C
41
字号
/* share.c - Tasks #3, 4, and 5 */#include <psos.h>#include <prepc.h>#include <stdio.h>#include "misc.h"#include "appl.h"void main_loop(ULONG me, ULONG tid, ULONG ev, ULONG qid){	ULONG	rc;	struct	message	in;	char	str[256];	bprintf("%s Task begin\n", me);	do {		/* Tell tsk1 we are ready */		if (0 != (rc = ev_send(tid, ev)))			fail(rc, "%s: ev_send(0x%x)", me, tid);		/* Then receive the broadcast */		if (0 != (rc = q_receive(qid, 0, 0, (ULONG *) &in)))			fail(rc, "%s: q_receive()", me);		bprintf("%s: received ", (char *) me);		if (in.flag == FALSE)			bprintf("FALSE: ");		else			bprintf("TRUE:  ");		str[0]='\0';		strncat(str, (char *) &(in.data), sizeof(in.data));		bprintf("%s\n", str);	} while (in.flag == FALSE);	/* Report we've seen the final message */	if (0 != (rc = ev_send(tid, ev)))		fail(rc, "%s: ev_send(0x%x)", me, tid);	bprintf("%s Task end\n", (char *) me);	exit(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?