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

📄 tk_misc.c

📁 internich公司实现的一个非常非常小的OS
💻 C
字号:
/* * FILENAME: tk_misc.c * * Copyright 2002-2004 By InterNiche Technologies Inc. All rights reserved * * Routines to create Network Tasks for the Generic Multitasking systems ports * of InterNiche TCP/IP packages. Also contains other miscellaneous  * routines for Multitasking ports. * * MODULE: NTF * * ROUTINES: create_apptasks(), task_stats(),  * ROUTINES: tk_keyboard(), to_keyboard(),  * * PORTABLE: yes */#include "license.h"#include "ipport.h"/* Multitasking systems should use this file, however superloop *systems need to be able to ifdef it away */#ifndef SUPERLOOP /* whole file can be ifdeffed out *//* include project header. Define this in ipport.h to point to a file * in your project directory, i.e. "..\******\osport.h" */ #ifndef OSPORT_H#error Need to define OSPORT_H#endif#include OSPORT_H#ifdef TK_STDIN_DEVICEextern struct inet_taskinfo keyboardtask;extern long keyboard_wakes;extern void kbdio(void);#endif#ifdef NTFextern long task1_wakes;extern long task2_wakes;#endif /* NTF */#ifndef NO_INET_STACKextern long netmain_wakes;#endif   /* NO_INET_STACK */#ifndef NO_INET_TICKextern long nettick_wakes;#endif   /* NO_INET_TICK *//* per-application thread definitions */intcreate_apptasks(void){int e = 0;#ifdef TK_STDIN_DEVICE   e = TK_NEWTASK(&keyboardtask);   if (e != 0)   {      dprintf("keyboardtask create error\n");      panic("create_apptasks");      return -1;  /* compiler warnings */   }#endif   USE_ARG(e);   return 0;}#ifdef TK_STDIN_DEVICEextern   void  kbdio(void);#endif#ifdef TK_STDIN_DEVICETK_OBJECT(to_keyboard);TK_ENTRY(tk_keyboard);long     keyboard_wakes =  0;#endif   /* TK_STDIN_DEVICE */#ifdef TK_STDIN_DEVICEstruct inet_taskinfo keyboardtask = {      &to_keyboard,      "console",      tk_keyboard,      NET_PRIORITY   -  1,      IO_STACK_SIZE,};#endif/* FUNCTION: TK_ENTRY() * * Task to hand keystrokes to InerNiche menu system *  * PARAM1: n/a * * RETURNS: n/a */#ifdef TK_STDIN_DEVICETK_ENTRY(tk_keyboard){   for (;;)   {      tk_yield();   /* make keyboard yield some time */      kbdio(); /* let Iniche menu routines poll for char */      keyboard_wakes++; /* count wakeups */   }   TK_RETURN_OK();}#endif   /* TK_STDIN_DEVICE *//* FUNCTION: task_stats() *  * Print the "wake" statistics of all tasks. * * PARAM1: void * pio * * RETURNS:  */voidtask_stats(void * pio){   ns_printf(pio, "Task wakeups:\n");#ifdef NTF   ns_printf(pio, "task1: %lu\n", task1_wakes);   ns_printf(pio, "task2: %lu\n", task2_wakes);#endif /* NTF */#ifndef NO_INET_STACK   ns_printf(pio, "netmain: %lu\n", netmain_wakes);#endif#ifndef NO_INET_TICK   ns_printf(pio, "nettick: %lu\n", nettick_wakes);#endif#ifdef TK_STDIN_DEVICE   ns_printf(pio, "keyboard: %lu\n", keyboard_wakes);#endif   ns_printf(pio, "\n");}#endif   /* SUPERLOOP - whole file can be ifdeffed out */

⌨️ 快捷键说明

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