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

📄 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"int	running = 0;ULONG	smid;/* ROOT task */voidroot(){	void	* dummy;	ULONG	ioretval, iopb[4], rc, args[4], tid, ignored, me,		rootpriority, priority;	int	index;	char	str[5];	/* 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");	com[0] = 0; com[1] = 1; com[2] = 2; com[3] = 3; com[4] = 4;	/* Create the semaphore */	if (0 != (rc = sm_create(SEM_NAM, 1, SM_PRIOR, & smid)))		fail(rc, "tsk1 sm_create(%s) failed", SEM_NAM);	srand(123456727L); /* Initialize random number generator */	t_setpri(0, 0, &rootpriority);	/* Create and start the test tasks */	args[0] = args[1] = args[2] = args[3] = 0;	/* Not Used */	for (index = NUMTASKS; index > 0; index--) {		priority = 1 + (rand() % rootpriority);		sprintf(str, "T%03d", priority);		if (rc = t_create(str, priority, 1024, 1024, 0, &tid))			fail(rc, "t_create(%s)", str);		if (rc = t_setreg(tid, 0, *(ULONG *) str)) /* Name */			fail(rc, "t_setreg(0) %s", str);		if (rc = t_start(tid, 0, (void(*)()) main_loop, args))			fail(rc, "t_start(%s)", str);		running++;	/* Count babies */	}	while (running)	/* See if any baby tasks are still around */		tm_wkafter(1*TENTH);	/* If so, wait */	/* Example finished */	bprintf("Root task end\n");	bpflush();	exit(0);}

⌨️ 快捷键说明

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