⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 root.c

📁 经典的psos编程实例源码
💻 C
字号:
/* root.c */#include "sys_conf.h"#include <psos.h>#include <prepc.h>#include <stdio.h>#include "misc.h"#include "appl.h"/* ROOT task */voidroot(){	void	* dummy;	ULONG	ioretval, iopb[4], rc, args[4], ignored, qid;	ULONG	tid1, tid2, tid3, tid4;	char	* me = "ROOT";	/* Initialize all drivers */	de_init(DEV_TIMER, 0, &ioretval, &dummy);	de_init(DEV_SERIAL, 0, &ioretval, &dummy);	bpinit(128*100);	bprintf("\nRoot task begin\n");	/* (Q_LIMIT & Length==0) No messages will ever be stored. */	if (0 != (rc = q_create(Q_NAM, 0, Q_LIMIT, & qid)))		fail(rc, "%s q_create(%s) failed", me, Q_NAM);	/* Create and start the test tasks */	args[0] = (ULONG) T1_NAM;	/* This task's name */	args[1] = 0;			/* Not used */	args[2] = 0;			/* Not used */	args[3] = qid;			/* Queue ID */	if (rc = t_create(T1_NAM, 128, 1024, 1024, 0, &tid1))		fail(rc, "root: t_create(%s)", T1_NAM);	if (rc = t_start(tid1, 0, (void(*)()) tsk1, args))		fail(rc, "root: t_start(%s)", T1_NAM);	args[0] = (ULONG) T2_NAM;	/* This task's name */	args[1] = tid1;			/* Other task's ID */	args[2] = T2_EV;		/* This task's event */	if (rc = t_create(T2_NAM, 128, 1024, 1024, 0, &tid2))		fail(rc, "%s: t_create(%s)", me, T2_NAM);	if (rc = t_start(tid2, 0, (void(*)()) main_loop, args))		fail(rc, "%s: t_start(%s)", me, T2_NAM);	args[0] = (ULONG) T3_NAM;	/* This task's name */	args[2] = T3_EV;		/* This task's event */	if (rc = t_create(T3_NAM, 128, 1024, 1024, 0, &tid3))		fail(rc, "%s: t_create(%s)", me, T3_NAM);	if (rc = t_start(tid3, 0, (void(*)()) main_loop, args))		fail(rc, "%s: t_start(%s)", me, T3_NAM);	args[0] = (ULONG) T4_NAM;	/* This task's name */	args[2] = T4_EV;		/* This task's event */	if (rc = t_create(T4_NAM, 128, 1024, 1024, 0, &tid4))		fail(rc, "%s: t_create(%s)", me, T4_NAM);	if (rc = t_start(tid4, 0, (void(*)()) main_loop, args))		fail(rc, "%s: t_start(%s)", me, T4_NAM);	/* Now wait until task #1 disappears */	while (0 == (rc = t_getreg(tid1, 0, &ignored)))		tm_wkafter(10);	if (rc != ERR_OBJDEL)		fail(rc, "root: t_getreg(%s)", T1_NAM);	/* Example finished */	bprintf("Root task end\n");	bpflush();	exit(0);}

⌨️ 快捷键说明

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