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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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一区二区三区免费野_久草精品视频
www.亚洲激情.com| 成人久久视频在线观看| 亚洲裸体xxx| 中文字幕人成不卡一区| 国产精品二三区| 亚洲欧美激情一区二区| 亚洲免费资源在线播放| 亚洲一区在线免费观看| 亚洲国产一区二区三区| 亚洲国产精品久久久久婷婷884| 亚洲精品一卡二卡| 亚洲最色的网站| 国产成人综合在线| 国产91丝袜在线播放0| 国产91综合网| 日本黄色一区二区| 欧美日韩一本到| 欧美成人女星排名| 国产日本一区二区| 亚洲欧美日韩国产一区二区三区| 一区二区三区日韩欧美| 天天综合色天天| 国产一区二区三区四区五区美女| 国产麻豆欧美日韩一区| 91在线看国产| 日韩一级免费观看| 亚洲国产成人一区二区三区| 亚洲女人小视频在线观看| 亚洲成va人在线观看| 六月婷婷色综合| 99久久亚洲一区二区三区青草| 欧美网站大全在线观看| 精品国产一区二区精华| ●精品国产综合乱码久久久久| 一区二区成人在线观看| 激情综合色播五月| 色偷偷一区二区三区| 精品国产乱码久久久久久浪潮| 欧美经典一区二区| 日韩二区三区在线观看| 99久久婷婷国产综合精品| 在线播放日韩导航| 亚洲日本丝袜连裤袜办公室| 奇米影视一区二区三区| 一本一道久久a久久精品综合蜜臀| 91精品国产综合久久香蕉麻豆 | 91啪亚洲精品| 欧美大尺度电影在线| 亚洲猫色日本管| 国产精品一区二区三区网站| 欧美日韩在线免费视频| 国产精品久久久久久久岛一牛影视| 亚洲国产毛片aaaaa无费看| 懂色av中文一区二区三区| 91精品免费观看| 伊人性伊人情综合网| 国产麻豆午夜三级精品| 日韩一区二区三区在线视频| 一区二区三区在线视频免费| 丁香一区二区三区| 久久影院视频免费| 蜜臀久久99精品久久久画质超高清| 日本高清不卡视频| 亚洲三级免费电影| 成人精品一区二区三区四区| 久久婷婷色综合| 精品制服美女丁香| 日韩欧美精品三级| 日产精品久久久久久久性色| 欧美日韩久久不卡| 亚洲国产精品久久不卡毛片| 成人深夜视频在线观看| 日本一区二区三区四区在线视频| 久草这里只有精品视频| 日韩免费观看2025年上映的电影| 日日夜夜一区二区| 欧美日韩一区二区在线观看| 一区二区三区欧美久久| 一道本成人在线| 亚洲自拍偷拍av| 欧美在线|欧美| 亚洲与欧洲av电影| 欧美日韩国产一级片| 亚洲午夜精品网| 555www色欧美视频| 免费欧美在线视频| 久久久久国产精品人| 国产不卡视频一区二区三区| 中文字幕av免费专区久久| 波多野结衣的一区二区三区| 亚洲美女屁股眼交3| 一本色道亚洲精品aⅴ| 一级日本不卡的影视| 欧美日韩夫妻久久| 精品一区二区三区在线观看国产| 久久综合久久综合久久综合| 成人免费不卡视频| 亚洲精品成人在线| 欧美一激情一区二区三区| 国产一区二区在线观看视频| 中文字幕不卡三区| 欧美日韩午夜在线| 久久不见久久见中文字幕免费| 国产欧美日韩精品在线| 色先锋aa成人| 韩国欧美国产1区| 国产精品不卡在线| 91精品国产综合久久久久| 国产精品一区二区在线观看网站| 国产精品毛片高清在线完整版 | 综合久久一区二区三区| 欧洲激情一区二区| 国产永久精品大片wwwapp| 1024成人网| 日韩欧美国产高清| 色综合久久综合网97色综合 | 精东粉嫩av免费一区二区三区| 国产欧美日韩精品一区| 9191精品国产综合久久久久久 | 成人黄色免费短视频| 日韩中文字幕不卡| 亚洲视频免费观看| 亚洲精品一区二区三区影院| 色播五月激情综合网| 国产经典欧美精品| 日韩精品一二三区| 一区二区三区在线视频播放| 久久精品综合网| 日韩欧美一区在线| 欧美日韩精品欧美日韩精品| 成人激情图片网| 国产一区二区三区最好精华液| 亚洲国产精品一区二区www| 国产精品日日摸夜夜摸av| 日韩一区二区免费电影| 在线观看国产日韩| 99久精品国产| 成人丝袜18视频在线观看| 国产一区欧美二区| 开心九九激情九九欧美日韩精美视频电影| 亚洲美女免费在线| 国产精品乱人伦中文| 国产偷国产偷精品高清尤物| 欧美电影免费观看高清完整版| 欧美亚州韩日在线看免费版国语版| 成人福利在线看| 成人午夜视频免费看| 国产精品99久久久久久久女警| 久久国产精品第一页| 日本色综合中文字幕| 天天av天天翘天天综合网 | 寂寞少妇一区二区三区| 日韩中文字幕麻豆| 婷婷成人综合网| 日韩av一区二区在线影视| 秋霞午夜鲁丝一区二区老狼| 调教+趴+乳夹+国产+精品| 日韩av一区二| 狠狠色综合播放一区二区| 国产精品一区免费视频| 国产a区久久久| 99精品视频免费在线观看| 99久久免费精品高清特色大片| 成人av资源在线| 在线观看日产精品| 91精品国产欧美一区二区18| 精品久久久三级丝袜| 国产人伦精品一区二区| 国产精品卡一卡二| 一区二区免费视频| 日韩va亚洲va欧美va久久| 高清beeg欧美| 色综合久久99| 日韩一二三区不卡| 国产人妖乱国产精品人妖| 亚洲欧洲一区二区在线播放| 一区二区三区免费| 久久精品国产999大香线蕉| 国产麻豆精品在线观看| 91免费版在线看| 91精品国产色综合久久不卡蜜臀 | 不卡视频一二三四| 欧美伊人久久久久久午夜久久久久| 欧美日韩国产三级| 久久久久久久av麻豆果冻| 亚洲丝袜精品丝袜在线| 青青草精品视频| 成人aaaa免费全部观看| 欧美日韩成人在线| 国产欧美日韩一区二区三区在线观看| 中文字幕一区二区在线观看| 天堂一区二区在线| 粉嫩高潮美女一区二区三区| 欧美日韩国产成人在线免费| 国产亚洲一区二区三区在线观看 | 久久成人麻豆午夜电影| 97精品国产露脸对白| 日韩午夜中文字幕| 亚洲天堂2016| 精品亚洲国产成人av制服丝袜|