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

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

?? mutexsemdemo.c.bak

?? 對Vxworks進程通訊的信號量詳細介紹
?? BAK
字號:
/* mutexSemDemo.c -  Demonstrate the usage of the mutual exclusion semaphore  *                   for intertask synchronization and obtaining exclusive  *                   access to a data structure shared among multiple tasks. *//* Copyright 1984-1997 Wind River Systems, Inc. *//*modification history--------------------01c,06nov97,mm  added copyright.01b,16sep97,ram included logLib.h, sysLib.h, stdio.h		 The arguments to logMsg are required arguments(6)		 Since there were fewer than 6 arguments the remaining		 have been filled up with zeros.01a,14jan94,ms   written.*/#include "vxWorks.h"#include "semLib.h"#include "taskLib.h"#include "mutexSemDemo.h"#include "logLib.h"#include "sysLib.h"#include "stdio.h"LOCAL STATUS protectSharedResource ();      /* protect shared data structure */LOCAL STATUS releaseProtectedSharedResource (); /* release protected access */LOCAL STATUS producerTask ();               /* producer task */LOCAL STATUS consumerTask ();               /* consumer task */LOCAL struct shMem shMemResource;           /* shared memory structure */LOCAL SEM_ID mutexSemId;                    /* mutual exclusion semaphore id*/LOCAL BOOL notFinished;                     /* Flag that indicates the                                              * completion *//***************************************************************************** *  mutexSemDemo - Demonstrate the usage of the mutual exclusion semaphore  *                 for intertask synchronization and obtaining exclusive  *                 access to a data structure shared among multiple tasks. * *  DESCRIPTION *  Creates a mutual exclusion semaphore for intertask syncronization  *  between the producerTask and the consumerTask. Both producerTask and *  consumerTask access and manipulate the global shared memory data  *  structure simultaneously. To avoid corruption of the global shared *  memory data structure mutual exclusion semaphores are used.  * *  Spawns the producerTask that produces the message and puts the message *  in the global shared data structure. Spawns the consumerTask that  *  consumes the message from the global shared data structure and *  updates the status field to CONSUMED so that producerTask can put *  the next produced message in the global shared data structure.  *  After consumerTask has consumed all the messages, the mutual exclusion *  semaphore is deleted. * *  RETURNS: OK or ERROR * *  EXAMPLE * *  -> sp mutexSemDemo * */ STATUS mutexSemDemo()    {    notFinished = TRUE;  /* initialize the global flag */     /* Create the mutual exclusion semaphore*/    if ((mutexSemId = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE                                          | SEM_INVERSION_SAFE)) == NULL)        {        perror ("Error in creating mutual exclusion semaphore");        return (ERROR);        }      /* Spwan the consumerTask task */    if (taskSpawn ("tConsumerTask", CONSUMER_TASK_PRI, 0, TASK_STACK_SIZE,                    (FUNCPTR) consumerTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)                    == ERROR)        {        perror ("consumerTask: Error in spawning demoTask");        return (ERROR);        }     /* Spwan the producerTask task */    if (taskSpawn ("tProducerTask", PRODUCER_TASK_PRI, 0, TASK_STACK_SIZE,                    (FUNCPTR) producerTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)                    == ERROR)        {        perror ("producerTask: Error in spawning demoTask");        return (ERROR);        }      /* Polling is not recommended. But used for making this demonstration      * simple */    while (notFinished)        taskDelay (sysClkRateGet ());    /* When done delete the mutual exclusion semaphore*/     if (semDelete (mutexSemId) == ERROR)       {       perror ("Error in deleting mutual exclusion semaphore");       return (ERROR);       }      return (OK);     }/***************************************************************************** *  producerTask - produce the message, and write the message to the global  *                 shared data structure by obtaining exclusive access to  *                 that structure which is shared with the consumerTask.  * *  RETURNS: OK or ERROR * */STATUS producerTask ()    {    int count = 0;    int notDone = TRUE;printf("in producerTask/n");    while (notDone)        {        /* Produce NUM_ITEMS, write each of these items to the shared         * global data structure.         */         if (count < NUM_ITEMS)            {            /* Obtain exclusive access to the global shared data structure */            if (protectSharedResource() == ERROR)                return (ERROR);            /* Access and manipulate the global shared data structure */            if (shMemResource.status == CONSUMED)                {                 count++;                shMemResource.tid = taskIdSelf ();                shMemResource.count = count;                shMemResource.status = PRODUCED;                }            /* Release exclusive access to the global shared data structure */            if (releaseProtectedSharedResource () == ERROR)                return (ERROR);            logMsg ("ProducerTask: tid = %#x, producing item = %d\n",                                                        taskIdSelf (), count,0,0,0,0);            taskDelay (sysClkRateGet()/6); /* relingiush the CPU so that                                             * consumerTask can access the                                             * global shared data structure.                                             */            }        else             notDone = FALSE;        }    return (OK);    }/***************************************************************************** *  consumerTask -  consumes the message from the global shared data  *                  structure and updates the status filled to CONSUMED  *                  so that producerTask can put the next produced message  *                  in the global shared data structure.  * *  RETURNS: OK or ERROR * */STATUS consumerTask ()    {    int notDone = TRUE;        printf("in consumerTask/n");    /* Initialize to consumed status */    if (protectSharedResource() == ERROR)        return (ERROR);    shMemResource.status = CONSUMED;    if (releaseProtectedSharedResource () == ERROR)        return (ERROR);    while (notDone)         {        taskDelay (sysClkRateGet()/6);     /* relingiush the CPU so that                                             * producerTask can access the                                             * global shared data structure.                                             */        /* Obtain exclusive access to the global shared data structure */        if (protectSharedResource() == ERROR)            return (ERROR);        /* Access and manipulate the global shared data structure */        if ((shMemResource.status == PRODUCED) && (shMemResource.count > 0))             {            logMsg ("ConsumerTask: Consuming item = %d from tid = %#x\n\n",                shMemResource.count, shMemResource.tid,0,0,0,0);            shMemResource.status = CONSUMED;            }        if (shMemResource.count >= NUM_ITEMS)            notDone = FALSE;        /* Release exclusive access to the global shared data structure */        if (releaseProtectedSharedResource () == ERROR)            return (ERROR);        }    notFinished = FALSE;    return (OK);    }/***************************************************************************** *  protectSharedResource -  Protect access to the shared data structure with  *                           the mutual exclusion  semaphore. * *  RETURNS: OK or ERROR * */LOCAL STATUS protectSharedResource ()    {    if (semTake (mutexSemId, WAIT_FOREVER) == ERROR)        {        perror ("protectSharedResource: Error in semTake");        return (ERROR);        }    else        return (OK);    }/***************************************************************************** *  releaseProtectedSharedResource -  Release the protected access to the  *                                    shared data structure using the mutual  *                                    exclusion semaphore * *  RETURNS: OK or ERROR * */LOCAL STATUS releaseProtectedSharedResource ()    {    if (semGive (mutexSemId) == ERROR)        {        perror ("protectSharedResource: Error in semTake");        return (ERROR);        }    else        return (OK);    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
奇米影视7777精品一区二区| 丰满白嫩尤物一区二区| 国内成人精品2018免费看| 99在线视频精品| 欧美v国产在线一区二区三区| 日本一二三四高清不卡| 人人精品人人爱| 色噜噜狠狠成人网p站| 久久看人人爽人人| 视频一区欧美精品| 在线观看免费视频综合| 国产三级一区二区| 久久精品国产成人一区二区三区| 91麻豆蜜桃一区二区三区| 久久久高清一区二区三区| 日韩av在线免费观看不卡| 91福利在线播放| 亚洲日本在线天堂| 成人网男人的天堂| 中文字幕免费观看一区| 国产乱码精品一区二区三区五月婷| 欧美一区永久视频免费观看| 亚洲综合免费观看高清完整版 | 婷婷丁香久久五月婷婷| 成人av先锋影音| 国产欧美日韩在线看| 国内久久精品视频| 精品蜜桃在线看| 久久99国产精品麻豆| 欧美一区二区三区四区视频| 三级久久三级久久久| 欧美图区在线视频| 亚洲一区日韩精品中文字幕| 色欧美片视频在线观看在线视频| 国产精品欧美极品| av一区二区不卡| 亚洲免费在线看| 在线视频亚洲一区| 亚洲成人中文在线| 欧美日韩精品系列| 秋霞电影网一区二区| 日韩欧美中文一区| 韩国av一区二区| 欧美韩国日本一区| 91在线视频在线| 亚洲成a人v欧美综合天堂| 欧美一区二区三区播放老司机| 青青草伊人久久| www久久久久| 成人短视频下载 | 久久久无码精品亚洲日韩按摩| 国产一区二区主播在线| 日本一区二区不卡视频| 色综合咪咪久久| 丝袜a∨在线一区二区三区不卡| 日韩视频中午一区| 国产成人精品亚洲午夜麻豆| 亚洲欧美日韩在线| 91麻豆精品国产综合久久久久久 | 亚洲一区二区三区不卡国产欧美| 欧美日本乱大交xxxxx| 精品一区免费av| 国产精品美女久久久久久久网站| 欧美性做爰猛烈叫床潮| 久久99国产乱子伦精品免费| 国产精品白丝在线| 欧美日韩电影在线播放| 国产精品1区2区| 一区二区高清在线| 精品国产污网站| 在线看国产一区二区| 国产综合色视频| 亚洲成av人片观看| 中文字幕国产一区| 日韩欧美在线123| 99久久婷婷国产| 麻豆成人av在线| 亚洲天堂成人网| 日韩视频中午一区| 91精品办公室少妇高潮对白| 激情综合色播激情啊| 一区二区三区国产精品| 精品福利av导航| 欧美色精品在线视频| 粉嫩一区二区三区在线看| 日本视频在线一区| 尤物av一区二区| 日本一区二区视频在线| 日韩欧美一卡二卡| 欧美欧美欧美欧美| 91女厕偷拍女厕偷拍高清| 精品一二线国产| 日本在线不卡一区| 亚洲国产一区二区在线播放| 国产精品免费网站在线观看| 欧美va亚洲va| 欧美一区二区三区四区久久| 欧洲国产伦久久久久久久| 成人aa视频在线观看| 国产一区在线观看视频| 日本视频一区二区| 亚洲午夜激情网站| 亚洲欧美电影院| 中文无字幕一区二区三区| 日韩免费性生活视频播放| 欧美性生活一区| 在线精品观看国产| 91激情五月电影| 色哟哟在线观看一区二区三区| 丁香网亚洲国际| 国产宾馆实践打屁股91| 国产精品一区免费在线观看| 国产一区二区三区综合| 国产一区二区三区av电影 | 欧美高清精品3d| 欧美性生活影院| 欧美日本一道本| 欧美日本免费一区二区三区| 欧美日韩aaa| 欧美一级搡bbbb搡bbbb| 欧美一级欧美一级在线播放| 日韩欧美电影在线| 欧美r级在线观看| 久久婷婷国产综合精品青草| 欧美精品一区二区三区在线| 国产色产综合产在线视频| 中文天堂在线一区| 亚洲美女视频在线| 亚洲第一福利视频在线| 日韩不卡免费视频| 国产一区二区三区精品欧美日韩一区二区三区 | 成人久久18免费网站麻豆| av电影在线观看不卡| 色94色欧美sute亚洲线路二| 欧美视频一区二区三区在线观看| 在线观看免费视频综合| 欧美精品高清视频| 久久网站最新地址| 亚洲欧美日韩国产另类专区| 亚洲一级片在线观看| 日韩综合一区二区| 国产精品综合视频| 91传媒视频在线播放| 91精品国产综合久久婷婷香蕉| 精品国产一区二区国模嫣然| 国产精品另类一区| 亚洲成人av中文| 国产一区不卡视频| 色婷婷久久久综合中文字幕| 日韩视频一区在线观看| 国产精品美女久久久久aⅴ| 亚洲一区二区av在线| 国内一区二区在线| 91国偷自产一区二区三区观看| 日韩视频国产视频| 亚洲色图视频网| 美国av一区二区| 色呦呦一区二区三区| 精品国产免费视频| 一区二区三区中文字幕电影| 国产在线播放一区| 欧美日本免费一区二区三区| 亚洲国产精品黑人久久久| 日本中文字幕不卡| 99久久精品国产麻豆演员表| 日韩色视频在线观看| 一区二区三区中文字幕精品精品 | 91精品国产综合久久久久| 欧美韩国日本一区| 蜜桃精品视频在线观看| 91精品91久久久中77777| 久久美女艺术照精彩视频福利播放 | 亚洲福利一二三区| 岛国av在线一区| 日韩欧美一区电影| 亚洲高清免费视频| 色哦色哦哦色天天综合| 久久九九久精品国产免费直播| 日韩电影免费在线观看网站| 色综合久久综合网欧美综合网 | 国产精品88av| 欧美mv和日韩mv国产网站| 一区二区三区在线观看国产| 成人中文字幕合集| 久久久91精品国产一区二区精品 | 日韩欧美国产高清| 亚洲国产色一区| 日本丶国产丶欧美色综合| 中文字幕精品—区二区四季| 国模少妇一区二区三区| 日韩精品中文字幕在线不卡尤物 | 久久99国产乱子伦精品免费| 欧美精品一级二级三级| 亚洲午夜私人影院| 欧美日韩一区二区三区高清| 亚洲一区二区不卡免费| 欧美视频三区在线播放| 一区二区三区在线视频播放| 色婷婷av一区二区三区大白胸| 亚洲日本中文字幕区|