app.c

来自「RT-Linux源码 一个实时操作系统源码」· C语言 代码 · 共 43 行

C
43
字号
//#include <asm/rt_time.h> #include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <unistd.h>#include <errno.h>#include "control.h"event_info ev1,ev2;#ifndef DEBUG#    error Probably kernel does not produce statistic for this program#endif  int main(){    int i;    int debug_fifo;    printf("TASK 1 \"UNO\"\nTASK 2 \"DOS\"\nTASK 3 \"TRES\"\n");    printf("TASK 4 \"CUATRO\"\nTASK 5 \"CINCO\"\nTASK 6 \"SEIS\"\n:BODY\n");    debug_fifo = open ("/dev/rtf5",O_RDONLY);    if ( debug_fifo == -1 ) {	printf("rtf5: not such device\n");	exit(1);    }    for (i=0; i<1000 ; i++) {  	read( debug_fifo, (char *) &ev2, sizeof(event_info));	if ( i==0 ) ev1 = ev2;    	printf("%s %d %d %d\n", 	    (ev2.state== EXEC) ? "EXEC": "ACTI",	    ev2.id, 	    (int) ((ev2.in-ev1.in)/10), 	    (int) ((ev2.out-ev1.in)/10));    }    close(debug_fifo);    return 0;}

⌨️ 快捷键说明

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