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

📄 test.c

📁 这是一个修改ucos的操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
static  void  TaskStartDispInit (void)
{
/*                                1111111111222222222233333333334444444444555555555566666666667777777777 */
/*                      01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
	 PC_DispStr( 0,  0, "                         uC/OS-II, The Real-Time Kernel                         ", DISP_FGND_WHITE + DISP_BGND_RED + DISP_BLINK);
	 PC_DispStr( 0,  1, "                                Jean J. Labrosse                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  2, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  3, "                                    EXAMPLE #1                                  ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  4, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  5, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  6, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  7, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  8, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0,  9, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 10, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 11, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 12, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 13, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 14, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 15, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 16, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 17, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 18, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 19, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 20, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 21, "                                                                                ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 22, "#Tasks          :        CPU Usage:     %                                       ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 23, "#Task switch/sec:                                                               ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
	 PC_DispStr( 0, 24, "                            <-PRESS 'ESC' TO QUIT->                             ", DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY + DISP_BLINK);
/*                                1111111111222222222233333333334444444444555555555566666666667777777777 */
/*                      01234567890123456789012345678901234567890123456789012345678901234567890123456789 */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           UPDATE THE DISPLAY
*********************************************************************************************************
*/

static  void  TaskStartDisp (void)
{
	 char   s[80];


	 sprintf(s, "%5d", OSTaskCtr);                                  /* Display #tasks running               */
	 PC_DispStr(18, 22, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);

#if OS_TASK_STAT_EN > 0
	 sprintf(s, "%3d", OSCPUUsage);                                 /* Display CPU usage in %               */
	 PC_DispStr(36, 22, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);
#endif

	 sprintf(s, "%5d", OSCtxSwCtr);                                 /* Display #context switches per second */
	 PC_DispStr(18, 23, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);

	 sprintf(s, "V%1d.%02d", OSVersion() / 100, OSVersion() % 100); /* Display uC/OS-II's version number    */
	 PC_DispStr(75, 24, s, DISP_FGND_YELLOW + DISP_BGND_BLUE);

	 switch (_8087) {                                               /* Display whether FPU present          */
		  case 0:
				 PC_DispStr(71, 22, " NO  FPU ", DISP_FGND_YELLOW + DISP_BGND_BLUE);
				 break;

		  case 1:
				 PC_DispStr(71, 22, " 8087 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
				 break;

		  case 2:
				 PC_DispStr(71, 22, "80287 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
				 break;

		  case 3:
				 PC_DispStr(71, 22, "80387 FPU", DISP_FGND_YELLOW + DISP_BGND_BLUE);
				 break;
	 }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                             CREATE TASKS
*********************************************************************************************************
*/

static  void  TaskStartCreateTasks (void)
{
	 INT8U  i;
	 INT16U rmerr;

	 for (i = RM_TASKS; i < N_TASKS; i++) {                        /* Create N_TASKS identical tasks           */
		  TaskData[i] = 'A' ;                             /* Each task will display its own letter    */
		  OSTaskCreate(Task, (void *)&TaskData[i], &TaskStk[i][TASK_STK_SIZE - 1], i + 1);
	}
	//  for (i = 0; i < RM_TASKS; i++) {                        /* Create N_TASKS identical tasks           */
	//	  TaskData[i] = 'B' ;                             /* Each task will display its own letter    */
		//  OSTaskCreate(Task1, (void *)&TaskData[i], &TaskStk[i][TASK_STK_SIZE - 1], i + 1);
	//		RMTaskCreate (Task1, (void *)&TaskData[i], &TaskStk[i][TASK_STK_SIZE - 1], 0, 1, 2, -1);
  //	 }
	// for (i = 0; i < RM_TASKS; i++) {                        /* Create N_TASKS identical tasks           */
	 //	  TaskData[i] = 'B' ;                             /* Each task will display its own letter    */
		  //OSTaskCreate(Task, (void *)&TaskData[i], &TaskStk[i][TASK_STK_SIZE - 1], i + 1);
	 //		rmerr = RMTaskCreate (Task1, (void *)&TaskData[i], &TaskStk[i][TASK_STK_SIZE - 1], 0, 1, 2, -1);
	//}


}

/*
*********************************************************************************************************
*                                                  TASKS
*********************************************************************************************************
*/

void  Task (void *pdata)
{
	 INT8U  x;
	 INT8U  y;
	 INT8U  err;


	 for (;;) {
		  OSSemPend(RandomSem, 0, &err);           /* Acquire semaphore to perform random numbers        */
		  x = random(80);                          /* Find X position where task number will appear      */
		  y = random(16);                          /* Find Y position where task number will appear      */
		  OSSemPost(RandomSem);                    /* Release semaphore                                  */
																 /* Display the task number on the screen              */
		  PC_DispChar(x, y + 5, *(char *)pdata, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
		  OSTimeDly(500);                            /* Delay 1 clock tick                                 */
	 }
}
void  Task1 (void *pdata)
{
	 INT8U  x;
	 INT8U  y;
	 INT8U  err;


	 for (;;) {
		  OSSemPend(RandomSem, 0, &err);           /* Acquire semaphore to perform random numbers        */
		  x = random(80);                          /* Find X position where task number will appear      */
		  y = random(16);                          /* Find Y position where task number will appear      */
		  OSSemPost(RandomSem);                    /* Release semaphore                                  */
																 /* Display the task number on the screen              */
		  PC_DispChar(x, y + 5, *(char *)pdata, DISP_FGND_BLACK + DISP_BGND_LIGHT_GRAY);
		  OSTimeDly(10);                            /* Delay 1 clock tick                                 */
	 }
}

⌨️ 快捷键说明

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