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

C++ semTake函数代码示例

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

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



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

示例1: sem2Task

void sem2Task  (long a0, long a1, long a2, long a3, long a4,
		long a5, long a6, long a7, long a8, long a9)
{
    WIND_TCB *pTcb = taskTcb(taskIdSelf());
    ULONG date;
    int n;

    TEST_ASSERT(pTcb != NULL);

    TEST_ASSERT(taskNameToId("Test2") == (TASK_ID)pTcb);

    TEST_MARK();

    TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER));

    TEST_MARK();

    TEST_ASSERT_OK(taskResume(a0));

    TEST_MARK();
    date = tickGet();
    for (n = 0; n < 1000000; n++) {
	    ULONG old_date = date;
	    date = tickGet();
	    if (date != old_date)
		    TEST_MARK();
    }

    TEST_MARK(); /* Should not pass this mark */
}
开发者ID:wangxin0020,项目名称:xenosim,代码行数:34,代码来源:t010823-2.c


示例2: pe_dispatcher

void pe_dispatcher()
{
	int i;
	Message msg;
	
	for(;;)
	{
		msgQReceive(msgQ_dispatcher, (char*)&msg, sizeof(msg), WAIT_FOREVER);
		
		semTake(mut_table_capt, WAIT_FOREVER);
		// On cherche si
		for(i=0; i < DEVICE_MAX_COUNT; ++i)
		{
			if(table_capt[i].specific.state == opened &&
			   table_capt[i].specific.address == msg.date.tv_nsec)
			// On fait passer l'adresse par la date non initialisé pour éviter des champs de mémoire supplémentaire inutile.
			{
				// Trouvé : on ne drop pas le message.
				clock_gettime(CLOCK_REALTIME, &(msg.date));

				semTake(mut_table_buffer, WAIT_FOREVER);
				memcpy((char*)&(table_buffer[i]), (char*)&msg, sizeof(Message));
				semGive(mut_table_buffer);
				
				break;
			}
		}
		semGive(mut_table_capt);
	}
}
开发者ID:boysb25,项目名称:VxWorks-Driver,代码行数:30,代码来源:driverl.c


示例3: Philosopher

void Philosopher (int i, int Philos)   {
	while (1) {

             if (i==Philos-1){
 				taskDelay (DELAY_TICKS);
 				printf("Philosopher %d - start thinking\n", i+1);
 				semTake(Sema_fork[0], WAIT_FOREVER);
 				taskDelay(X);
 				semTake (Sema_fork[Philos-1], WAIT_FOREVER);
 				printf("Philosopher %d - start eating\n", i+1);
 				taskDelay(10);
 				semGive(Sema_fork[Philos-1]);
 				semGive(Sema_fork[0]);
                p[i]++;
            	           	 
             }
             else {
				taskDelay (DELAY_TICKS);
				printf("Philosopher %d - start thinking\n", i+1);
				semTake(Sema_fork[i], WAIT_FOREVER);
				taskDelay(X);
				semTake (Sema_fork[i+1], WAIT_FOREVER);
				printf("Philosopher %d - start eating\n", i+1);
				taskDelay(10);
				semGive(Sema_fork[i]);
				semGive(Sema_fork[i+1]);
                p[i]++;
              }		
	};
	
}
开发者ID:abdelmo,项目名称:C-CPP,代码行数:31,代码来源:Dining-Philosophers.c


示例4: pe_deviceRemove

/**
 * @brief Enlever un périphérique.
 * @param i L'index du device à enlever
 * @return OK pour un succès, ERROR sinon. 
 */
int pe_deviceRemove(int i)
{
	semTake(mut_table_capt, WAIT_FOREVER);
	if(i < DEVICE_MAX_COUNT && table_capt[i].specific.state != notcreated)
	{	
		iosDevDelete((DEV_HDR*)&(table_capt[i]));
		table_capt[i].specific.state = notcreated;
		table_capt[i].specific.address = -1;
		semGive(mut_table_capt);
		
		semTake(mut_table_capt, WAIT_FOREVER);
		table_buffer[i].id = -1;
		semGive(mut_table_buffer);
		
		return OK;
	}
	else
	{
		// Le capteur n'a pas été crée :
		// " If the device was never added to the device list, 
		//   unpredictable results may occur."
		semGive(mut_table_capt);
		errnoSet(ENEXIST);
		return ERROR;
	}
}
开发者ID:boysb25,项目名称:VxWorks-Driver,代码行数:31,代码来源:driverl.c


示例5: send_sim_state

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

sends the entire joint_sim_state to shared memory
	

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

none

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

  // joint state
  if (semTake(sm_joint_sim_state_sem,ns2ticks(TIME_OUT_NS)) == ERROR) {
    
    ++simulation_servo_errors;
    return FALSE;

  } 

  cSL_Jstate(joint_sim_state,sm_joint_sim_state_data,n_dofs,DOUBLE2FLOAT);
    
  for (i=1; i<=n_dofs; ++i)
    sm_joint_sim_state->joint_sim_state[i] = sm_joint_sim_state_data[i];

  sm_joint_sim_state->ts = simulation_servo_time;
  
  semGive(sm_joint_sim_state_sem);


  // base state
  if (semTake(sm_base_state_sem,ns2ticks(TIME_OUT_NS)) == ERROR) {
    
    ++simulation_servo_errors;
    return FALSE;

  } 

  cSL_Cstate((&base_state)-1, sm_base_state_data, 1, DOUBLE2FLOAT);

  sm_base_state->state[1] = sm_base_state_data[1];

  sm_base_state->ts = simulation_servo_time;
  
  semGive(sm_base_state_sem);


  // base orient
  if (semTake(sm_base_orient_sem,ns2ticks(TIME_OUT_NS)) == ERROR) {
    
    ++simulation_servo_errors;
    return FALSE;

  } 

  cSL_quat(&base_orient-1, sm_base_orient_data, 1, DOUBLE2FLOAT);

  sm_base_orient->orient[1] = sm_base_orient_data[1];

  sm_base_orient->ts = simulation_servo_time;
  
  semGive(sm_base_orient_sem);


  return TRUE;
}
开发者ID:Riba7,项目名称:hoap-sl,代码行数:76,代码来源:SL_simulation_servo.c


示例6: os_mutexInit

os_result os_mutexInit (os_mutex *mutex, const os_mutexAttr *mutexAttr)
{
    os_mutexAttr defAttr;
    os_result rv;
    int options;
    SEM_ID id;

    assert (mutex != NULL);
    #ifdef OSPL_STRICT_MEM
    assert (mutex->signature != OS_MUTEX_MAGIC_SIG);
#endif

    if(!mutexAttr) {
        os_mutexAttrInit(&defAttr);
        mutexAttr = &defAttr;
    }

    options = (SEM_Q_PRIORITY | SEM_DELETE_SAFE);
    /* Set option for priority inheritance if feature is enabled */
    if (ospl_mtx_prio_inherit) {
        options = options | SEM_INVERSION_SAFE;
    }
    if (mutexAttr->scopeAttr == OS_SCOPE_SHARED) {
        /* create named mutex using shared address as unique name */
        snprintf (mutex->name, sizeof (mutex->name), "/%lu", (os_uint32) mutex);
        id = semOpen (mutex->name, SEM_TYPE_MUTEX, SEM_EMPTY, options, OM_CREATE|OM_EXCL, NULL);
        /* As it may exist from a previous run. remove leftover semaphore object */
        if (id != NULL) {
            /* a fresh one, initialise it and cache the SEM_ID */
            pa_st32 ((void *) &mutex->info.id, 0);
            semTake (cache_lock, WAIT_FOREVER);
            (void) ut_tableInsert ((ut_table) cache, mutex, id);
            semGive (cache_lock);
        } else {
            /* re-using an old one: it should have been destroyed and hence should have a marker in info.id */
            id = get_mutex (mutex);
            if (id != NULL) {
                semTake (id, WAIT_FOREVER);
                semGive (id);
                /*cas_mutex_info_id ((void*)&mutex->info.id, invalid_sem_id, 0);*/
            } else {
                mutex_panic ("init: attempt to reuse semaphore currently in use", 0);
            }
        }

        rv = (id != NULL) ? os_resultSuccess : os_resultFail;
    } else {
        int result;
        mutex->name[0] = '\0';
        /* TODO attrs */
        result = pthread_mutex_init(&mutex->info.posix_mutex, NULL);
        rv = (result == 0) ? os_resultSuccess : os_resultFail;
    }

#ifdef OSPL_STRICT_MEM
    mutex->signature = OS_MUTEX_MAGIC_SIG;
#endif
    return rv;
}
开发者ID:osrf,项目名称:opensplice,代码行数:59,代码来源:os_mutex.c


示例7: semTake

Preferences::~Preferences()
{
    semTake(m_tableLock, WAIT_FOREVER);
    semDelete(m_tableLock);
    semTake(m_fileLock, WAIT_FOREVER);
    semDelete(m_fileOpStarted);
    semDelete(m_fileLock);
}
开发者ID:errorcodexero,项目名称:porting,代码行数:8,代码来源:Preferences.cpp


示例8: RandomizerThreadFunc

int RandomizerThreadFunc(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10)
{
    int operation, semIdx, semTimeout;
    int stat=0;

    while(1)
    {	
        operation  = (int) (rand() * 2.) / RAND_MAX;
        semIdx	   = (int) (rand() * 2.) / RAND_MAX;
        semTimeout = (int) rand() * 5. / RAND_MAX;

        switch( operation )
        {
            case 0:	
                cTake++;
                switch( semIdx )
                {
                    case 0: stat = semTake( s_binary, semTimeout );break;
                    case 1: stat = semTake( s_counting, semTimeout );break;
                }
                if ( OK != stat )
                {
                    if( S_objLib_OBJ_TIMEOUT == errno || S_objLib_OBJ_UNAVAILABLE == errno )
                    {
                        cTakeTimeout++;
                    }
                    else
                    {
                        cTakeErr++;
                        puts("");
                        perror("Error taking semaphore");
                    }
                }
                break;

            case 1:
                cGive++;
                switch( semIdx )
                {
                    case 0: stat = semGive( s_binary );break;
                    case 1: stat = semGive( s_counting );break;
                }
                if ( OK != stat )
                    cGiveErr++;
                break;
            default:break;

        } //switch( operation )

    } //while(1)
}
开发者ID:dubrousky,项目名称:v2lin,代码行数:51,代码来源:test_sem.c


示例9: semTake

static DMA_MSG *getDmaBuffer (SND_DEV *pDev)
{
  DMA_MSG *dmaBuffer;

  semTake (pDev->bufSem, WAIT_FOREVER);

  semTake (pDev->devSem, WAIT_FOREVER);
/*  dmaBuffer = snd_dmaBuffer + pDev->dmaIndex * MAX_DMA_SIZE;*/
  dmaBuffer = &snd_buffer[pDev->dmaIndex];
  pDev->dmaIndex = (pDev->dmaIndex + 1) % MAX_DMA_MSGS;
  semGive (pDev->devSem);

  return dmaBuffer;
}
开发者ID:rgmabs19357,项目名称:gameseer,代码行数:14,代码来源:dac3550drv.c


示例10: devDelete

int devDelete(char* devName)
{
	myDev * i = first;
	char * pNameTail;
	myDev * dev = (myDev*) iosDevFind (devName,&pNameTail);
	if ((*pNameTail)!='\0' || dev==NULL)
	//If pNameTail is not '\0', either we don't have an exact match
	//or we have no match at all
	{
		errnoSet(UNKNOWN_DEVICE);
		semGive(semMAdmin);
		return -1;
	}
	if(semMAdmin==0)
	{
		errnoSet(NOT_INSTALLED);
		return -1;
	}
	if(semTake(semMAdmin,WAIT_FOREVER)==-1)
	{
		errnoSet(SEM_ERR);
		return -1;
	}
	
	if (dev->openned != 0)
	{
		//There are still openned file descriptors on this device,
		//we can't delete it, give back semaphores and leave.
		semGive(dev->semMData);
		errnoSet(OPENNED_DEV);
		semGive(semMAdmin);
		return -1;
	}
	iosDevDelete((DEV_HDR*)dev); //This only prevents further oppenings. 
	//Find and delete the device in device list :
	if (dev==first)
	{
		first=dev->next;
	} else {
		for (i=first;i->next!=dev;i=i->next);
		i->next=dev->next;
	}
	semTake(dev->semMData,WAIT_FOREVER); //Let pending ops on this dev finish
	semDelete(dev->semMData); //We don't need to release it to delete it
	free(dev);
	semGive(semMAdmin);
	return 0;
}
开发者ID:hermixy,项目名称:driver,代码行数:48,代码来源:driver.c


示例11: ShbIpcThreadSignalJobReady

//------------------------------------------------------------------------------
// Function:    ShbIpcThreadSignalJobReady
//
// Description: Thread for new data Job Ready signaling
//
// Parameters:
//      pvThreadParam_p         user parameters for thread
//
// Return:      void *          thread exit value (not used)
//------------------------------------------------------------------------------
int ShbIpcThreadSignalJobReady (int pvThreadParam_p)
{
    tShbInstance        pShbInstance;
    tShbMemInst         *pShbMemInst;
    tShbMemHeader*      pShbMemHeader;
    INT                 iRetVal;
    UINT                fTimeOut;

    EPL_DBGLVL_SHB_TRACE("%s(): ThreadId:%ld\n", __func__);

    pShbInstance = (tShbMemInst*)pvThreadParam_p;
    pShbMemInst = ShbIpcGetShbMemInst (pShbInstance);
    pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance);

    pShbMemInst->m_fJobReadyThreadStarted = TRUE;

    if (pShbMemInst->m_ulTimeOutMsJobReady != 0)
    {
    	// todo: timeout is in ticks!!
        iRetVal = semTake(pShbMemHeader->m_semJobReady,
        		          pShbMemInst->m_ulTimeOutMsJobReady);
    }
    else
    {
        iRetVal = semTake(pShbMemHeader->m_semJobReady, WAIT_FOREVER);
    }

    if (iRetVal == OK)
    {
        fTimeOut = FALSE;
    }
    else
    {
        /* timeout or error */
        fTimeOut = TRUE;
    }

    if (pShbMemInst->m_pfnSigHndlrJobReady != NULL)
    {
        //call Handler
        pShbMemInst->m_pfnSigHndlrJobReady(pShbInstance, fTimeOut);
    }

    pShbMemInst->m_pfnSigHndlrJobReady = NULL;
    pShbMemInst->m_fJobReadyThreadStarted = FALSE;

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


示例12: semTake

NetworkTable::~NetworkTable()
{
	delete m_hasAdded;
	delete m_hasChanged;
	delete m_transaction;
	semTake(m_listenerLock, WAIT_FOREVER);
	m_connectionListeners.clear();
	m_additionListeners.clear();
	m_listeners.clear();
	m_listenToAllListeners.clear();
	semDelete(m_listenerLock);
	semTake(m_dataLock, WAIT_FOREVER);
	m_connections.clear();
	m_data.clear();
	semDelete(m_dataLock);
}
开发者ID:bescovedo,项目名称:becode,代码行数:16,代码来源:NetworkTable.cpp


示例13: ShbIpcEnterAtomicSection

//------------------------------------------------------------------------------
// Function:    ShbIpcEnterAtomicSection
//
// Description: Enter atomic section for Shared Buffer access
//
// Parameters:  pShbInstance_p          pointer to shared buffer instance
//
// Return:      tShbError      = error code
//------------------------------------------------------------------------------
tShbError  ShbIpcEnterAtomicSection (tShbInstance pShbInstance_p)
{
    tShbMemInst         *pShbMemInst;
    tShbMemHeader       *pShbMemHeader;
    tShbError           ShbError;

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

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

    if (semTake (pShbMemHeader->m_mutexBuffAccess, TIMEOUT_ENTER_ATOMIC) == OK)
    {
        ShbError = kShbOk;
    }
    else
    {
        ShbError = kShbBufferInvalid;
    }

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


示例14: ShbIpcThreadSignalNewData

//------------------------------------------------------------------------------
// Function:    ShbIpcThreadSignalNewData
//
// Description: Thread for new data signaling
//
// Parameters:
//      pvThreadParam_p         user parameters for thread
//
// Return:      void *          thread exit value (not used)
//------------------------------------------------------------------------------
int ShbIpcThreadSignalNewData (int pvThreadParam_p)
{
    tShbInstance        pShbInstance;
    tShbMemInst*        pShbMemInst;
    tShbMemHeader*      pShbMemHeader;
    INT                 iRetVal;

    /* thread parameter contains pointer to shared memory */
    pShbInstance = (tShbMemInst*)pvThreadParam_p;

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

    /* signal that thread is running */
    pShbMemInst->m_fNewDataThreadStarted = TRUE;

    do
    {
        if ((iRetVal = semTake(pShbMemHeader->m_semNewData,
        		               TIMEOUT_CANCEL_THREAD)) == OK)
        {
            //check terminate flag
            if (!pShbMemInst->m_fThreadTermFlag)
            {
                pShbMemInst->m_pfnSigHndlrNewData(pShbInstance);
            }
        }
    } while(!pShbMemInst->m_fThreadTermFlag);

    //set sem thread terminated
    pShbMemInst->m_fNewDataThreadStarted = FALSE;
    semGive(pShbMemHeader->m_semStopSignalingNewData);

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


示例15: semTake

/**
 * Execute a transaction with a Jaguar that sets some property.
 *
 * Jaguar always acks when it receives a message.  If we don't wait for an ack,
 * the message object in the Jaguar could get overwritten before it is handled.
 *
 * @param messageID The messageID to be used on the CAN bus (device number is added internally)
 * @param data The up to 8 bytes of data to be sent with the message
 * @param dataSize Specify how much of the data in "data" to send
 */
void CANJaguar::setTransaction(uint32_t messageID, const uint8_t *data, uint8_t dataSize)
{
    uint32_t ackMessageID = LM_API_ACK | m_deviceNumber;
    int32_t localStatus = 0;

    // If there was an error on this object and it wasn't a timeout, refuse to talk to the device
    // Call ClearError() on the object to try again
    if (StatusIsFatal() && GetError().GetCode() != -44087)
	return;

    // Make sure we don't have more than one transaction with the same Jaguar outstanding.
    semTake(m_transactionSemaphore, WAIT_FOREVER);

    // Throw away any stale acks.
    receiveMessage(&ackMessageID, NULL, 0, 0.0f);
    // Send the message with the data.
    localStatus = sendMessage(messageID | m_deviceNumber, data, dataSize);
    wpi_setErrorWithContext(localStatus, "sendMessage");
    // Wait for an ack.
    localStatus = receiveMessage(&ackMessageID, NULL, 0);
    wpi_setErrorWithContext(localStatus, "receiveMessage");

    // Transaction complete.
    semGive(m_transactionSemaphore);
}
开发者ID:errorcodexero,项目名称:porting,代码行数:35,代码来源:CANJaguar.cpp


示例16: runToCompletion

void StateMachine :: runToCompletion() {
	std::string actualEvent;
	int d,i,j;
	while (TRUE) {
		semTake (semEvent, WAIT_FOREVER);
		actualEvent = getEvent(); // Get the event from the queue
		//printf(actualEvent.c_str()); // For debug purposes only
		for (d = 0; d < diagrams; d++) {
			for (i = 0; i < lines[d]; i++) {
				if ((actualState[d] == tab[d][i]->actState) && 
						(actualEvent == tab[d][i]->myEvent) && 
						((*tab[d][i]->condition)() == TRUE)) { // Call the condition function which returns bool
					actualState[d] = tab[d][i]->nextState;
					(*tab[d][i]->action)(); //Call the funtion defined by pointer action
					for (j = 0; j < lines[d]; j++) {
						if ((actualState[d] == tab[d][j]->actState) && 
								(tab[d][j]->myEvent == (diaTimerTable[d]->timerName))) {
							diaTimerTable[d]->startTimer(tab[d][j]->eventTime); // Look for timers to start next
							break;
						}
					}
					break;
				}
			}
		}
	}
}
开发者ID:Domidos,项目名称:ConveyerBeltProject,代码行数:27,代码来源:stateMachine.cpp


示例17: EplApiProcessImageWaitForCompletion

static tEplKernel EplApiProcessImageWaitForCompletion(
    tEplApiProcessImageCopyJobInt* pCopyJob_p)
{
    tEplKernel      Ret = kEplSuccessful;

#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
    int             iRes;

    iRes = wait_for_completion_interruptible(&pCopyJob_p->m_Event.m_pCompletion->m_Completion);
    if (iRes != 0)
    {
        Ret = kEplShutdown;
    }

#elif (TARGET_SYSTEM == _LINUX_) && !defined(__KERNEL__)
    sem_wait(&pCopyJob_p->m_Event.m_semCompletion);
#elif (TARGET_SYSTEM == _WIN32_)
    WaitForSingleObject(pCopyJob_p->m_Event.m_hEvent, INFINITE);
#elif (TARGET_SYSTEM == _VXWORKS_)
    semTake(pCopyJob_p->m_Event.m_semCompletion, WAIT_FOREVER);
#else
#error "OS currently not supported by EplApiProcessImage!"
#endif

//Exit:
    return Ret;
}
开发者ID:victorlp,项目名称:openPOWERLINK_systec,代码行数:27,代码来源:EplApiProcessImage.c


示例18: sync

/**
 * Free the resources for a timer event.
 * All resources will be freed and the timer event will be removed from the
 * queue if necessary.
 */
Notifier::~Notifier()
{
    tRioStatusCode localStatus = NiFpga_Status_Success;
    {
        Synchronized sync(queueSemaphore);
        DeleteFromQueue();

        // Delete the static variables when the last one is going away
        if (!(--refcount))
        {
            talarm->writeEnable(false, &localStatus);
            delete talarm;
            talarm = NULL;
            manager->disable(&localStatus);
            delete manager;
            manager = NULL;
        }
    }
    wpi_setError(localStatus);

    // Acquire the semaphore; this makes certain that the handler is 
    // not being executed by the interrupt manager.
    semTake(m_handlerSemaphore, WAIT_FOREVER);
    // Delete while holding the semaphore so there can be no race.
    semDelete(m_handlerSemaphore);
}
开发者ID:anidev,项目名称:frc-simulator,代码行数:31,代码来源:Notifier.cpp


示例19: RecvTask

int RecvTask(   int sockfd/* server's socket fd */  )
{
	/*int i,j;*/
        while(1) 
        {
            /*nRead = read(newFd, adNauseam, sizeof (adNauseam));
            if ( nRead < 0 )
            {
                perror ("read");
                close (sFd);
                return (ERROR);
	    }*/
        static int kk=0;
        kk++;
            semTake(SEM_DMA_Playback, WAIT_FOREVER);
           /* semTake(SEM_Sample, WAIT_FOREVER);*/
            loadbuffer(saved_samples, DAC_BUFFER_SIZE);
	    	if(DTC_DMA_Playback)
	    	{
	    		printf("\e[1;1H task0=%d     %d \n", kk);
                memmove(DAC_BUFFER+(DAC_BUFFER_SIZE/2),saved_samples/*adNauseam*/, (DAC_BUFFER_SIZE/2));
	    	}
            else
            {
            	printf("\e[1;40H task1=%d    [%d]  \n", kk );
                memmove(DAC_BUFFER,/*adNauseam*/saved_samples, (DAC_BUFFER_SIZE/2));
            }
	   

        } /* end while awaiting frames */
开发者ID:tejasnjoshi,项目名称:ecen_5623_real_time_embedded_systems,代码行数:30,代码来源:AudioInit2.c


示例20: tWrite

// Lab01/2 -  for third task
void tWrite(void){
	while(1){
		beLazy(100);
		char stringBufferPot[50];
		char stringBufferTemp[50];
		char stringBufferKey[50];
		
		semTake(writeSem, WAIT_FOREVER);
		sprintf(stringBufferTemp, "Temperature: %d   ",AInTemp);
		//sprintf(stringBufferPot, "Potentiomenter: %d   ",AInPot);
		sprintf(stringBufferKey, "Gedrueckte Taste: %d   ", key);
		
		if(key == 49){
			sprintf(stringBufferPot, "Potentiometer: %d                      ",AInPot);
		}
		else if(key == 50){
			//calculation of the voltage based on the input value 58...4095
			float k = (5.0/4037);
			float d = (float)(-k*58);
			float calc = (float)(k* AInPot+d);
			sprintf(stringBufferPot, "Potentiometer: %f V                      ",calc);
		}
		else if (key == 51){
			sprintf(stringBufferPot, "Potentiometer: %x                        ", AInPot);
		}
		else{
			sprintf(stringBufferPot, "Error - key 1,2 or 3 should be used");
		}
		writeToDisplay(0,0, stringBufferPot);
		writeToDisplay(1,0, stringBufferTemp);
		writeToDisplay(2,0, stringBufferKey);
		semGive(writeSem);
	}
}
开发者ID:EstebanFuerte,项目名称:FHV_MEM_2015WS_EmbeddedSystems,代码行数:35,代码来源:MEM.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sem_close函数代码示例发布时间:2022-05-30
下一篇:
C++ semGive函数代码示例发布时间: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