• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ semGive函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中semGive函数的典型用法代码示例。如果您正苦于以下问题:C++ semGive函数的具体用法?C++ semGive怎么用?C++ semGive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了semGive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: event_info_alloc

static struct event_info * event_info_alloc(int event) {
    int nxt;
    struct event_info * info;
    SPIN_LOCK_ISR_TAKE(&events_lock);
    if (events_buf_overflow) {
        SPIN_LOCK_ISR_GIVE(&events_lock);
        return NULL;
    }
    info = events + events_inp;
    nxt = (events_inp + 1) % MAX_EVENTS;
    if (nxt == events_out) {
        events_buf_overflow = 1;
        semGive(events_signal);
        SPIN_LOCK_ISR_GIVE(&events_lock);
        return NULL;
    }
    memset(info, 0, sizeof(struct event_info));
    info->event = event;
    events_inp = nxt;
    events_cnt++;
    return info;
}
开发者ID:eswartz,项目名称:emul,代码行数:22,代码来源:context-vxworks.c


示例2: TI81XX_SPI_LOG

STATUS ti81xxSpiChannelConfig
    (
    int module,     /* SPI module number */
    int channel,    /* SPI channel number */
    int cfgValue    /* SPI channel configure value */
    )
    {
    if (ti81xxMcSpiSanityCheck(module, channel) == ERROR)
        {
        TI81XX_SPI_LOG("%s : invalid parameter.\n", __FUNCTION__, 0, 0, 0, 0, 0);
        return (ERROR);
        }

    semTake(mcSpiSem[module], WAIT_FOREVER);

    TI81XX_SPI_REGISTER_WRITE(module, MCSPI_CHxCONF(channel), cfgValue);

    semGive(mcSpiSem[module]);

    return (OK);

    }
开发者ID:TomCrowley-ME,项目名称:me_sim_test,代码行数:22,代码来源:ti81xxMcSpi.c


示例3: send_misc_sensors

/*!*****************************************************************************
*******************************************************************************
\note  send_misc_sensors
\date  Nov. 2007
   
\remarks 

sends the entire misc_sim_sensors to shared memory
	

*******************************************************************************
Function Parameters: [in]=input,[out]=output

none

******************************************************************************/
int 
send_misc_sensors(void)
{
  
  int i;

  if (semTake(sm_misc_sim_sensor_sem,ns2ticks(TIME_OUT_NS)) == ERROR) {
    
    ++simulation_servo_errors;
    return FALSE;

  } 

  for (i=1; i<=n_misc_sensors; ++i)
    sm_misc_sim_sensor->value[i] = misc_sim_sensor[i];

  sm_misc_sim_sensor->ts = simulation_servo_time;
  
  semGive(sm_misc_sim_sensor_sem);

  return TRUE;
}
开发者ID:akshararai,项目名称:HERMES_qp,代码行数:38,代码来源:SL_simulation_servo.c


示例4: defined

void Semaphore::give()
{
#if defined (PTHREADS)
	if (sem_post(sem))
	{
		throw Exception("Could not release semaphore", errno, __FILE__, __LINE__);
	}

#elif defined(VXWORKS)
	if (semGive(sem))
	{
		throw Exception("Could not release semaphore", -1, __FILE__, __LINE__);
	}

#elif defined(_WINDOWS)
	if (! ReleaseSemaphore(sem,1,NULL))
	{
		throw Exception("Could not release semaphore", GetLastError(), __FILE__, __LINE__);
	}

#endif
}
开发者ID:JosephFoster118,项目名称:RobotSoftware,代码行数:22,代码来源:Semaphore.cpp


示例5: return

STATUS virtualStackNumGet
    (
    VSID vsid,
    int *num
    )
    {
    
    if ((vsid == NULL) && (num == NULL))
        return (ERROR);

    semTake (vsTblLock, WAIT_FOREVER);
    
    for (*num = 0; (*num < VSID_MAX) && (vsTbl[*num] != vsid); (*num)++);

    semGive(vsTblLock);

    if ( vsTbl[*num] != vsid )
	return (ERROR);

    return OK;

    }
开发者ID:andy345,项目名称:vxworks5,代码行数:22,代码来源:vsLib.c


示例6: ShbIpcStopSignalingNewData

//------------------------------------------------------------------------------
// Function:    ShbIpcStopSignalingNewData
//
// Description: Stop signaling of new data (called from reading process)
//
// Parameters:  pShbInstance_p        pointer to shared buffer instance
//
// Return:      tShbError      = error code
//------------------------------------------------------------------------------
tShbError ShbIpcStopSignalingNewData(tShbInstance pShbInstance_p)
{
    tShbMemInst         *pShbMemInst;
    tShbMemHeader       *pShbMemHeader;
    tShbError           ShbError;
    INT                 iRetVal = -1;

    if (pShbInstance_p == NULL)
    {
        return (kShbInvalidArg);
    }

    pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance_p);
    pShbMemInst = ShbIpcGetShbMemInst (pShbInstance_p);

    ShbError = kShbOk;

    if (!pShbMemInst->m_fNewDataThreadStarted)
    {
        ShbError = kShbBufferAlreadyCompleted;
        goto Exit;
    }

    //set termination flag and signal new data to terminate thread
    pShbMemInst->m_fThreadTermFlag = TRUE;
    semGive(pShbMemHeader->m_semNewData);

    iRetVal = semTake(pShbMemHeader->m_semStopSignalingNewData,
    		          TIMEOUT_WAITING_THREAD);
    if (iRetVal == ERROR)
    {
        EPL_DBGLVL_ERROR_TRACE("%s() Stop Sem TIMEOUT %d (%s)\n", __func__,
        		                iRetVal, strerror(errno));
    }

Exit:

    return (ShbError);
}
开发者ID:vinodpa,项目名称:openPOWERLINK_systec,代码行数:48,代码来源:ShbIpc-VxWorks.c


示例7: devClose

int devClose(myDev * dev)
{
	fifo * i = NULL; 
	fifo * temp = NULL;
	if(dev==NULL)
	{
		errnoSet(NOT_OPEN);
		return -1;
	}
	//Prevent anyone from accessing this device while we're modifying it :
	if(semTake(dev->semMData,WAIT_FOREVER)==-1)
	{
		errnoSet(SEM_ERR);
		return -1;
	}
	if (dev->openned == 0)
	{
		errnoSet(NOT_OPEN);
		return -1;
	} else {
		//Find fifo corresponding to this task in drv->listFifo and deallocate it
		if (dev->firstFifo->taskId==taskIdSelf())
		{
			temp=dev->firstFifo;
			dev->firstFifo=temp->nextFifo;
			deleteFifo(temp);
			free(temp);
		} else {
			for (i=dev->firstFifo;i->nextFifo->taskId==taskIdSelf();i=i->nextFifo);
			temp=i->nextFifo;
			i->nextFifo=temp->nextFifo;
			deleteFifo(temp);
			free(temp);
		}
		dev->openned--;
	}
	semGive(dev->semMData);
	return 0;
}
开发者ID:hermixy,项目名称:driver,代码行数:39,代码来源:driver.c


示例8: BST_OS_PalSendSem

BST_ERR_ENUM_UINT8  BST_OS_PalSendSem(
    BST_OS_PAL_SEM_T    stSemHandle,
    BST_VOID           *pvArg )
{
    if( BST_PAL_IsSemInValid( stSemHandle ) )
    {
        return BST_ERR_ILLEGAL_PARAM;
    }

#if (VOS_RTOSCK == VOS_OS_VER)
    if( VOS_OK == VOS_SmV(stSemHandle) )
#else
    if( OK == semGive(stSemHandle) )
#endif
    {
        return BST_NO_ERROR_MSG;
    }
    else
    {
        return BST_ERR_ILLEGAL_PARAM;
    }
}
开发者ID:debbiche,项目名称:android_kernel_huawei_p8,代码行数:22,代码来源:BST_PAL_Sync.c


示例9: ssh_netjob_synchronous_invoke

/* Move execution to netJob. returns 0 if successful. */
int ssh_netjob_synchronous_invoke(FUNCPTR function, void *context)
{
  STATUS stat;
  SEMAPHORE *s;

  s = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
  if (!s) return 2;
  
  semTake(s, WAIT_FOREVER);
  stat = netJobAdd(function, (int)context, (int)s, 0, 0, 0);

  if (stat == OK) 
    {
      semTake(s, WAIT_FOREVER);
      semDelete(s);
      return 0;
    }

  semGive(s);
  semDelete(s);
  return 1;
}
开发者ID:patrick-ken,项目名称:kernel_808l,代码行数:23,代码来源:icept_kernel_stubs_vxworks.c


示例10: errnoSet

/******************************************************************************
*
* m2SysGroupInfoSet - set system-group MIB-II variables to new values
*
* This routine sets one or more variables in the system group as specified in
* the input structure at <pSysInfo> and the bit field parameter <varToSet>.
*
* RETURNS: 
* OK, or ERROR if <pSysInfo> is not a valid pointer, or <varToSet> has an 
* invalid bit field.
*
* ERRNO:
*  S_m2Lib_INVALID_PARAMETER
*  S_m2Lib_INVALID_VAR_TO_SET
*
* SEE ALSO: m2SysInit(), m2SysGroupInfoGet(), m2SysDelete()
*/
STATUS m2SysGroupInfoSet
    (
    unsigned int varToSet,		/* bit field of variables to set */
    M2_SYSTEM * pSysInfo		/* pointer to the system structure */
    )
    {
 
    /* Validate Pointer to System structure and bit field in varToSet */
 
    if (pSysInfo == NULL ||
        (varToSet & (M2SYSNAME | M2SYSCONTACT | M2SYSLOCATION)) == 0)
	{
	if (pSysInfo == NULL)
	    errnoSet (S_m2Lib_INVALID_PARAMETER);
	else
	    errnoSet (S_m2Lib_INVALID_VAR_TO_SET);

        return (ERROR);
	}
 
    /* Set requested variables */
 
    semTake (m2SystemSem, WAIT_FOREVER);
 
    if (varToSet & M2SYSNAME)
        strcpy ((char *) m2SystemVars.sysName, (char *) pSysInfo->sysName);
 
    if (varToSet & M2SYSCONTACT)
        strcpy ((char *) m2SystemVars.sysContact, (char *)pSysInfo->sysContact);
 
    if (varToSet & M2SYSLOCATION)
        strcpy ((char *) m2SystemVars.sysLocation, 
		(char *) pSysInfo->sysLocation);
 
    semGive (m2SystemSem);
 
    return (OK);
    }
开发者ID:andy345,项目名称:vxworks5,代码行数:55,代码来源:m2SysLib.c


示例11: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	classLibInit();
	memPartLibInit(memBuf, MEM_LEN);

	char* a1 = (char*)memPartAlloc(memSysPartId, 10);
	char* a2 = (char*)memPartAlloc(memSysPartId, 45);
	memPartFree(memSysPartId, a1);
	memPartFree(memSysPartId, a2);

	a1 = (char*)memPartAlloc(memSysPartId, 10);
	a2 = (char*)memPartAlloc(memSysPartId, 45);

	memPartFree(memSysPartId, a2);
	memPartFree(memSysPartId, a1);

	a1 = (char*)memPartAlloc(memSysPartId, 10);
	a2 = (char*)memPartAlloc(memSysPartId, 12);
	char* a3 = (char*)memPartAlloc(memSysPartId, 45);

	memPartFree(memSysPartId, a2);

	char* a4 = (char*)memPartAlloc(memSysPartId, 12);

	testQueue();

	SEM_ID semId = semMCreate(0);

	int c = 0;
	semTake(semId, WAIT_FOREVER);
	c++;
	semGive(semId);

	semDelete(semId);

	gets(a1);
	return 0;
}
开发者ID:anders007,项目名称:vxworks-like-kernel,代码行数:38,代码来源:rain.cpp


示例12: DisconnectFromHost

/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(int_T numSampTimes)
{
    int i;

    for (i=0; i<NUM_UPINFOS; i++) {
        UploadPrepareForFinalFlush(i);

#if defined(VXWORKS)
        /*
         * UploadPrepareForFinalFlush() has already called semGive(uploadSem)
         * two times.  Now the server thread will wait until the upload thread
         * has processed all of the data in the buffers for the final upload
         * and exhausted the uploadSem semaphores.  If the server thread
         * attempts to call UploadServerWork() while the upload thread is in
         * the middle of processing the buffers, the target code may crash
         * with a NULL pointer exception (the buffers are destroyed after
         * calling UploadLogInfoTerm).
         */
        while(semTake(uploadSem, NO_WAIT) != ERROR) {
            semGive(uploadSem);
            taskDelay(1000);
        }
#else
#ifndef EXTMODE_DISABLESIGNALMONITORING
        if (host_upstatus_is_uploading) {
            UploadServerWork(i, numSampTimes);
        }
#endif
#endif

        UploadLogInfoTerm(i, numSampTimes);
    }
    
    connected       = false;
    commInitialized = false;
    
    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */
开发者ID:CatarinaSilva,项目名称:SimulinkARDroneTarget,代码行数:42,代码来源:AR_Drone_ext_svr.c


示例13: while

/**
 * ProcessQueue is called whenever there is a timer interrupt.
 * We need to wake up and process the current top item in the timer queue as long
 * as its scheduled time is after the current time. Then the item is removed or 
 * rescheduled (repetitive events) in the queue.
 */
void Notifier::ProcessQueue(uint32_t mask, void *params)
{
    Notifier *current;
    while (true)                // keep processing past events until no more
    {
        {
            Synchronized sync(queueSemaphore);
            double currentTime = GetClock();
            current = timerQueueHead;
            if (current == NULL || current->m_expirationTime > currentTime)
            {
                break;        // no more timer events to process
            }
            // need to process this entry
            timerQueueHead = current->m_nextEvent;
            if (current->m_periodic)
            {
                // if periodic, requeue the event
                // compute when to put into queue
                current->InsertInQueue(true);
            }
            else
            {
                // not periodic; removed from queue
                current->m_queued = false;
            }
            // Take handler semaphore while holding queue semaphore to make sure
            //  the handler will execute to completion in case we are being deleted.
            semTake(current->m_handlerSemaphore, WAIT_FOREVER);
        }

        current->m_handler(current->m_param);    // call the event handler
        semGive(current->m_handlerSemaphore);
    }
    // reschedule the first item in the queue
    Synchronized sync(queueSemaphore);
    UpdateAlarm();
}
开发者ID:anidev,项目名称:frc-simulator,代码行数:44,代码来源:Notifier.cpp


示例14: drvRemove

int drvRemove()
{
	myDev * i = first;
	myDev * drv;
	if (semMAdmin == 0)
	{
		errnoSet(NOT_INSTALLED);
		return -1;
	}
	if (semTake(semMAdmin,WAIT_FOREVER)==-1)
	{
		errnoSet(SEM_ERR);
		return -1;
	}
	if (iosDrvRemove(numPilote,1) == -1) //And force closure of open files
	{
		errnoSet(REMOVE_ERROR);
		semGive(semMAdmin);
		return -1;
	}
	taskDelete(tMsgDispatchID);
	msgQDelete(isrmq);
	//Delete all devices  : 
	while (i!=NULL)
	{
		drv = i;
		i = drv->next;
		iosDevDelete((DEV_HDR*)drv);
		semTake(drv->semMData,WAIT_FOREVER); //Let pending ops finish
		semDelete(drv->semMData);
		free(drv);
	}
	numPilote = -1;
	first = NULL;
	semDelete(semMAdmin);
	semMAdmin=0;
	return 0;
}
开发者ID:hermixy,项目名称:driver,代码行数:38,代码来源:driver.c


示例15: receive_misc_sensors

/*!*****************************************************************************
 *******************************************************************************
\note  receive_misc_sensors
\date  Nov. 2007   
\remarks 

        receives the entire misc_sim_sensors from shared memory
	

 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

     none

 ******************************************************************************/
static int 
receive_misc_sensors(void)
{
  
  int i;

  if (n_misc_sensors <= 0)
    return TRUE;

  if (semTake(sm_misc_sim_sensor_sem,ns2ticks(TIME_OUT_NS)) == ERROR) {
    
    ++motor_servo_errors;
    return FALSE;

  } 

  for (i=1; i<=n_misc_sensors; ++i)
    misc_sim_sensor[i] = sm_misc_sim_sensor->value[i];
  
  semGive(sm_misc_sim_sensor_sem);

  return TRUE;
}
开发者ID:wonjsohn,项目名称:sarcos,代码行数:38,代码来源:SL_user_sensor_proc_unix.c


示例16: DisconnectFromHost

/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(SimStruct *S)
{
    UploadPrepareForFinalFlush();
#ifdef VXWORKS
    /*
     * Patch by Gopal Santhanam 5/24/2002 (for VXWORKS) We
     * were having problems in RTAI in that the semaphore
     * signaled in UploadPrepareForFinalFlush was taken up by
     * the upload server task.  This meant that the subsequent
     * call to rt_UploadServerWork in this function would
     * block indefinitely!
     */
    semGive(uploadSem);
#endif
    rt_UploadServerWork(S);
    
    UploadLogInfoTerm();

    connected       = FALSE;
    commInitialized = FALSE;

    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */
开发者ID:sensysnetworks,项目名称:stromboli-24.1,代码行数:27,代码来源:ext_svr.c


示例17: OS_CloseAllFiles

/* --------------------------------------------------------------------------------------
   Name: OS_CloseAllFiles

   Purpose: Closes All open files that were opened through the OSAL

   Returns: OS_FS_ERROR   if one or more file close returned an error
            OS_FS_SUCCESS if the files were all closed without error
 ---------------------------------------------------------------------------------------*/
int32 OS_CloseAllFiles(void)
{
    uint32            i;
    int32             return_status = OS_FS_SUCCESS;
    int               status;

    semTake(OS_FDTableMutex,WAIT_FOREVER);

    for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
    {
        if ( OS_FDTable[i].IsValid == TRUE )
        {
           /*
           ** Close the file
           */
           status = close ((int) OS_FDTable[i].OSfd);

           /*
           ** Next, remove the file from the OSAL list
           ** to free up that slot
           */
           OS_FDTable[i].OSfd =       -1;
           strcpy(OS_FDTable[i].Path, "\0");
           OS_FDTable[i].User =       0;
           OS_FDTable[i].IsValid =    FALSE;
           if (status == ERROR)
           {
              return_status = OS_FS_ERROR;
           }
        }

    }/* end for */

    semGive(OS_FDTableMutex);
    return (return_status);

}/* end OS_CloseAllFiles */
开发者ID:TomCrowley-ME,项目名称:me_sim_test,代码行数:45,代码来源:osfileapi.c


示例18: logFdAdd

STATUS logFdAdd(
    int fd
    )
{
    STATUS status;

    semTake(&logFdSem, WAIT_FOREVER);

    /* If maximum file descriptor reached */
    if ((numLogFds + 1) > MAX_LOGFDS)
    {
        status = ERROR;
    }
    else
    {
        /* Add file descriptor */
        logFd[numLogFds++] = fd;
        status = OK;
    }

    semGive(&logFdSem);

    return status;
}
开发者ID:phoboz,项目名称:vmx,代码行数:24,代码来源:logLib.c


示例19: node

/*****************************************************************
*
* ArrayStore_T :: fetch
*
* This function looks up a descriptor for the array specified by
* <pObject>. When found, the descriptor is removed from the hash table
* and deleted, then the number of elements is returned. Memory for the
* array descriptor is reclaimed by this function.
*
* RETURNS: the number of elements in the specified array, if found,
*          otherwise -1.
*
* NOMANUAL
*/
int ArrayStore_T :: fetch
    (
    void	* pObject
    )
    {
    int		rval;
    HASH_NODE * pNode;
    ArrayDesc_T	node (pObject, 0);
    semTake (mutexSem, WAIT_FOREVER);
    if ((pNode = hashTblFind (hashId, (HASH_NODE *) (&node), 0)) == 0)
	{
	rval = -1;
	}
    else
	{
	// Cast the fetched pointer back to ArrayDesc_T
	ArrayDesc_T * ad = (ArrayDesc_T *)(pNode);
	rval = ad->nElems;
	hashTblRemove (hashId, (HASH_NODE *) pNode);
	delete ad;
	}
    semGive (mutexSem);
    return rval;
    }
开发者ID:andy345,项目名称:vxworks5,代码行数:38,代码来源:cplusCore.cpp


示例20: addTimer

//------------------------------------------------------------------------------
static void addTimer(tTimeruData* pData_p)
{
    tTimeruData*    pTimerData;

    semTake(timeruInstance_l.mutex, WAIT_FOREVER);

    if (timeruInstance_l.pFirstTimer == NULL)
    {
        timeruInstance_l.pFirstTimer = pData_p;
        timeruInstance_l.pLastTimer = pData_p;
        pData_p->pPrevTimer = NULL;
        pData_p->pNextTimer = NULL;
    }
    else
    {
        pTimerData = timeruInstance_l.pLastTimer;
        pTimerData->pNextTimer = pData_p;
        pData_p->pPrevTimer = pTimerData;
        pData_p->pNextTimer = NULL;
        timeruInstance_l.pLastTimer = pData_p;
    }

    semGive(timeruInstance_l.mutex);
}
开发者ID:Kalycito-open-automation,项目名称:openPOWERLINK_V2,代码行数:25,代码来源:timer-vxworks.c



注:本文中的semGive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ semTake函数代码示例发布时间:2022-05-30
下一篇:
C++ self_exec函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap