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

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

?? os_sem.c

?? 基于uCOS-II 的MMC/SD卡的讀寫源程序
?? 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);
    }
    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一区二区三区免费野_久草精品视频
中文字幕av一区二区三区免费看 | av不卡一区二区三区| 精品国产一区二区三区四区四| 亚洲国产欧美在线| 色先锋aa成人| 一区二区三区精品| 欧美最猛性xxxxx直播| 国产精品私人影院| 91麻豆文化传媒在线观看| 一区二区三区中文字幕电影| 色婷婷综合久久久中文字幕| 亚洲视频资源在线| 91免费在线播放| 亚洲一二三级电影| 欧美日韩午夜在线视频| 三级不卡在线观看| 亚洲精品在线免费观看视频| 舔着乳尖日韩一区| 欧美日韩在线不卡| 久久成人羞羞网站| 国产精品乱子久久久久| 91首页免费视频| 亚洲综合在线第一页| 大白屁股一区二区视频| 夜夜嗨av一区二区三区网页| 欧美日韩一区三区| 国产在线播精品第三| 国产精品嫩草影院av蜜臀| 欧美少妇xxx| 国产麻豆91精品| 一区二区三区在线观看动漫| 欧美一区二区视频免费观看| 国产黄色精品网站| 五月综合激情日本mⅴ| 国产日韩欧美综合在线| 欧美色网一区二区| 丁香五精品蜜臀久久久久99网站| 一区二区三区欧美| 国产日产欧美一区二区视频| 欧美三级视频在线观看| 高清国产一区二区| 日本亚洲最大的色成网站www| 中文字幕免费不卡| 日韩精品一区二区三区在线观看 | 国产精品盗摄一区二区三区| 欧美撒尿777hd撒尿| 成人一二三区视频| 国产精品77777竹菊影视小说| 亚洲成人av福利| 亚洲自拍偷拍av| 亚洲精品国久久99热| 国产精品久久久一本精品 | 亚洲视频免费在线观看| 国产欧美日韩另类一区| 91精品国产一区二区三区| 国产激情一区二区三区| 成人深夜在线观看| 欧美卡1卡2卡| 一区二区在线免费观看| 精品一区免费av| 国产九色sp调教91| 欧美嫩在线观看| 91九色最新地址| 91国在线观看| 精品国偷自产国产一区| 久久久久久久国产精品影院| 国产精品久久久久一区二区三区共 | 99国产精品99久久久久久| 色综合久久久久综合体| 欧美区视频在线观看| 国产亚洲视频系列| 亚洲自拍另类综合| 国产99久久久国产精品| 在线观看网站黄不卡| 2020国产精品自拍| 亚洲高清免费在线| 成人福利视频在线看| 欧美日韩一区二区三区免费看| 久久蜜臀精品av| 亚洲国产精品视频| 91精品黄色片免费大全| 国产女人aaa级久久久级| 欧美国产日产图区| 亚洲黄色av一区| 国产精品久久福利| 国产精品美日韩| 蜜桃一区二区三区四区| 久久er精品视频| 国产一区日韩二区欧美三区| jlzzjlzz国产精品久久| 精品国产乱码久久久久久闺蜜| 亚洲精品成人精品456| 国产在线精品一区二区不卡了| 99热99精品| 国产精品免费视频网站| 国产精品一区二区视频| 欧美第一区第二区| 免费观看久久久4p| 日韩一区二区三区四区| 婷婷夜色潮精品综合在线| 日本二三区不卡| 一区二区视频在线| 91免费看`日韩一区二区| 国产午夜精品福利| 国产一区二区伦理| 欧美激情在线一区二区| 国产在线麻豆精品观看| 日韩欧美亚洲国产另类| 麻豆91精品视频| 久久综合色之久久综合| 成人性生交大片免费看视频在线| 国产亚洲成av人在线观看导航| 国产激情视频一区二区三区欧美| 久久精品网站免费观看| 菠萝蜜视频在线观看一区| 亚洲精品水蜜桃| 欧美日韩国产天堂| 精彩视频一区二区| 欧美国产精品专区| 欧美三级电影网站| 国产精品一区一区三区| 亚洲精品中文字幕乱码三区| 欧美伊人精品成人久久综合97| 99久久婷婷国产综合精品 | 色综合久久久久综合体| 天天av天天翘天天综合网| 国产午夜精品一区二区三区视频| 99久久精品国产麻豆演员表| 中文字幕日韩欧美一区二区三区| 91精品啪在线观看国产60岁| 国产精品一区二区久久精品爱涩 | 午夜欧美视频在线观看| 亚洲一区在线播放| 日日夜夜精品视频免费| 日本一区中文字幕| 韩国女主播一区二区三区| 激情五月激情综合网| 日本不卡不码高清免费观看| 婷婷久久综合九色综合绿巨人| 亚洲va韩国va欧美va| 亚洲欧美偷拍三级| 中文字幕欧美国产| 久久久久88色偷偷免费| 久久亚洲综合色一区二区三区| 欧美精品高清视频| 精品国产凹凸成av人网站| 国产人伦精品一区二区| 亚洲国产成人在线| 精品国产乱码久久| 日韩理论在线观看| 日韩电影在线一区| 成人少妇影院yyyy| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 在线看日本不卡| 99免费精品在线观看| 欧美性受xxxx黑人xyx性爽| 欧美日韩精品电影| 三级欧美韩日大片在线看| 国产一区二区电影| 欧美午夜电影在线播放| 欧美韩国日本综合| 久久电影网站中文字幕| 欧美一区二区三区在线看| 中文字幕在线观看不卡| 日日摸夜夜添夜夜添国产精品| 国精产品一区一区三区mba桃花 | 91麻豆高清视频| 久久久久久一级片| 亚洲另类一区二区| 777午夜精品免费视频| 国产欧美一区二区精品忘忧草| 国产亚洲一二三区| 另类专区欧美蜜桃臀第一页| 欧美日韩午夜在线视频| 亚洲福利视频一区| 在线观看国产一区二区| 亚洲精品视频免费看| 日本久久精品电影| 日韩欧美国产麻豆| 欧美日韩日本视频| 欧美一区二区精品在线| 日本不卡高清视频| 日韩国产高清影视| 男男视频亚洲欧美| 国产乱码精品一区二区三区五月婷 | 7777精品伊人久久久大香线蕉经典版下载 | 另类小说综合欧美亚洲| 精品国产成人系列| 99re热这里只有精品视频| 日产精品久久久久久久性色| 国产欧美一区二区三区鸳鸯浴| 欧美视频在线一区| 成人丝袜18视频在线观看| 天天影视涩香欲综合网| 国产精品美女久久久久久2018| 欧美精品aⅴ在线视频| aaa欧美日韩| 欧美天天综合网| 国产欧美日韩精品a在线观看| 国产精品国产a|