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

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

?? os_sem.c

?? 三星公司S3C2410處理器平臺上的ucos內核源代碼
?? 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 "uC_OS.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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
        return (0);
    }
#endif
    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                */
        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);
    }
    if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type                */
        *err = OS_ERR_EVENT_TYPE;
        return (pevent);
    }
#endif
    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) {
                 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
                 pevent->OSEventPtr  = OSEventFreeList;    /* Return Event Control Block to free list  */
                 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);
             }
             pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
             pevent->OSEventPtr  = OSEventFreeList;        /* Return Event Control Block to free list  */
             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;
             return ((OS_EVENT *)0);                       /* Semaphore has been deleted               */

        default:
             OS_EXIT_CRITICAL();
             *err = OS_ERR_INVALID_OPT;
             return (pevent);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产电影一区在线| 国产一区二区视频在线| 国产精品久久久久久久久免费桃花| 91精品免费观看| 欧美日韩一级黄| 欧美精品久久一区二区三区 | 欧美变态凌虐bdsm| 日韩欧美二区三区| 久久综合久久鬼色中文字| 精品日产卡一卡二卡麻豆| 欧美成人精品1314www| 欧美videos大乳护士334| 精品国产凹凸成av人导航| 久久综合九色欧美综合狠狠| 久久亚洲春色中文字幕久久久| 2017欧美狠狠色| 国产精品免费网站在线观看| 自拍偷拍亚洲欧美日韩| 亚洲妇女屁股眼交7| 日韩高清国产一区在线| 国内精品在线播放| 不卡高清视频专区| 欧美色网站导航| 亚洲精品在线电影| 国产精品乱码妇女bbbb| 亚洲男人都懂的| 肉色丝袜一区二区| 国产精品一区二区三区网站| 91视频com| 日韩视频一区二区三区在线播放 | 成人国产精品免费观看动漫| 99re视频精品| 精品久久人人做人人爰| 亚洲色欲色欲www| 捆绑调教美女网站视频一区| 国产电影一区在线| 欧美久久久一区| 国产精品福利电影一区二区三区四区| 亚洲成人黄色小说| 成人性生交大片免费看视频在线| 在线国产亚洲欧美| 国产欧美综合在线| 免费人成在线不卡| 91美女福利视频| 久久夜色精品一区| 爽好多水快深点欧美视频| 国产成人夜色高潮福利影视| 制服丝袜日韩国产| 亚洲一区二区三区国产| 不卡的av在线| 久久综合色播五月| 男女视频一区二区| 欧美综合欧美视频| 中文字幕日本不卡| 成人中文字幕在线| 精品国产电影一区二区| 亚洲成在人线免费| 91精彩视频在线| 亚洲视频免费在线| av不卡在线观看| 欧美韩日一区二区三区四区| 精品一区精品二区高清| 欧美日韩中文精品| 一区二区三区在线播放| 99精品视频中文字幕| 欧美国产精品专区| 国产成人av一区二区三区在线观看| 日韩一区二区三区高清免费看看| 一区二区欧美精品| 欧美系列亚洲系列| 午夜婷婷国产麻豆精品| 欧美日韩激情一区二区| 亚洲成人综合网站| 欧美精品精品一区| 丝袜脚交一区二区| 日韩午夜av一区| 免费高清在线一区| 精品国产乱子伦一区| 国产一区三区三区| 久久亚洲精品国产精品紫薇| 国产精品一区二区视频| 国产精品免费视频网站| 99精品视频一区| 亚洲精品欧美专区| 欧美日韩大陆在线| 久久国产精品一区二区| 久久久久成人黄色影片| 丰满亚洲少妇av| 亚洲天堂福利av| 欧美日精品一区视频| 日韩av电影免费观看高清完整版在线观看 | 555www色欧美视频| 免费视频一区二区| 久久久美女毛片| 91免费观看视频| 亚洲已满18点击进入久久| 欧美日韩国产一级片| 久久爱www久久做| 国产精品久久久一区麻豆最新章节| 99久久婷婷国产综合精品电影| 亚洲一区二区三区在线| 欧美一级午夜免费电影| 成人污污视频在线观看| 一区二区三区四区精品在线视频| 在线不卡中文字幕| 国产精品 欧美精品| 亚洲一区影音先锋| 久久久五月婷婷| 一本久道中文字幕精品亚洲嫩| 亚洲成人资源网| 国产喂奶挤奶一区二区三区| 欧美在线999| 国产露脸91国语对白| 一区二区高清在线| 国产亚洲精品aa午夜观看| 欧美色国产精品| 国产成a人亚洲精| 午夜欧美一区二区三区在线播放 | 国产一区二区成人久久免费影院| 日韩一区在线看| 精品国产乱码久久久久久图片 | 天堂av在线一区| 欧美激情综合在线| 这里是久久伊人| 91无套直看片红桃| 国产精品888| 日韩vs国产vs欧美| 亚洲一区欧美一区| 中文字幕在线一区免费| 26uuu国产电影一区二区| 在线观看免费视频综合| 成人免费高清视频| 激情国产一区二区| 日韩av不卡一区二区| 亚洲综合男人的天堂| 亚洲啪啪综合av一区二区三区| 26uuu久久天堂性欧美| 欧美嫩在线观看| 色婷婷亚洲婷婷| 国产成人午夜高潮毛片| 国产一区二区视频在线| 久久99热这里只有精品| 青青草国产精品97视觉盛宴| 亚洲va欧美va国产va天堂影院| 亚洲综合在线免费观看| 中文字幕一区二区三区四区| 中文av字幕一区| 欧美经典一区二区| 久久久蜜臀国产一区二区| 亚洲精品一区二区三区在线观看| 91精品国产91久久久久久最新毛片 | 一区二区免费看| 亚洲精品国产精华液| 亚洲精品欧美专区| 亚洲六月丁香色婷婷综合久久| 亚洲男人天堂av网| 亚洲国产三级在线| 天天av天天翘天天综合网 | 七七婷婷婷婷精品国产| 日韩精品欧美精品| 精品一区二区国语对白| 国产在线精品一区二区| 国产91高潮流白浆在线麻豆| 成人免费视频播放| 色婷婷国产精品综合在线观看| 色999日韩国产欧美一区二区| 欧美中文字幕一区二区三区亚洲| 欧美色综合网站| 欧美一区二区三区免费| ww亚洲ww在线观看国产| 中文字幕欧美国产| 亚洲欧美电影一区二区| 亚洲成a人片在线观看中文| 免费视频一区二区| 成人免费观看视频| 色国产精品一区在线观看| 91精品国产日韩91久久久久久| 久久精品视频网| 亚洲免费资源在线播放| 日韩高清不卡在线| 国产福利一区在线观看| 色欧美88888久久久久久影院| 91精品国产欧美一区二区成人 | 欧美日韩中字一区| 337p日本欧洲亚洲大胆精品| 中文字幕佐山爱一区二区免费| 亚洲成av人片在线| 成人性生交大合| 欧美日韩国产精品自在自线| 国产亚洲成aⅴ人片在线观看| 亚洲精品日韩综合观看成人91| 久久精品理论片| 色拍拍在线精品视频8848| 日韩午夜激情av| 亚洲精品国产a| 国产在线不卡视频| 欧美高清精品3d| 日韩久久一区二区| 狠狠色狠狠色综合| 欧美精选一区二区|