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

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

?? sempxlib.c

?? vxworks的完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* semPxLib.c - semaphore synchronization library (POSIX) *//* Copyright 1984-2002 Wind River Systems, Inc.  */#include "copyright_wrs.h"/*modification history--------------------01l,17jul00,jgn  merge DOT-4 pthreads changes01k,03feb95,rhp  strengthen warning re semaphore deletion01j,25jan95,rhp  restructure library man page, other doc tweaks.    19jan95,jdi  doc cleanup.01i,08apr94,dvs  changed semClass to semPxClass (SCD #3119).01h,08apr94,dvs  fixed error in args when calling symFindByName (SCD #3091).01g,01feb94,dvs  documentation cleanup.01f,12jan94,kdl	 changed semaphoreInit() to semPxLibInit().01e,05jan94,kdl	 changed param names to match POSIX spec; changed sem_t		 "close" field to "refCnt"; general cleanup.01d,21dec93,kdl	 made sem_destroy() return error if sem has tasks blocked.01c,13dec93,dvs  added initialization of posix name tbl in semaphoreInit().	   +rrr  fixed sem_open bug01b,15nov93,dvs  initial cleanup01a,06apr93,smb  created*//*DESCRIPTION:This library implements the POSIX 1003.1b semaphore interface.  Foralternative semaphore routines designed expressly for VxWorks, seethe manual page for semLib and other semaphore librariesmentioned there.  POSIX semaphores are counting semaphores; assuch they are most similar to the semCLib VxWorks-specific semaphores.The main advantage of POSIX semaphores is portability (to the extentthat alternative operating systems also provide these POSIXinterfaces).  However, VxWorks-specific semaphores providethe following features absent from the semaphores implemented in thislibrary: priority inheritance, task-deletion safety, the ability for asingle task to take a semaphore multiple times, ownership ofmutual-exclusion semaphores, semaphore timeout, and the choice ofqueuing mechanism.POSIX defines both named and unnamed semaphores; semPxLib includesseparate routines for creating and deleting each kind.  For otheroperations, applications use the same routines for both kinds ofsemaphore.TERMINOLOGYThe POSIX standard uses the terms \f2wait\f1 or \f2lock\f1 where\f2take\f1 is normally used in VxWorks, and the terms \f2post\f1 or\f2unlock\f1 where \f2give\f1 is normally used in VxWorks.  VxWorksdocumentation that is specific to the POSIX interfaces (such as theremainder of this manual entry, and the manual entries for subroutinesin this library) uses the POSIX terminology, in order to make iteasier to read in conjunction with other references on POSIX.SEMAPHORE DELETIONThe sem_destroy() call terminates an unnamed semaphore and deallocatesany associated memory; the combination of sem_close() and sem_unlink()has the same effect for named semaphores.  Take care when deletingsemaphores, particularly those used for mutual exclusion, to avoiddeleting a semaphore out from under a task that has already lockedthat semaphore.  Applications should adopt the protocol of onlydeleting semaphores that the deleting task has successfully locked.(Similarly, for named semaphores, applications should take care toonly close semaphores that the closing task has opened.)If there are tasks blocked waiting for the semaphore, sem_destroy()fails and sets `errno' to EBUSY.INTERNAL:POSIX indicates that semaphores may be implemented using a filedescriptor.  I have chosen not to include this functionality in thisimplementation of semaphores.  POSIX specs do not insist on a file descriptor implementation.There is an attempt to deal with the issues of a task connecting to a semaphore and the persistence of that semaphore.  Persistence implies thata semaphore and its associated state remains valid until the reference isreleased.  Ref.  sem_close() and sem_unlink().Detection of deadlock is not considered in this implementation.  POSIXconsiders the issue but does not require it to be addressed for POSIX.The routines in this library are compliant to POSIX 1003.4 draft 14.INCLUDE FILES: semaphore.hSEE ALSO: POSIX 1003.1b document, semLib, .pG "Basic OS"*/#include "vxWorks.h"#include "errno.h"#include "semaphore.h"#include "semLib.h"#include "symLib.h"#include "posixName.h"#include "fcntl.h"#include "taskLib.h"#include "stdarg.h"#include "symSync.h"#include "string.h"#include "objLib.h"#include "qLib.h"#define __PTHREAD_SRC#include "pthread.h" /* defines */#define MAX_TASKS	100/* locals */LOCAL OBJ_CLASS semPxClass;                        /* sem object class */LOCAL BOOL	semInitialized;CLASS_ID semPxClassId = &semPxClass;               /* sem class id *//********************************************************************************* semPxLibInit - initialize POSIX semaphore support** This routine must be called before using POSIX semaphores.** RETURNS: OK, or ERROR if there is an error installing the semaphore library.*/STATUS semPxLibInit (void)    {    if ((!semInitialized) &&        (classInit (semPxClassId, sizeof (struct sem_des), 		    OFFSET (struct sem_des, objCore),                    (FUNCPTR) NULL, (FUNCPTR) NULL, (FUNCPTR) NULL) == OK))        {	/* initialize the posix name table */	posixNameTblInit (0);			/* use default hashing */	/* init counting semaphore library */        if (semCLibInit () == ERROR)            {            return (ERROR);            }        semInitialized = TRUE;        /* we've finished the initialization */        }    return (OK);    }/********************************************************************************* sem_init - initialize an unnamed semaphore (POSIX)** This routine is used to initialize the unnamed semaphore <sem>.* The value of the initialized semaphore is <value>.  Following a successful* call to sem_init() the semaphore may be used in subsequent calls to* sem_wait(), sem_trywait(), and sem_post().  This semaphore remains usable* until the semaphore is destroyed.** The <pshared> parameter currently has no effect.** Only <sem> itself may be used for synchronization.** RETURNS: 0 (OK), or -1 (ERROR) if unsuccessful.** ERRNO:*  EINVAL*     - <value> exceeds SEM_VALUE_MAX.*  ENOSPC *     - unable to initialize semaphore due to resource constraints.*	* SEE ALSO: sem_wait(), sem_trywait(), sem_post()**/int sem_init     (    sem_t *      sem, 		/* semaphore to be initialized */    int          pshared, 	/* process sharing */    unsigned int value		/* semaphore initialization value */    )    {    /* validate value */    if (value > SEM_VALUE_MAX)	{	errno = EINVAL;	return (ERROR);	}    /* initialize the semaphore library */    if (semPxLibInit () == OK)        {	/* create semaphore */        if ((sem->semId = semCCreate (SEM_Q_PRIORITY, value)) == NULL)	    {	    errno = ENOSPC;	    return (ERROR);	    }        sem->sem_name = NULL; 		           /* init the structure */        objCoreInit (&sem->objCore, semPxClassId); /* validate object */        }    else	{	errno = ENOSPC;        return (ERROR);        }    return (OK);    }/********************************************************************************* sem_destroy - destroy an unnamed semaphore (POSIX)** This routine is used to destroy the unnamed semaphore indicated by <sem>.** The sem_destroy() call can only destroy a semaphore created by sem_init().* Calling sem_destroy() with a named semaphore will cause a EINVAL error.* Subsequent use of the <sem> semaphore will cause an EINVAL error in the* calling function.** If one or more tasks is blocked on the semaphore, the semaphore is not* destroyed.* * WARNING* Take care when deleting semaphores, particularly those used for* mutual exclusion, to avoid deleting a semaphore out from under a* task that has already locked that semaphore.  Applications should* adopt the protocol of only deleting semaphores that the deleting* task has successfully locked.* * RETURNS: 0 (OK), or -1 (ERROR) if unsuccessful.** ERRNO:*  EINVAL *     - invalid semaphore descriptor.*  EBUSY*     - one or more tasks is blocked on the semaphore.*	* SEE ALSO: sem_init()**/int sem_destroy     (    sem_t * sem		/* semaphore descriptor */    )    {    taskLock ();                                /* TASK LOCK */    if (OBJ_VERIFY (sem, semPxClassId) != OK)        {        taskUnlock ();                          /* TASK UNLOCK */        errno = EINVAL;        return (ERROR);                         /* invalid object */        }    if (sem->sem_name != NULL)			/* close via sem_close/unlink */	{        taskUnlock ();                          /* TASK UNLOCK */	errno = EINVAL;	return (ERROR);	}    if (qFirst (&(sem->semId->qHead)) != NULL) 	{        taskUnlock ();                          /* TASK UNLOCK */	errno = EBUSY;	return (ERROR);				/* someone waiting on sem */	}    objCoreTerminate (&sem->objCore);  		/* terminate object */    semDelete (sem->semId);    taskUnlock ();				/* TASK UNLOCK */    return (OK);    }/********************************************************************************* sem_open - initialize/open a named semaphore (POSIX)** This routine establishes a connection between a named semaphore and* a task.  Following a call to sem_open() with a semaphore name <name>,* the task may reference the semaphore associated with <name> using* the address returned by this call.  This semaphore may be used in * subsequent calls to sem_wait(), sem_trywait(), and sem_post().  The * semaphore remains usable until the semaphore is closed by a successful* call to sem_close().  ** The <oflag> argument controls whether the semaphore is created or merely* accessed by the call to sem_open().  The following flag bits may be set* in <oflag>:** .iP O_CREAT* Use this flag to create a semaphore if it does not already exist.  If* O_CREAT is set and the semaphore already exists, O_CREAT has no effect* except as noted below under O_EXCL.  Otherwise, sem_open() creats a* semaphore.  O_CREAT requires a third and fourth argument: <mode>, which is* of type mode_t, and <value>, which is of type unsigned int.  <mode> has no* effect in this implementation.  The semaphore is created with an initial* value of <value>.  Valid initial values for semaphores must be less than* or equal to SEM_VALUE_MAX.** .iP O_EXCL* If O_EXCL and O_CREAT are set, sem_open() will fail if the semaphore name* exists.  If O_EXCL is set and O_CREAT is not set, the named semaphore * is not created.* .LP* * To determine whether a named semaphore already exists in the system,* call sem_open() with the flags `O_CREAT | O_EXCL'.  If the* sem_open() call fails, the semaphore exists.* * If a task makes multiple calls to sem_open() with the same value* for <name>, then the same semaphore address is returned for each such* call, provided that there have been no calls to sem_unlink()* for this semaphore.** References to copies of the semaphore will produce undefined results.** NOTE* The current implementation has the following limitations:**     - A semaphore cannot be closed with calls to _exit() or exec().*     - A semaphore cannot be implemented as a file.*     - Semaphore names will not appear in the file system.  ** RETURNS: A pointer to sem_t, or  -1 (ERROR) if unsuccessful.  ** ERRNO:*  EEXIST*     - O_CREAT | O_EXCL are set and the semaphore already exists.*  EINVAL*     - <value> exceeds SEM_VALUE_MAX or the semaphore name is invalid.*  ENAMETOOLONG*     - the semaphore name is too long.*  ENOENT*     - the named semaphore does not exist and O_CREAT is not set.*  ENOSPC*     - the semaphore could not be initialized due to resource constraints.** SEE ALSO: sem_unlink()** INTERNAL:* Note that if the sem already exists and O_CREAT is not set then this call* has no effect.  If the sem does not exist and only the O_EXCL flag* is set then ENOENT is set and an -1 returned.  These are not clear from the * POSIX specifications.**/sem_t * sem_open     (    const char * name, 	/* semaphore name */    int 	 oflag, 	/* semaphore creation flags */    ...				/* extra optional parameters */    )    {    va_list 	 vaList;     	 /* traverses argument list */    mode_t  	 mode;		 /* mode of semaphore */    unsigned int value;		 /* initial value of semaphore */    sem_t *      pSemDesc;	 /* semaphore descriptor */    BOOL	 found = FALSE;	 /* find named object */    void *       pPool = NULL;   /* area for name */    SYM_TYPE 	 dummy;		 /* dummy var for calling symFindByName */    #if _POSIX_NO_TRUNC    /* check name length */    if (strlen (name) > NAME_MAX)        {        errno = ENAMETOOLONG;        return ((sem_t *) ERROR);        }#endif    /* Initialize semaphore library */    if (semPxLibInit () == ERROR)        {        errno = ENOSPC;        return ((sem_t *) ERROR);        }    /* The following symTblLock is used to insure that no other task     * can create a semaphore of the same name as this one. This     * could have occurred if another task tried to access the name table     * between symFindByName returning not found and the name being     * added to the name table via symAdd.     */    symTblLock (posixNameTbl);			/* LOCK NAME TABLE */    if (symFindByName (posixNameTbl, (char *) name, (char **) &pSemDesc, 		       &dummy) == OK)	{    	found = TRUE;	}    if (found) 					/* found */	{	if (O_EXCL & oflag)            {    	    symTblUnlock (posixNameTbl);	/* UNLOCK NAME TABLE */            errno = EEXIST;            return ((sem_t *) ERROR);            }        else 	    {    	    symTblUnlock (posixNameTbl);	/* UNLOCK NAME TABLE */	    /* validate semaphore descriptor */	    if (OBJ_VERIFY (pSemDesc, semPxClassId) != 0)		{		errno = EINVAL;		return ((sem_t *) ERROR);		}	    pSemDesc->refCnt++;			/* attach */            return (pSemDesc);	    }	}    else 					/* not found */	if (!(O_CREAT & oflag))			/* if not creating */            {    	    symTblUnlock (posixNameTbl);	/* UNLOCK NAME TABLE */            errno = ENOENT;            return ((sem_t *) ERROR);            }    /* retrieve optional parameters */    va_start (vaList, oflag);    mode = va_arg (vaList, mode_t);    value = va_arg (vaList, uint_t);    va_end (vaList);    /* validate parameter */    if (value > SEM_VALUE_MAX)        {        symTblUnlock (posixNameTbl);		/* UNLOCK NAME TABLE */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜精品在线| 中文字幕欧美一区| 青青草国产精品亚洲专区无| 欧美日韩国产首页| 日韩主播视频在线| 欧美精品v日韩精品v韩国精品v| 亚洲va国产va欧美va观看| 欧美日韩中文一区| 免费高清在线一区| 久久久精品国产99久久精品芒果 | 亚洲自拍都市欧美小说| 日本黄色一区二区| 亚洲高清视频在线| 日韩欧美国产综合| 国产精品亚洲成人| 亚洲欧美电影一区二区| 欧美精品一二三四| 黄页网站大全一区二区| 国产精品欧美久久久久一区二区| 91麻豆成人久久精品二区三区| 亚洲成人高清在线| 精品va天堂亚洲国产| 91日韩一区二区三区| 视频在线观看一区| 日本一区二区成人在线| 欧美亚洲一区二区在线| 九九视频精品免费| 亚洲美女免费在线| 91精品国产综合久久久蜜臀粉嫩| 国产乱码字幕精品高清av| 亚洲免费视频中文字幕| 精品久久五月天| 色哟哟精品一区| 麻豆91精品91久久久的内涵| 亚洲欧洲日韩一区二区三区| 欧美日本免费一区二区三区| 高清国产一区二区三区| 午夜精品久久久久久久蜜桃app| 久久久久青草大香线综合精品| 色香蕉久久蜜桃| 国产中文字幕精品| 亚洲第一主播视频| 日韩一区在线免费观看| 精品美女被调教视频大全网站| 91丨九色丨尤物| 国产精品一区二区久久不卡 | 美腿丝袜在线亚洲一区| 国产精品黄色在线观看| 日韩视频123| 日本韩国视频一区二区| 国产iv一区二区三区| 毛片一区二区三区| 亚洲天堂av一区| 久久精品综合网| 日韩欧美一二区| 欧美日韩国产成人在线91| 99久免费精品视频在线观看| 精品一区二区av| 亚洲一二三四区不卡| 亚洲特黄一级片| 国产日本欧洲亚洲| 精品久久久久久久久久久久包黑料 | 高清在线观看日韩| 国模冰冰炮一区二区| 日本一区中文字幕| 亚洲成人高清在线| 亚洲高清在线精品| 亚洲一区二区三区激情| 亚洲男人电影天堂| 亚洲精品第一国产综合野| 国产精品美女久久久久久久久| 久久综合999| 精品人伦一区二区色婷婷| 欧美mv和日韩mv的网站| 日韩视频国产视频| 日韩视频不卡中文| 久久只精品国产| 久久天堂av综合合色蜜桃网| 精品久久人人做人人爰| 亚洲精品一线二线三线无人区| 日韩一区二区三区在线| 日韩精品一区在线| 精品国产自在久精品国产| 精品av综合导航| 久久一夜天堂av一区二区三区 | 欧美人与性动xxxx| 欧美群妇大交群中文字幕| 欧美色图一区二区三区| 欧美色精品天天在线观看视频| 欧美综合欧美视频| 欧美日韩中文字幕一区| 日韩欧美国产综合在线一区二区三区| 日韩欧美的一区二区| 久久综合狠狠综合| 国产精品视频麻豆| 亚洲激情图片qvod| 亚洲国产欧美在线| 日本视频中文字幕一区二区三区| 日韩和欧美一区二区三区| 精品中文字幕一区二区| 国产98色在线|日韩| 97久久精品人人爽人人爽蜜臀| 色综合久久中文综合久久97| 欧美日韩亚洲综合| 日韩三级精品电影久久久 | 在线一区二区观看| 欧美一区二区女人| 久久在线免费观看| 亚洲欧美一区二区久久| 日韩av一区二区在线影视| 狠狠色丁香久久婷婷综| av亚洲精华国产精华精| 欧美电影影音先锋| 久久亚洲综合色一区二区三区| 中文字幕在线不卡视频| 亚洲成人高清在线| 国产成人精品免费看| 一本高清dvd不卡在线观看| 91精品免费在线观看| 国产亚洲一区二区三区四区| 亚洲精品日韩综合观看成人91| 日韩精品欧美精品| 成人综合在线网站| 欧美日韩和欧美的一区二区| 久久久久久久久久电影| 亚洲一区av在线| 国产**成人网毛片九色| 6080午夜不卡| 日韩一区欧美一区| 免费av网站大全久久| 99久久免费视频.com| 日韩一二三四区| 亚洲欧美日韩久久| 韩国中文字幕2020精品| 欧美视频日韩视频在线观看| 久久精品日产第一区二区三区高清版| 一区二区三区免费观看| 国产aⅴ综合色| 欧美成人性福生活免费看| 亚洲欧美国产77777| 国产成人午夜视频| 日韩欧美高清dvd碟片| 亚洲中国最大av网站| 成人免费精品视频| 欧美va天堂va视频va在线| 亚洲一区在线观看视频| 91视频在线看| 国产精品三级av| 99久久综合99久久综合网站| 开心九九激情九九欧美日韩精美视频电影 | 欧美伊人精品成人久久综合97| 国产欧美日韩在线| 激情成人综合网| 欧美一区中文字幕| 亚洲成av人片在线观看| 99久久婷婷国产综合精品电影 | 丝袜美腿亚洲色图| 日本高清不卡aⅴ免费网站| 国产精品三级电影| 国产成人av一区二区三区在线观看| 欧美一区午夜视频在线观看| 亚洲高清不卡在线观看| 欧美亚洲丝袜传媒另类| 亚洲综合av网| 欧美日韩午夜影院| 亚洲成人av免费| 欧洲精品中文字幕| 亚洲制服丝袜一区| 日本电影欧美片| 亚洲综合免费观看高清完整版| 97精品视频在线观看自产线路二| 欧美经典一区二区| 国产成人精品一区二区三区四区 | 国产丝袜美腿一区二区三区| 激情小说欧美图片| 精品国产麻豆免费人成网站| 蜜臀99久久精品久久久久久软件| 欧美一区二区三区色| 日韩av在线免费观看不卡| 日韩欧美高清dvd碟片| 激情偷乱视频一区二区三区| 日韩午夜激情电影| 久久精品国产一区二区三| 欧美xxxx老人做受| 国产精品一区免费视频| 国产精品污污网站在线观看| 色诱亚洲精品久久久久久| 亚洲va天堂va国产va久| 欧美变态tickling挠脚心| 国产成人免费av在线| 亚洲少妇屁股交4| 欧美色欧美亚洲另类二区| 六月丁香婷婷久久| 久久久久国产精品麻豆| 91丝袜国产在线播放| 亚洲成a人v欧美综合天堂下载| 日韩小视频在线观看专区| 国产高清不卡二三区| 亚洲日本一区二区| 5566中文字幕一区二区电影|