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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mutexsemdemo.c

?? 對Vxworks進程通訊的信號量詳細介紹
?? C
字號:
/* 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一区二区三区免费野_久草精品视频
91香蕉视频在线| 国产精品久久毛片| 国产精品私人影院| 亚洲午夜精品网| 国产suv精品一区二区三区| 欧美日韩午夜影院| 中文字幕中文字幕在线一区| 日本伊人午夜精品| 色香色香欲天天天影视综合网| 亚洲免费资源在线播放| 美女尤物国产一区| 91高清在线观看| 国产精品入口麻豆九色| 精品一区二区在线视频| 777亚洲妇女| 亚洲已满18点击进入久久| 国产麻豆欧美日韩一区| 欧美日本一区二区在线观看| 亚洲精品国产a| 99久久99久久久精品齐齐| 国产欧美一区二区精品久导航 | 亚洲精品国产品国语在线app| 久久久综合网站| 奇米888四色在线精品| 欧美日韩高清一区二区不卡 | 国产精品久久久久7777按摩 | 99久久伊人网影院| 久久久午夜精品理论片中文字幕| 久久久不卡网国产精品二区| 久久er99热精品一区二区| 91精品国产入口在线| 日韩高清在线不卡| 欧美剧情片在线观看| 亚洲国产日韩精品| 欧洲精品中文字幕| 樱桃视频在线观看一区| 色综合色综合色综合 | 久久美女艺术照精彩视频福利播放| 久久伊99综合婷婷久久伊| 国产原创一区二区| 久久亚洲精华国产精华液| 久久电影国产免费久久电影| 精品久久久久久久久久久久久久久久久| 欧美高清在线一区二区| 成人综合激情网| 亚洲六月丁香色婷婷综合久久 | 亚洲色图清纯唯美| 972aa.com艺术欧美| 亚洲精品综合在线| 欧美美女喷水视频| 狠狠色狠狠色综合系列| 久久精品欧美一区二区三区麻豆| 亚洲二区视频在线| 欧美一区二区在线免费播放| 美脚の诱脚舐め脚责91| 欧美不卡在线视频| av一二三不卡影片| 偷窥国产亚洲免费视频| 亚洲精品在线观| 成人av电影在线| 五月天国产精品| 国产午夜精品久久| 欧美视频一区二区三区四区| 久久国产综合精品| 亚洲欧洲av色图| 91麻豆精品国产91久久久久久 | 国产日韩三级在线| 成人激情免费网站| 日韩成人午夜电影| 国产清纯在线一区二区www| 99re成人在线| 极品少妇xxxx精品少妇偷拍| 亚洲精品乱码久久久久| 精品久久久久久久人人人人传媒| 日本不卡的三区四区五区| 国产精品情趣视频| 在线成人av影院| 99精品国产91久久久久久| 奇米亚洲午夜久久精品| 亚洲男人的天堂在线aⅴ视频| 99久久伊人精品| 日本美女一区二区| 亚洲色图欧美在线| 久久久久国产精品麻豆ai换脸| 国产在线乱码一区二区三区| 亚洲男人的天堂网| 欧美国产成人在线| 欧美videofree性高清杂交| 在线日韩一区二区| 从欧美一区二区三区| 久久国产精品99精品国产| 亚洲国产cao| 亚洲精品日产精品乱码不卡| 久久综合九色综合久久久精品综合| 久久国产精品免费| 午夜欧美视频在线观看| 亚洲精品中文在线影院| 国产精品视频一二三区| 精品国内二区三区| 欧美精品自拍偷拍动漫精品| 色婷婷综合久久久中文字幕| 成人动漫在线一区| 丰满少妇久久久久久久| 激情国产一区二区| 麻豆国产91在线播放| 亚洲成av人片| 亚洲第一主播视频| 亚洲高清中文字幕| 亚洲成人av一区二区| 一二三区精品视频| 樱花草国产18久久久久| 亚洲女女做受ⅹxx高潮| 中文字幕在线观看不卡| 欧美国产精品久久| 中文字幕一区二区三区四区不卡| 在线精品视频一区二区| 9色porny自拍视频一区二区| 国产精品77777| 国产成人av福利| 国产在线一区二区| 国产成人av自拍| 成人激情视频网站| 91在线一区二区| 在线国产亚洲欧美| 欧美日韩国产免费| 欧美一区二区三区爱爱| 精品盗摄一区二区三区| 久久久亚洲午夜电影| 国产精品久久久久久久久免费丝袜| 欧美另类变人与禽xxxxx| 欧美日韩国产高清一区| 538在线一区二区精品国产| 精品久久久久一区| 中文字幕第一页久久| 一区二区三区在线观看国产| 亚洲一区二区三区激情| 男女男精品网站| 成人性生交大合| 在线观看欧美日本| 日韩一卡二卡三卡国产欧美| 久久精品免费在线观看| 一区二区三区久久| 久久超碰97人人做人人爱| 国产成人av影院| 欧美日韩在线直播| 久久蜜桃一区二区| 一区二区三区中文免费| 裸体在线国模精品偷拍| 成人免费毛片app| 欧美日韩综合色| 国产亚洲人成网站| 亚洲一区二区三区四区在线免费观看| 国产精品美女久久久久久久久久久 | 视频一区视频二区中文| 青青青伊人色综合久久| 成人精品鲁一区一区二区| 欧美视频在线一区| 国产日韩欧美激情| 三级欧美在线一区| 91香蕉国产在线观看软件| 日韩一区二区免费电影| 亚洲啪啪综合av一区二区三区| 一区二区中文视频| 美女一区二区视频| 成人一区二区在线观看| 日韩午夜激情免费电影| 亚洲裸体xxx| 国产精品影音先锋| 91精品中文字幕一区二区三区| 91激情五月电影| 欧美激情一区二区三区蜜桃视频| 26uuu久久综合| 亚洲大片一区二区三区| 成人av在线影院| 欧美一级免费观看| 亚洲在线视频网站| 福利视频网站一区二区三区| 日韩欧美123| 亚洲成年人影院| 色综合 综合色| 亚洲色图另类专区| 国产.欧美.日韩| 久久久激情视频| 韩国精品久久久| 欧美sm美女调教| 精品综合免费视频观看| 91精品国产综合久久精品app| 欧美成人女星排名| 日韩中文字幕91| 欧美日韩精品三区| 亚洲特黄一级片| av中文字幕亚洲| 日本一区二区高清| 国产成人精品影视| 国产欧美一区二区精品久导航| 一区二区三区 在线观看视频| 日韩在线a电影| 欧美一区二区三区日韩| 同产精品九九九| 日韩情涩欧美日韩视频|