📄 tsk1.c
字号:
/* tsk1.c - Task #1 */#include <psos.h>#include <prepc.h>#include <stdio.h>#include "misc.h"#include "appl.h"void tsk1(ULONG me, ULONG qid, ULONG pid, ULONG l4){ ULONG rc, ignored, bufs; int data_size, loop_count, line_size, line_size2; struct message out; char * cp; char data[]="abcdefghijklmnopqrstuvwxyz"; bprintf("\t\t\t%s Task begin\n", (char *) me); data_size = strlen(data); /* Get buffers, fill them in, and send them to the queue */ for (loop_count = 0; loop_count < LOOP_MAX; loop_count++) { line_size = line_size2 = (rand() % (LINE_MAX-1)) + 1; while (ERR_NOBUF == (rc = pt_getbuf(pid, (void **) &cp))) { bprintf("%s waiting for buffers\n", (char *) me); tm_wkafter(1); } out.leng = line_size; out.pbuf = cp; out.ptid = pid; while (line_size-- > 0) *cp++ = data[rand() % data_size]; if (0 != (rc = q_send(qid, (ULONG *) &out))) fail(rc, "%s q_send(%s) failed", me, Q_NAM); bprintf("%s buffer sent\n", (char *) me); } /* All done, send a final message with NULL buffer ptr */ out.leng = 0; out.pbuf = (char *) 0; out.ptid = 0; if (0 != (rc = q_send(qid, (ULONG *) &out))) fail(rc, "%s q_send(%s) failed", me, Q_NAM); bprintf("\t\t\t%s Task end\n", (char *) me); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -