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

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

?? os-task-switch.c

?? ucos-ii-at90S-icc-avr
?? C
?? 第 1 頁 / 共 2 頁
字號:
{
    OS_ENTER_CRITICAL();
    if ((--OSIntNesting | OSLockNesting) == 0) { /* Reschedule only if all ISRs completed & not locked */
        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)||(0==OSTCBCur)||
			   (OSPrioCur>OS_LOWEST_PRIO)||(OSPrioHighRdy>OS_LOWEST_PRIO))
			  OSError(0);
#endif			
            OSDebug();
            OSIntCtxSw();                        /* Perform interrupt level context switch             */
        }//end OSPrioHighRdy != OSPrioCur
    }//end nesting==0
    OS_EXIT_CRITICAL();
}

void OSDebug(void)
{
INT8U port_a;
            //debug
			DDRA=0;port_a=PORTA;
			DDRA=0xff;PORTA=~port_a;
			//end debug
}

/*
*********************************************************************************************************
*                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
*
* Description: This function is called by other uC/OS-II services and is used to ready a task that was
*              waiting for an event to occur.
*
* Arguments  : pevent    is a pointer to the event control block corresponding to the event.
*
*              msg       is a pointer to a message.  This pointer is used by message oriented services
*                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
*                        service functions.
*
*              msk       is a mask that is used to clear the status byte of the TCB.  For example,
*                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
*
* Returns    : none
*
* Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
*********************************************************************************************************
*/
#if OS_EVENT_EN

/*init event structure*/
void  OSEventInit(OS_EVENT *pevent)
{
	INT8U i;
	if(0==pevent)
		return;
    for(i=0;i<OS_TASK_COUNT;i++)
		pevent->OSTaskTbl[i]=0;
    pevent->OSEventCnt=0;
    pevent->OSEventType=OS_EVENT_TYPE_INVALID;                   /* OS_EVENT_TYPE_MBOX, OS_EVENT_TYPE_Q or OS_EVENT_TYPE_SEM */
}

/*get highest prio from event's waiting task list,
  ignore OSTCBStat and OSTCBDly.
  Find first tcb in pevent->OSTaskTbl which is not null*/
INT8U OSEventGetHighPrioRdy(OS_EVENT *pevent)
{
	INT8U i;
	OS_TCB *ptcb;
	if(0==pevent)
		return OS_TASK_COUNT;//error
    for(i=0;i<OS_TASK_COUNT;i++)
	{
		ptcb=pevent->OSTaskTbl[i];
		if(ptcb)
		{
			return ptcb->OSTCBPrio;
		}
	}
	return OS_TASK_COUNT;//error
}

/*when OSSemPend success,call OSEventTaskRdy to remove task from event waitting task list*/
void  OSEventTaskRdy (OS_EVENT *pevent, INT8U msk)
{
    OS_TCB *ptcb;
    INT8U   prio;

	prio=OSEventGetHighPrioRdy(pevent);
#if OS_STRICT
	if(prio>OS_LOWEST_PRIO)
		OSError(0);
#endif
    ptcb                 =  OSpTCBList[prio];       /* Point to this task's OS_TCB                   */
#if OS_STRICT
	if(0==ptcb)
		OSError(0);
#endif
	//clear event flags
    ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
    ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
}


/*
*********************************************************************************************************
*                                   MAKE TASK WAIT FOR EVENT TO OCCUR
*
* Description: This function is called by other uC/OS-II services to suspend a task because an event has
*              not occurred.
*
* Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
*
* Returns    : none
*
* Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
*********************************************************************************************************
*/
void  OSEventTaskWait (OS_EVENT *pevent)
{
#if OS_STRICT
	if(!OSTCBCur)
		OSError(0);
#endif
}
/*
*********************************************************************************************************
*                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
*
* Description: This function is called by other uC/OS-II services to make a task ready to run because a
*              timeout occurred.
*
* Arguments  : pevent   is a pointer to the event control block which is readying a task.
*
* Returns    : none
*
* Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
*********************************************************************************************************
*/
void  OSEventTO (OS_EVENT *pevent)
{
    OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
}
#endif//OS_EVENT_EN

#if OS_SEM_EN
/*
*********************************************************************************************************
*                                           ACCEPT SEMAPHORE
*
* Description: This function checks the semaphore to see if a resource is available or, if an event
*              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
*              resource is not available or the event did not occur.
*
* Arguments  : pevent     is a pointer to the event control block
*
* Returns    : >  0       if the resource is available or the event did not occur the semaphore is
*                         decremented to obtain the resource.
*              == 0       if the resource is not available or the event did not occur or,
*                         you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/
INT16U OSSemAccept (OS_EVENT *pevent)
{
    INT16U cnt;

    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        return (0);
    }
    cnt = pevent->OSEventCnt;
    if (cnt > 0) {                                    /* See if resource is available                  */
        pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
    }
    OS_EXIT_CRITICAL();
    return (cnt);                                     /* Return semaphore count                        */
}

/*
*********************************************************************************************************
*                                           CREATE A SEMAPHORE
*
* Description: This function creates a semaphore.
*
* Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resource is
*                            available (or no event has occurred).  You initialize the semaphore to a 
*                            non-zero value to specify how many resources are available (e.g. if you have
*                            10 resources, you would initialize the semaphore to 10).
*
* Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
*                            created semaphore
*              == (void *)0  if no event control blocks were available
*********************************************************************************************************
*/

OS_EVENT *OSSemCreate (OS_EVENT *pevent,INT16U cnt)
{
    if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
        OSEventInit(pevent);
		pevent->OSEventType = OS_EVENT_TYPE_SEM;
        pevent->OSEventCnt  = cnt;                         /* Set semaphore value                      */
    }
    return (pevent);
}
//called by OSSemPend to remove current tcb from event's waitting task list
void OSEventRemoveCurrentTCB(OS_EVENT *pevent)
{
#if OS_STRICT
	if((0==pevent)||(OSPrioCur>OS_LOWEST_PRIO)||(OSTCBCur==0))
		OSError(0);
	if(pevent->OSTaskTbl[OSPrioCur]==0)
		OSError(0);
#endif
	pevent->OSTaskTbl[OSPrioCur]=0;
}

/*
*********************************************************************************************************
*                                           PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
*              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
*                            wait for the resource up to the amount of time specified by this argument.  
*                            If you specify 0, however, your task will wait forever at the specified 
*                            semaphore or, until the resource becomes available (or the event occurs).
*
*              err           is a pointer to where an error message will be deposited.  Possible error
*                            messages are:
*
*                            OS_NO_ERR          The call was successful and your task owns the resource 
*                                               or, the event you are waiting for occurred.
*                            OS_TIMEOUT         The semaphore was not received within the specified 
*                                               timeout.
*                            OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore.
*                            OS_ERR_PEND_ISR    If you called this function from an ISR and the result
*                                               would lead to a suspension.
*
* Returns    : none
*********************************************************************************************************
*/

void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        OS_EXIT_CRITICAL();
        *err = OSERR_EVENT_TYPE;
    }
    if (pevent->OSEventCnt > 0) {                     /* If sem. is positive, resource available ...   */
        pevent->OSEventCnt--;                         /* ... decrement semaphore only if positive.     */
        OS_EXIT_CRITICAL();
        *err = OS_NO_ERR;
    } else if (OSIntNesting > 0) {                    /* See if called from ISR ...                    */
        OS_EXIT_CRITICAL();                           /* ... can't PEND from an ISR                    */
        *err = OSERR_PEND_ISR;
    } else {                                          /* Otherwise, must wait until event occurs       */
        OSTCBCur->OSTCBStat    |= OS_STAT_SEM;        /* Resource not available, pend on semaphore     */
        OSTCBCur->OSTCBDly      = timeout;            /* Store pend timeout in TCB                     */
        OSEventTaskWait(pevent);                      /* Suspend task until event or timeout occurs    */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find next highest priority task ready         */
        OS_ENTER_CRITICAL();
        OSEventRemoveCurrentTCB(pevent);
        if (OSTCBCur->OSTCBStat & OS_STAT_SEM) {      /* Must have timed out if still waiting for event*/
            OSEventTO(pevent);
            OS_EXIT_CRITICAL();
            *err = OSERR_TIMEOUT;                        /* Indicate that didn't get event within TO      */
        } else {
            OS_EXIT_CRITICAL();
            *err = OS_NO_ERR;
        }
    }
}

/*
*********************************************************************************************************
*                                         POST TO A SEMAPHORE
*
* Description: This function signals a semaphore
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired 
*                            semaphore.
*
* Returns    : OS_NO_ERR          The call was successful and the semaphore was signaled.
*              OS_SEM_OVF         If the semaphore count exceeded its limit.  In other words, you have 
*                                 signalled the semaphore more often than you waited on it with either
*                                 OSSemAccept() or OSSemPend().
*              OS_ERR_EVENT_TYPE  If you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

INT8U OSSemPost (OS_EVENT *pevent)
{
	INT8U prio;
    OS_ENTER_CRITICAL();
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        OS_EXIT_CRITICAL();
        return (OSERR_EVENT_TYPE);
    }
    prio=OSEventGetHighPrioRdy(pevent);
    if (prio<=OS_LOWEST_PRIO) {                              /* See if any task waiting for semaphore    */
        OSEventTaskRdy(pevent,OS_STAT_SEM);    /* Ready highest prio task waiting on event */
        OS_EXIT_CRITICAL();
        OSSched();                                    /* Find highest priority task ready to run       */
        return (OS_NO_ERR);
    } else {
        if (pevent->OSEventCnt < 65535) {             /* Make sure semaphore will not overflow         */
            pevent->OSEventCnt++;                     /* Increment semaphore count to register event   */
            OS_EXIT_CRITICAL();
            return (OS_NO_ERR);
        } else {                                      /* Semaphore value has reached its maximum       */
            OS_EXIT_CRITICAL();
            return (OSERR_SEM_OVF);
        }
    }
}

#endif//OS_SEM_EN

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av不卡在线观看| 久久精品国产亚洲a| 亚洲超碰精品一区二区| 久久国产尿小便嘘嘘| 色综合天天性综合| 91精品国产一区二区三区 | 日本aⅴ免费视频一区二区三区| 蜜臀精品一区二区三区在线观看| 成人深夜在线观看| 91精品国产品国语在线不卡| 国产精品福利一区二区| 麻豆专区一区二区三区四区五区| 成人一道本在线| 日韩一区二区影院| 一区二区免费看| 成人午夜视频在线观看| 日韩美女天天操| 亚洲gay无套男同| 91一区二区在线观看| 国产无遮挡一区二区三区毛片日本| 亚洲一区在线看| 99国产欧美久久久精品| 久久精品日韩一区二区三区| 日韩精品乱码免费| 欧美日韩一级二级三级| 最新高清无码专区| 不卡一二三区首页| 国产午夜精品美女毛片视频| 美腿丝袜亚洲三区| 欧美久久久久久蜜桃| 亚洲精品第一国产综合野| 成人一区二区视频| 国产欧美一区二区精品忘忧草 | 欧美日韩1234| 一区二区三区精品视频在线| av中文字幕不卡| 日本一区二区免费在线观看视频| 久久精品国产99| 日韩欧美高清一区| 美国毛片一区二区| 日韩一区二区三区观看| 蜜桃av噜噜一区| 欧美大胆人体bbbb| 久久99久久久久| 精品国产乱码久久久久久闺蜜| 日韩高清在线观看| 日韩精品一区二区三区视频播放| 蜜臀99久久精品久久久久久软件| 欧美一区二区三区在线观看| 五月综合激情日本mⅴ| 欧美日韩另类一区| 美日韩一区二区| 精品捆绑美女sm三区| 国产成人在线视频播放| 国产精品久久久久影院| 91网站黄www| 亚洲国产色一区| 在线播放国产精品二区一二区四区| 日韩国产欧美视频| 精品奇米国产一区二区三区| 蜜桃精品视频在线| 久久久精品蜜桃| 一本在线高清不卡dvd| 亚洲欧美激情插 | 成人免费视频视频在线观看免费| 国产精品久久久久影院老司 | 欧美mv日韩mv国产网站app| 韩国精品一区二区| 亚洲人123区| 日韩一级大片在线| 国产不卡视频在线观看| 亚洲黄色在线视频| 欧美mv日韩mv国产| 91一区二区三区在线观看| 亚洲国产精品精华液网站| 久久综合色鬼综合色| 99久久综合色| 久久精品久久综合| 《视频一区视频二区| 日韩一区二区在线观看| 99国产精品久久久久久久久久| 成人网页在线观看| 午夜免费欧美电影| 国产精品国产自产拍高清av王其| 欧美日韩中字一区| 高清成人免费视频| 日韩经典中文字幕一区| 亚洲欧洲99久久| 精品av久久707| 欧美日韩一区中文字幕| 国产成人综合亚洲网站| 日韩一区精品视频| 综合在线观看色| 久久老女人爱爱| 欧美一区二区三区视频免费 | 日韩美一区二区三区| 99久久久国产精品免费蜜臀| 精品一区二区三区在线播放视频 | 精品一区二区在线视频| 亚洲一区中文日韩| 1区2区3区精品视频| 久久久久久**毛片大全| 欧美一二三四区在线| 欧美午夜精品一区二区三区| 国产.欧美.日韩| 国产乱码精品一区二区三| 日韩va亚洲va欧美va久久| 亚洲激情在线播放| 亚洲天堂成人在线观看| 国产欧美日韩在线| 久久亚区不卡日本| 欧美mv和日韩mv国产网站| 日韩欧美激情在线| 欧美一级免费观看| 欧美日韩国产一二三| 在线观看国产一区二区| 一本大道久久a久久精二百| 成人美女视频在线观看| 国产剧情一区二区| 国产精品综合久久| 国产精品一区不卡| 国产高清精品网站| 国产精品一区二区久久精品爱涩 | 亚洲综合999| 亚洲午夜视频在线观看| 亚洲综合小说图片| 亚洲国产成人高清精品| 日日摸夜夜添夜夜添国产精品 | 亚洲影视在线观看| 亚洲综合精品自拍| 亚洲国产成人tv| 日本不卡的三区四区五区| 男女男精品视频| 国产麻豆精品一区二区| 国产精品一区二区在线看| 欧美视频在线一区| 91精品国产色综合久久| 欧美mv和日韩mv国产网站| 久久久久久久网| 中文av一区二区| 亚洲黄色小视频| 日韩不卡一二三区| 国产麻豆日韩欧美久久| www.欧美色图| 欧美三级日韩在线| 精品少妇一区二区三区| 国产欧美一区二区精品忘忧草| 亚洲欧洲一区二区在线播放| 一二三区精品福利视频| 日韩成人av影视| 国产白丝网站精品污在线入口| 91免费版在线看| 日韩欧美一级二级三级久久久| 日本一区二区在线不卡| 一区二区三区久久| 国内精品视频666| 色综合久久中文字幕综合网| 欧美精品第1页| 久久精品水蜜桃av综合天堂| 亚洲蜜臀av乱码久久精品蜜桃| 天天操天天色综合| 成人精品一区二区三区中文字幕| 在线观看精品一区| 久久精品视频在线看| 亚洲aaa精品| 成人免费视频免费观看| 欧美日韩和欧美的一区二区| 久久这里只有精品首页| 一区二区三国产精华液| 老司机精品视频线观看86| www.欧美.com| 精品国产百合女同互慰| 亚洲一区日韩精品中文字幕| 国产制服丝袜一区| 欧美日韩日本视频| 国产精品美女久久久久久久网站| 日韩精品欧美精品| 91尤物视频在线观看| 26uuu亚洲综合色| 午夜精品久久久久久久99樱桃| 成人在线综合网| 26uuu精品一区二区| 日韩黄色在线观看| 日本韩国精品一区二区在线观看| 国产亚洲自拍一区| 久久精品噜噜噜成人av农村| 欧美日韩黄视频| 亚洲男人的天堂在线aⅴ视频| 国产精品综合在线视频| 日韩欧美一二三| 日韩高清不卡一区二区| 欧美三级视频在线| 一区二区成人在线观看| 91免费在线看| 最好看的中文字幕久久| 99久久婷婷国产综合精品| 久久一区二区三区四区| 黄页视频在线91| 久久久久久影视| 国产传媒欧美日韩成人|