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

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

?? os_sem.c

?? UCOS移植到三星ARM芯片S3C44B0上程序的范例,并有移植成功后的應用
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                                uC/OS-II
*                                          The Real-Time Kernel
*                                          SEMAPHORE MANAGEMENT
*
*                          (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* File : OS_SEM.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#ifndef  OS_MASTER_FILE
#include "includes.h"
#endif

#if OS_SEM_EN > 0
/*
*********************************************************************************************************
*                                           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,
*                         if 'pevent' is a NULL pointer or,
*                         if you didn't pass a pointer to a semaphore
*********************************************************************************************************
*/

#if OS_SEM_ACCEPT_EN > 0
INT16U  OSSemAccept (OS_EVENT *pevent)
{
#if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    OS_CPU_SR  cpu_sr;
#endif    
    INT16U     cnt;


#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
        return (0);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
    OS_ENTER_CRITICAL();
    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                        */
}
#endif    

/*$PAGE*/
/*
*********************************************************************************************************
*                                           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 (INT16U cnt)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    OS_EVENT  *pevent;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR             */
    }
    OS_ENTER_CRITICAL();
    pevent = OSEventFreeList;                              /* Get next free event control block        */
    if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empty   */
        OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
    }
    OS_EXIT_CRITICAL();
    if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
        pevent->OSEventType = OS_EVENT_TYPE_SEM;
        pevent->OSEventCnt  = cnt;                         /* Set semaphore value                      */
        pevent->OSEventPtr  = (void *)0;                   /* Unlink from ECB free list                */
#if OS_EVENT_NAME_SIZE > 0
        (void)strcpy(pevent->OSEventName, "?");
#endif
        OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem.   */
    }
    return (pevent);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         DELETE A SEMAPHORE
*
* Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
*
* Arguments  : pevent        is a pointer to the event control block associated with the desired
*                            semaphore.
*
*              opt           determines delete options as follows:
*                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
*                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waiting.
*                                                    In this case, all the tasks pending will be readied.
*
*              err           is a pointer to an error code that can contain one of the following values:
*                            OS_NO_ERR               The call was successful and the semaphore was deleted
*                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from an ISR
*                            OS_ERR_INVALID_OPT      An invalid option was specified
*                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphore
*                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
*                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
*
* Returns    : pevent        upon error
*              (OS_EVENT *)0 if the semaphore was successfully deleted.
*
* Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the presence of
*                 the semaphore MUST check the return code of OSSemPend().
*              2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
*                 they check 'pevent' to see that it's a NULL pointer.
*              3) This call can potentially disable interrupts for a long time.  The interrupt disable
*                 time is directly proportional to the number of tasks waiting on the semaphore.
*              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
*                 applications where the semaphore is used for mutual exclusion because the resource(s)
*                 will no longer be guarded by the semaphore.
*********************************************************************************************************
*/

#if OS_SEM_DEL_EN > 0
OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
    OS_CPU_SR  cpu_sr;
#endif    
    BOOLEAN    tasks_waiting;


    if (OSIntNesting > 0) {                                /* See if called from ISR ...               */
        *err = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR             */
        return (pevent);
    }
#if OS_ARG_CHK_EN > 0
    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
        *err = OS_ERR_PEVENT_NULL;
        return (pevent);
    }
#endif
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
    OS_ENTER_CRITICAL();
    if (pevent->OSEventGrp != 0x00) {                      /* See if any tasks waiting on semaphore    */
        tasks_waiting = TRUE;                              /* Yes                                      */
    } else {
        tasks_waiting = FALSE;                             /* No                                       */
    }
    switch (opt) {
        case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task waiting */
             if (tasks_waiting == FALSE) {
#if OS_EVENT_NAME_SIZE > 0
                 (void)strcpy(pevent->OSEventName, "?");   /* Unknown name                             */
#endif
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 pevent->OSEventCnt  = 0;
                 OSEventFreeList     = pevent;             /* Get next free event control block        */
                 OS_EXIT_CRITICAL();
                 *err                = OS_NO_ERR;
                 return ((OS_EVENT *)0);                   /* Semaphore has been deleted               */
             } else {
                 OS_EXIT_CRITICAL();
                 *err                = OS_ERR_TASK_WAITING;
                 return (pevent);
             }

        case OS_DEL_ALWAYS:                                /* Always delete the semaphore              */
             while (pevent->OSEventGrp != 0x00) {          /* Ready ALL tasks waiting for semaphore    */
                 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
             }
#if OS_EVENT_NAME_SIZE > 0
             (void)strcpy(pevent->OSEventName, "?");       /* Unknown name                             */
#endif
             OS_EventWaitListInit(pevent);                 /* Clear out the wait list                  */
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             pevent->OSEventCnt  = 0;
             OSEventFreeList     = pevent;                 /* Get next free event control block        */
             OS_EXIT_CRITICAL();
             if (tasks_waiting == TRUE) {                  /* Reschedule only if task(s) were waiting  */
                 OS_Sched();                               /* Find highest priority task ready to run  */
             }
             *err = OS_NO_ERR;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产高清在线观看视频| 国产欧美综合色| 欧美激情一区在线| 亚洲在线观看免费| 国产馆精品极品| 欧美日韩一二三区| 国产精品久久久久久久久免费樱桃| 亚洲成人7777| 99免费精品视频| 国产午夜亚洲精品羞羞网站| 日韩精品91亚洲二区在线观看| 欧美日韩一区国产| 亚洲伦在线观看| 成人午夜激情影院| 久久这里都是精品| 麻豆成人在线观看| 在线不卡免费欧美| 亚洲精品免费在线观看| 成人一级黄色片| 国产亚洲欧美一区在线观看| 免费高清不卡av| 91精品麻豆日日躁夜夜躁| 亚洲欧美激情插 | 91.xcao| 亚洲人精品一区| 91日韩精品一区| 国产精品福利在线播放| 成人毛片在线观看| 欧美激情在线一区二区| 国产精品正在播放| 久久蜜桃一区二区| 国产一区不卡视频| 久久欧美中文字幕| 国产精品影视网| 久久精品视频免费| 国产成人亚洲综合a∨婷婷| 久久女同互慰一区二区三区| 精品一区二区三区在线播放视频| 欧美刺激脚交jootjob| 蜜臀久久99精品久久久久宅男 | 91亚洲精品久久久蜜桃| 中文字幕乱码久久午夜不卡| 不卡视频免费播放| 亚洲精品视频观看| 国产亚洲va综合人人澡精品| 懂色中文一区二区在线播放| 国产精品伦理在线| 色婷婷精品久久二区二区蜜臀av| 亚洲自拍另类综合| 日韩视频123| 国产一区二区不卡在线| 国产三级精品三级在线专区| av不卡免费在线观看| 亚洲国产你懂的| 日韩精品专区在线| 成人黄页在线观看| 亚洲国产精品久久久男人的天堂| 欧美一区二区三区四区久久| 国产在线精品一区二区夜色| 中文字幕一区二区5566日韩| 欧美午夜宅男影院| 久久电影网电视剧免费观看| 国产欧美精品区一区二区三区 | 国产精品视频一区二区三区不卡| 99久久精品免费| 视频一区视频二区中文| 久久奇米777| 91国产视频在线观看| 麻豆精品国产传媒mv男同| 中文字幕av一区二区三区免费看| 在线亚洲免费视频| 国产一区二区女| 亚洲另类在线视频| 精品国产91乱码一区二区三区 | 色综合色综合色综合色综合色综合 | 91精品国产一区二区三区| 国产乱码精品一区二区三区忘忧草 | 日韩亚洲欧美中文三级| 99久久99久久精品国产片果冻| 丝袜诱惑制服诱惑色一区在线观看| 国产亚洲精品超碰| 91精品免费在线| 91丨九色丨蝌蚪丨老版| 经典三级视频一区| 亚洲福利视频一区二区| 国产精品污污网站在线观看 | 色94色欧美sute亚洲线路一久| 男人操女人的视频在线观看欧美| 中文字幕在线一区二区三区| 欧美xingq一区二区| 欧洲精品一区二区| www.欧美日韩国产在线| 久久国产精品99久久人人澡| 亚洲福利电影网| 国产精品第13页| 国产欧美一区二区精品性色超碰| 日韩欧美色综合网站| 欧美日韩在线直播| 色视频一区二区| youjizz国产精品| 国产精品系列在线观看| 久久99精品国产麻豆婷婷洗澡| 亚洲国产成人av| 亚洲一区二区欧美激情| 中文字幕综合网| 成人欧美一区二区三区视频网页| 久久伊人中文字幕| www一区二区| www国产成人| 精品久久久久久久久久久久包黑料 | 国产成人av在线影院| 久久99精品久久久久| 裸体健美xxxx欧美裸体表演| 日日噜噜夜夜狠狠视频欧美人| 亚洲第一狼人社区| 一级中文字幕一区二区| 亚洲一区二区三区不卡国产欧美| 一个色综合av| 亚洲成av人片在www色猫咪| 亚洲一区二区欧美| 日本在线不卡一区| 蜜臀av一区二区| 韩国女主播一区| 处破女av一区二区| 91免费国产在线观看| 日本精品视频一区二区三区| 91黄色激情网站| 欧美疯狂性受xxxxx喷水图片| 91精品久久久久久久久99蜜臂| 欧美一区二区免费观在线| 精品免费99久久| 国产精品久久久久久久久图文区 | 亚洲一区二区精品3399| 午夜伦欧美伦电影理论片| 日本成人在线一区| 国产精品一区二区在线观看不卡| 国产福利一区二区| 91精品视频网| 国产日韩三级在线| 亚洲免费看黄网站| 视频一区在线播放| 国产大陆精品国产| 色综合天天天天做夜夜夜夜做| 欧美色图12p| www国产精品av| 亚洲视频一二三| 日本视频一区二区三区| 国产成人亚洲综合a∨婷婷| 91视视频在线观看入口直接观看www| 欧美图片一区二区三区| 欧美电影免费观看高清完整版在 | 制服丝袜在线91| 国产午夜精品一区二区三区嫩草| 1024亚洲合集| 日韩中文字幕亚洲一区二区va在线 | 欧美性三三影院| 欧美一二三在线| 亚洲视频免费在线观看| 爽好多水快深点欧美视频| 国模少妇一区二区三区| 99热精品一区二区| 日韩三级免费观看| 亚洲美女偷拍久久| 国产一区二区三区黄视频 | 国产精品萝li| 奇米色一区二区| 91免费在线看| 国产日本亚洲高清| 图片区小说区国产精品视频| 粉嫩久久99精品久久久久久夜| 欧美精品成人一区二区三区四区| 欧美高清在线视频| 99久久综合狠狠综合久久| 欧美日韩色综合| 国产精品成人网| 国产美女精品人人做人人爽| 欧美日韩在线播| 综合色中文字幕| 国产福利一区二区三区| 欧美一区二区三区婷婷月色| 亚洲色图制服丝袜| 国产一区二区三区四区五区美女 | 国产精品久久久久久久久图文区 | 91精品国产高清一区二区三区| 中文字幕一区在线观看视频| 国产在线精品一区二区不卡了| 欧美老肥妇做.爰bbww视频| 亚洲六月丁香色婷婷综合久久| 不卡av在线网| 亚洲国产精品传媒在线观看| 国产美女精品一区二区三区| 日韩精品中午字幕| 免费在线一区观看| 欧美一级片在线| 日本亚洲电影天堂| 欧美一级国产精品| 蜜臀av一区二区在线观看| 欧美巨大另类极品videosbest| 亚洲第一成年网| 91.麻豆视频|