亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os-task-switch.c

?? ucos-ii-at90S-icc-avr
?? C
?? 第 1 頁 / 共 2 頁
字號:
//os主要代碼
#define  OS_GLOBALS                           /* Declare GLOBAL variables                              */
#include "includes.h"

#define  OS_MASTER_FILE                       /* Prevent the following files from including includes.h */

void        OSInit(void)
{
  INT8U i;

  OSIntNesting=0;             /* Interrupt nesting level                              */
  OSLockNesting=0;            /* Multitasking lock nesting level                      */
  OSPrioCur=0xff;                /* Priority of current task                             */
  OSPrioHighRdy=0xff;            /* Priority of highest priority task                    */
  OSRunning = FALSE;

  OSTCBCur=0;                        /* Pointer to currently running TCB              */
  OSTCBHighRdy=0;                    /* Pointer to highest priority TCB ready to run  */
/*init task tcb pointers list*/
  for(i=0;i<OS_TASK_COUNT;i++)
    OSpTCBList[i]=(OS_TCB*)0;
}
/*
OS_STK *	OSTaskStkInit (void (*task)(void *pd),void *pdata, OS_STK *ptos);
INT8U       OSTCBInit(OS_TCB *ptcb,INT8U prio, OS_STK *ptos,INT16U stk_size);
*/

INT8U       OSTaskCreate(OS_TCB *ptcb,void (*task)(void *pd), void *pdata, OS_STK *ptos,INT16U stk_size, INT8U prio)
{
    void   *psp;
    INT8U   err;

    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OSERR_PRIO_INVALID);
    }
    OS_ENTER_CRITICAL();
    if (OSpTCBList[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
        OSpTCBList[prio] = ptcb;    /* Reserve the priority to prevent others from doing ...  */
        OS_EXIT_CRITICAL();
        psp = (void *)OSTaskStkInit(task, pdata, ptos, stk_size); /* Initialize the task's stack              */
        err = OSTCBInit(ptcb,prio, psp,stk_size);         
        if (err == OS_NO_ERR) {
            if (OSRunning) {                 /* Find highest priority task if multitasking has started */
                OSSched();
            }
        } else {
        }
        return (err);
    } else {
        OS_EXIT_CRITICAL();
        return (OSERR_PRIO_EXIST);
    }
}

/*
*********************************************************************************************************
*                                            INITIALIZE TCB
*
* Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
*              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
*
* Arguments  : prio          is the priority of the task being created
*
*              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
*                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
*                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
*                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
*                            specific.
*
*              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
*                            'OSTaskCreate()'.
*
*              id            is the task's ID (0..65535)
*
*              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
*                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
*                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
*                            units are established by the #define constant OS_STK which is CPU
*                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
*
*              pext          is a pointer to a user supplied memory area that is used to extend the task
*                            control block.  This allows you to store the contents of floating-point
*                            registers, MMU registers or anything else you could find useful during a 
*                            context switch.  You can even assign a name to each task and store this name
*                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
*
*              opt           options as passed to 'OSTaskCreateExt()' or, 
*                            0 if called from 'OSTaskCreate()'.
*
* Returns    : OS_NO_ERR         if the call was successful
*              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
*                                be created.
*
* Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
*********************************************************************************************************
*/

INT8U OSTCBInit (OS_TCB *ptcb,INT8U prio, OS_STK *ptos, INT16U stk_size)
{
#if OS_STRICT
  if((0==ptcb)||(prio>OS_LOWEST_PRIO)||((INT16U)ptos<OS_HARDWARE_STACK_SIZE+40)||(stk_size<OS_HARDWARE_STACK_SIZE+40))
    OSError(0);
#endif
    OS_ENTER_CRITICAL();
    if ((OS_TCB *)0!=ptcb) {
        OS_EXIT_CRITICAL();
        ptcb->OSTCBStkPtr    = ptos;                       /* Load Stack pointer in TCB                */
        ptcb->OSTCBPrio      = (INT8U)prio;                /* Load task priority into TCB              */
        ptcb->OSTCBStat      = OS_STAT_RDY;                /* Task is ready to run                     */
        ptcb->OSTCBDly       = 0;                          /* Task is not delayed                      */

        return (OS_NO_ERR);
    } else {
        OS_EXIT_CRITICAL();
        return (OSERR_TCB_INVALID);
    }
}

/*
*********************************************************************************************************
*                                              SCHEDULER
*
* Description: This function is called by other uC/OS-II services to determine whether a new, high
*              priority task has been made ready to run.  This function is invoked by TASK level code
*              and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
*
* Arguments  : none
*
* Returns    : none
*
* Notes      : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
*              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
*********************************************************************************************************
*/

void OSSched (void)
{
    OS_ENTER_CRITICAL();
    if ((OSLockNesting | OSIntNesting) == 0) {   /* Task scheduling must be enabled and not ISR level  */
        OSPrioHighRdy=OSGetPrioRdy();
		if(OSPrioHighRdy>OS_LOWEST_PRIO)
		{
#if OS_STRICT
		  OSError(0);
#endif
		}else if (OSPrioHighRdy != OSPrioCur) {         /* No context switch if current task is highest ready */
            OSTCBHighRdy = OSpTCBList[OSPrioHighRdy];
#if OS_STRICT
		  	if(0==OSTCBHighRdy)
			  OSError(0);
#endif			
			OS_TASK_SW();                        /* Perform a context switch                           */
        }//end OSPrioHighRdy != OSPrioCur
    }//end nesting==0
    OS_EXIT_CRITICAL();
}

/*
*********************************************************************************************************
*                                          START MULTITASKING
*
* Description: This function is used to start the multitasking process which lets uC/OS-II manages the
*              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
*              and you MUST have created at least one task.
*
* Arguments  : none
*
* Returns    : none
*
* Note       : OSStartHighRdy() MUST:
*                 a) Call OSTaskSwHook() then,
*                 b) Set OSRunning to TRUE.
*********************************************************************************************************
*/

void OSStart (void)
{
    if (OSRunning == FALSE) {
        OSPrioHighRdy = 0;
        OSPrioCur     = 0;
        OSTCBHighRdy  = OSpTCBList[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
        OSTCBCur      = OSTCBHighRdy;
#if OS_STRICT
		if(0==OSTCBCur) 
		  OSError(0);
#endif		
        OSStartHighRdy();                            /* Execute target specific code to start task     */
    }
#if OS_STRICT
	else OSError(0);
#endif
}

/*
*********************************************************************************************************
*                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
*
* Description: This function is called to delay execution of the currently running task until the 
*              specified number of system ticks expires.  This, of course, directly equates to delaying
*              the current task for some time to expire.  No delay will result If the specified delay is 
*              0.  If the specified delay is greater than 0 then, a context switch will result.
*
* Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.  
*                        Note that by specifying 0, the task will not be delayed.
*
* Returns    : none
*********************************************************************************************************
*/

void OSTimeDly (INT16U ticks)
{
    if (ticks > 0) {                                                      /* 0 means no delay!         */
        OS_ENTER_CRITICAL();
        OSTCBCur->OSTCBDly = ticks;                                       /* Load ticks in TCB         */
        OS_EXIT_CRITICAL();
        OSSched();                                                        /* Find next task to run!    */
    }
}
/*return tcb's prio which OSTCBDly==0*/
INT8U OSGetPrioRdy(void)
{
  INT8U i,ret=0xff;
  OS_TCB *ptcb;
  for(i=0;i<OS_TASK_COUNT;i++)
  {
    ptcb=OSpTCBList[i];
    //OS_ENTER_CRITICAL();
    if(ptcb)
	{
	  if(0==ptcb->OSTCBDly)
	  {
	  if(OS_STAT_RDY==ptcb->OSTCBStat)
	  {
#if OS_STRICT
	    if(i!=ptcb->OSTCBPrio)
		  OSError(0);
#endif  
        ret=ptcb->OSTCBPrio;     
#if OS_STRICT
		if(ret>OS_LOWEST_PRIO)
		  OSError(0);
#endif  		
	    break;//for
	  }//end OS_STAT_RDY==ptcb->OSTCBStat
#if OS_SEM_EN
	  else{
		  if(ptcb->OSTCBStat & OS_STAT_SEM)
		  {
#if OS_STRICT
			  if(i!=ptcb->OSTCBPrio)
				  OSError(0);
#endif  
			  ret=ptcb->OSTCBPrio;     
#if OS_STRICT
			  if(ret>OS_LOWEST_PRIO)
				  OSError(0);
#endif  		
	    break;//for
		  }
	  }//end (ptcb->OSTCBStat & OS_STAT_SEM)
#endif//OS_SEM_EN
	  }//end (0==ptcb->OSTCBDly)
	}
    //OS_EXIT_CRITICAL();
  }
  return ret;
}

/*
*********************************************************************************************************
*                                         PROCESS SYSTEM TICK
*
* Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
*              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
*              called by a high priority task.
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/

void OSTimeTick (void)
{
    INT8U i,ret;
    OS_TCB *ptcb;
	//skip last task,last task must be idle task
	for(i=0;i<OS_TASK_COUNT-1;i++)
	{
	ptcb=OSpTCBList[i];
//    OS_ENTER_CRITICAL();
    //check ptcb != 0
	if(ptcb){              /* Go through all TCBs in TCB list          */
        if (ptcb->OSTCBDly != 0) {                         /* Delayed or waiting for event with TO     */
            if (--ptcb->OSTCBDly == 0) {                   /* Decrement nbr of ticks to end of delay   */
//                if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {    /* Is task suspended?                   */
//                    OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task Rdy to Run (timed out)*/
//                    OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
//                } else {                                       /* Yes, Leave 1 tick to prevent ...     */
//                    ptcb->OSTCBDly = 1;                        /* ... loosing the task when the ...    */
//                }                                              /* ... suspension is removed.           */
			}//end (--ptcb->OSTCBDly==0)         
			}//end OSTCBDly!=0
        }//end if(ptcb)
  //  OS_EXIT_CRITICAL();
    }//end for
}

/*
*********************************************************************************************************
*                                               EXIT ISR
*
* Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When 
*              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
*              a new, high-priority task, is ready to run.
*
* Arguments  : none
*
* Returns    : none
*
* Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
*                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
*                 end of the ISR.
*              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
*********************************************************************************************************
*/

void OSIntExit(void)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精选视频免费看| 欧美一区二区三区免费在线看 | 波多野结衣中文字幕一区| 免费成人小视频| 另类专区欧美蜜桃臀第一页| 日韩精品一级中文字幕精品视频免费观看 | 91蜜桃传媒精品久久久一区二区| 粉嫩蜜臀av国产精品网站| 国产精品亚洲综合一区在线观看| 狠狠色2019综合网| 国产伦精品一区二区三区视频青涩 | 视频一区二区三区入口| 日韩国产欧美在线观看| 久久精品国产亚洲高清剧情介绍 | 欧美日韩精品一区二区三区| 欧美日韩美少妇| 91麻豆精品91久久久久久清纯| 制服视频三区第一页精品| 日韩欧美美女一区二区三区| 久久综合一区二区| 国产精品卡一卡二| 一区二区日韩电影| 日本伊人精品一区二区三区观看方式| 久久精品av麻豆的观看方式| 国产一区视频网站| 色悠悠久久综合| 日韩一区二区三区免费看 | 久久精品国产99国产精品| 激情文学综合网| 成人黄色大片在线观看| 欧美天堂一区二区三区| 日韩精品一区二区三区三区免费| 国产欧美综合在线观看第十页| 成人欧美一区二区三区白人| 日韩国产欧美在线观看| 丁香一区二区三区| 欧美日韩国产一级| 国产精品午夜春色av| 午夜影院久久久| 懂色av一区二区夜夜嗨| 欧美日韩国产一区| 一区二区中文视频| 狠狠色丁香久久婷婷综合_中| 色综合天天视频在线观看| 欧美一级专区免费大片| 一区二区三区自拍| 国产成人在线观看| 日韩欧美国产综合在线一区二区三区| 亚洲欧洲99久久| 九九**精品视频免费播放| 欧美这里有精品| 国产精品乱码久久久久久| 日本一不卡视频| 欧美性猛交一区二区三区精品| 久久久久久久久久久久久夜| 日韩精品三区四区| 91福利国产成人精品照片| 国产精品色一区二区三区| 精品一区二区三区在线播放| 欧美另类高清zo欧美| 亚洲精品国产第一综合99久久 | 欧美国产乱子伦| 精品一区二区三区的国产在线播放| 色网综合在线观看| 中文字幕中文在线不卡住| 国产精品亚洲午夜一区二区三区| 91精品国产91久久综合桃花| 亚洲线精品一区二区三区| 色综合久久久久久久久| 成人免费在线观看入口| 国产凹凸在线观看一区二区| 久久综合久久综合九色| 久久精品72免费观看| 日韩亚洲欧美一区| 免费视频一区二区| 精品少妇一区二区三区在线播放 | 日韩福利电影在线观看| 欧美精品在线一区二区三区| 亚洲综合久久久久| 欧美高清dvd| 美女久久久精品| 精品国产一区二区国模嫣然| 国产一区二区三区蝌蚪| 久久久噜噜噜久久人人看 | 欧美午夜不卡视频| 一级日本不卡的影视| 色伊人久久综合中文字幕| 一区二区三区欧美在线观看| 欧美性猛交xxxx黑人交| 日本午夜一本久久久综合| 欧美变态凌虐bdsm| 国产成人超碰人人澡人人澡| 亚洲欧洲在线观看av| 在线精品视频免费播放| 美女一区二区视频| 久久久久久久电影| 色呦呦网站一区| 日本成人在线网站| 久久久777精品电影网影网| 99久久精品国产一区二区三区| 亚洲日本免费电影| 欧美日韩夫妻久久| 激情小说亚洲一区| 亚洲免费毛片网站| 日韩欧美的一区二区| 成人深夜福利app| 亚洲成av人片在线观看无码| 久久亚洲捆绑美女| 欧美日韩国产免费一区二区 | 欧美另类videos死尸| 国产在线一区二区综合免费视频| 国产精品毛片久久久久久久| 欧美中文字幕一区二区三区亚洲| 日韩专区在线视频| 欧美高清在线一区| 91精品久久久久久久99蜜桃| 丁香五精品蜜臀久久久久99网站| 亚洲成人动漫av| 中文字幕一区二区在线播放| 日韩欧美一级二级三级久久久| 97久久超碰精品国产| 麻豆精品在线观看| 亚洲va欧美va人人爽午夜 | 色婷婷综合视频在线观看| 蜜臀av亚洲一区中文字幕| 亚洲欧洲性图库| av成人免费在线观看| 日本vs亚洲vs韩国一区三区二区 | 色哟哟在线观看一区二区三区| 麻豆国产精品一区二区三区| 亚洲精品综合在线| 欧美激情中文不卡| 精品国产乱码久久久久久免费| 在线观看网站黄不卡| hitomi一区二区三区精品| 激情成人午夜视频| 琪琪久久久久日韩精品| 亚洲国产精品久久艾草纯爱| 国产精品久久久久久久久久久免费看 | 亚洲男女一区二区三区| 国产亚洲短视频| 精品sm在线观看| 欧美一区二区三区啪啪| 9191成人精品久久| 欧美精品国产精品| 精品视频在线视频| 欧洲视频一区二区| 91国内精品野花午夜精品| av亚洲产国偷v产偷v自拍| 成人免费的视频| 成人免费视频视频在线观看免费| 国产黄色精品网站| 国产成人免费视频网站| 国产黄色成人av| 成人免费av网站| 菠萝蜜视频在线观看一区| 成人国产精品免费观看| av电影天堂一区二区在线观看| 成人精品视频一区| 色婷婷av一区| 欧美体内she精高潮| 欧美日韩在线三级| 日韩欧美国产小视频| 精品对白一区国产伦| 欧美国产日本韩| 亚洲精品国产无天堂网2021| 午夜精品久久久久久久久| 老汉av免费一区二区三区 | 亚洲另类在线一区| 一区二区三区在线观看视频| 亚洲国产精品久久久男人的天堂 | 国产精品妹子av| 亚洲精品成人a在线观看| 亚洲成人免费影院| 免费高清不卡av| 国产成人自拍网| 91高清视频在线| 欧美电视剧免费全集观看| 久久精品夜色噜噜亚洲aⅴ| 国产精品久久久久久久久久久免费看 | 韩国av一区二区| www.亚洲免费av| 欧美日韩国产另类一区| 久久综合给合久久狠狠狠97色69| 国产精品毛片久久久久久久| 亚洲韩国一区二区三区| 精品在线观看免费| 日本精品一级二级| 久久夜色精品国产欧美乱极品| 亚洲欧美激情在线| 精品一区二区免费| 日本久久一区二区| 日韩美女久久久| 麻豆精品新av中文字幕| 99天天综合性| 精品成人佐山爱一区二区| 一区二区三区欧美日韩| 国产精品12区| 欧美一级黄色片| 亚洲自拍偷拍九九九|