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

📄 cos12run.c

📁 一个简单的任务调度系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/*            START              |              |              |<---------------------------------------------------|              |                                                    |       |-------------------|                                       |       |reset   watchdog   |                                       |       |-------------------|                                       |              |                                                    |       |-------------------|                                       |       |test for exception |                                       |       |-------------------|                                       |#ifndef OS_PRE_EMPTIVE              |                                                    |       |--------------|                                            |       |guard timers  |                                            |       |--------------|                                            |              |                                                    |#endif              |                                                    |        /--------------\                                           /      /    is there     \ Y  |-----------------|   |----------|    |     <       any         >-->|retrieve message |->-|dispatcher|->--|      \    message ?    /    |-----------------|   |----------|    |        \--------------/                                           |              |                                                    |              |N                                                   |              |                                                    |              |                                                    |        |------------|                                             |        |go idle     |                                             |        |------------|                                             |              |------------------------------------------------->--|*//* == STATEMENTS =========================================================== */{  while(1)  {#ifdef __arm      p_os19_RetriggerWatchDog();       /* feed HW watch dog */#endif#if (OS_RUNTIME_CHECK_LEVEL != 0 && !defined(RTK))      p_os19_CheckException();#endif#ifndef OS_PRE_EMPTIVE      if(G_st_os00_RunControl.u8_TimerActive)      {	  p_os13_GuardTimers();      }#endif      if (G_u8_os00_SystemActive)      {#ifdef SIM_FT_PT_CON	  p_su10_DummyMac();#endif  /* SIM_FT_PT_CON */#ifndef __arm	  p_su15_MMISim();#endif#if OS_DEBUG >= 2#ifdef __arm	  if(kbhit())	  {	      G_u8_os07_NoDebugger = 0;	  }#endif /* __arm */#endif /* OS_DEBUG >= 2 */#if OS_DEBUG >= 2	  p_os17_DbgTestBreak();	  if(!G_u8_os07_NoDebugger)	  {	      p_os17_DbgGetCommand();	  }#endif#ifdef OS_PRE_EMPTIVE	  if(p_os14_GetNextMsg(OS00_LPRIO_SCHEDULER))	  {	      p_os12_Dispatcher(OS00_LPRIO_SCHEDULER);#if OS_RUNTIME_CHECK_LEVEL >= 2	      if (G_st_os00_HPrioMsgAdmin.u8_MsgInQueue)	      {		  p_os19_RaiseException(OS09_EXC_HPRIO_LEVEL_STUCK);	      }#endif	      continue; /* dispatching may have triggered new events */	  }#else	  if(p_os14_GetNextMsg())	  {	      p_os12_Dispatcher();	      continue; /* dispatching may have triggered new events */	  }#endif      } /* G_u8_os00_SystemActive */      /* idle: no messages, no timers (otherwise continue'd) */#ifdef __arm      G_st_os00_Act.u8_Process = OS08_IDLE_PROCESS_ID; /* magic value for TRACE 'idle' process */      p_os19_IdleMode();#else /* __arm */#if !defined(SIM_FT_PT_CON)      if(G_st_os00_RunControl.u8_TimerActive == 0)      {#if (OS_DEBUG != 0)          OS_LOG_COMMENT;          OS_PRINTF_0("no more messages\n");          OS_LOG_STRING;#if OS_DEBUG >= 2          G_u8_os07_NoDebugger = 0;#else          break;#endif  /* OS_DEBUG >= 2 */#endif  /* OS_DEBUG != 2 */      }#endif  /* !defined(SIM_FT_PT_CON) */#endif /* __arm */#ifdef RTK      {          extern u16  RtkWaitEvents (u16 vp_EventList);          extern void RtkClearEvents(u16 vp_EventList);          RtkWaitEvents (1);          RtkClearEvents(1);      }#endif  } /* while (1) */}/* == END OF p_os12_Scheduler ============================================== */#ifdef OS_PRE_EMPTIVE/*MPF::p_os12_HPrioScheduler ==================================================== *//* FUNCTIONAL DESCRIPTION: * * This is the high priority schedule running as soft_int IRQ handler. * * GLOBALS *        - G_st_os01_LPrioAct *        - G_st_os00_Act * PARAMETERS * * None * * INTERFACE DECLARATION: */void p_os12_HPrioScheduler(void)/*EMP ====================================================================== *//* == DESIGN =============================================================== *//* * *//* == STATEMENTS =========================================================== */{  /* Assume we interrupted a low prio process. If not, this doesn't hurt as   * the global variable  G_st_os00_Act will the be loaded again before the   * next low prio process is invoked   */  G_st_os01_LPrioAct = G_st_os00_Act;  /* There must be at least one ready to run process, as otherwise we would   * not have been called.   */  while (p_os14_GetNextMsg(OS00_HPRIO_SCHEDULER))  {#ifdef __arm      p_os19_RetriggerWatchDog();       /* feed HW watch dog */#endif      p_os12_Dispatcher(OS00_HPRIO_SCHEDULER);#if (OS_RUNTIME_CHECK_LEVEL != 0 && !defined(RTK))      p_os19_CheckException();#endif  }  /* Return from HPrio execution, restore global variable */  G_st_os00_Act = G_st_os01_LPrioAct;}/* == END OF p_os12_HPrioScheduler ====================================== */#endif /* OS_PRE_EMPTIVE */#if OS_DEBUG >= 2/*MPF::p_os12_ShowStateTable ============================================ *//*                                                                        *//* FUNCTIONAL DESCRIPTION:                                                *//*                                                                        *//* Shows the state table for debug purpose                                *//*                                                                        *//* INTERFACE DECLARATION:                                                 */void p_os12_ShowStateTable(void)  /*EMP===================================================================*/  /* == DESIGN ========================================================== */  /*                                                                      */  /* print header and then the states of all processes                    */  /*                                                                      */  /* == STATEMENTS ====================================================== */{  u8 u8_Process;  u8 u8_Instance;  u8 u8_FirstInstance;  u8 u8_LastInstance;  OS_LOG_COMMENT;  OS_PUT_S ("state table:\n");  /* OS_LOG_STRING; ASA 21-Feb-2002: workaround for sprintf */  OS_LOG_COMMENT;  OS_PUT_SW("proc/inst",20);  OS_PUT_S ("state\n");  /* OS_LOG_STRING; ASA 21-Feb-2002: workaround for sprintf */  for(u8_Process= 0; u8_Process < OS09_NR_OF_PROCESSES; u8_Process++)  {      u8_FirstInstance = G_u8_os09_StateTableIndex[u8_Process];      if(u8_Process == OS09_NR_OF_PROCESSES - 1)      {	  u8_LastInstance = (u8)(OS09_LEN_OF_STATE_TABLE - u8_FirstInstance);      }      else      {	  u8_LastInstance = (u8)(G_u8_os09_StateTableIndex[u8_Process + 1] -				                            u8_FirstInstance);      }      for(u8_Instance = 0;u8_Instance < u8_LastInstance;u8_Instance++)      {	  OS_LOG_COMMENT;	  OS_PUT_UW(u8_Process,4);OS_PUT_S("/");	  OS_PUT_U (u8_Instance);  OS_PUT_S(" ");	  OS_PUT_SW(G_pu8_os09_ProcessNames[u8_Process], 13);	  OS_PUT_S(G_pu8_os09_StateNames[u8_Process]                      [G_u8_os09_StateTable[u8_FirstInstance + u8_Instance]]);	  OS_PUT_S("\n");	  /* OS_LOG_STRING; ASA 21-Feb-2002: workaround for sprintf */      }  }}/* == END OF p_os12_ShowStateTable ====================================== */#endif/* == END OF MODULE =================================================== */

⌨️ 快捷键说明

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