BST_ERR_ENUM_UINT8  BST_OS_PalDeleteSem( BST_OS_PAL_SEM_T stSemHandle )
{
    if( BST_PAL_IsSemInValid( stSemHandle ) )
    {
        return BST_ERR_ILLEGAL_PARAM;
    }

#if (VOS_RTOSCK == VOS_OS_VER)
    VOS_SmDelete( stSemHandle );
#else
    semDelete( stSemHandle );
#endif

    return BST_NO_ERROR_MSG;
}
Exemple #2
0
void mutex_delete(OSI_LIB_HANDLE mutex_handle)
{
#ifdef WINDOWS_OS
	DeleteCriticalSection((LPCRITICAL_SECTION)mutex_handle);
#endif

#ifdef VXWORKS_OS
	semDelete((SEM_ID)mutex_handle);
#endif

#ifdef LINUX_OS
	pthread_mutex_destroy((pthread_mutex_t*)mutex_handle);
#endif

}
Exemple #3
0
static int __wind_sem_delete(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	wind_sem_t *sem;

	sem = (wind_sem_t *)xnregistry_fetch(handle);

	if (!sem)
		return S_objLib_OBJ_ID_ERROR;

	if (semDelete((SEM_ID)sem) == ERROR)
		return wind_errnoget();

	return 0;
}
Exemple #4
0
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;
}
Exemple #5
0
PUBLIC IX_STATUS
ixOsalSemaphoreDestroy (IxOsalSemaphore * sid)
{

    int retVal;
    retVal = semDelete (*(SEM_ID *) sid);
    if (retVal != OK)
    {
        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,
            IX_OSAL_LOG_DEV_STDOUT,
            "ixOsalSemaphoreDestroy(): ERROR - semDelete, return error code = %d \n",
            retVal, 0, 0, 0, 0, 0);
        return IX_FAIL;
    }
    return IX_SUCCESS;
}
Exemple #6
0
void
os_procDispose(
    os_procId procId)
{
    os_procContextData process_procContextData;

    process_procContextData = (os_procContextData)procId;
    os_iterFree(process_procContextData->procCallbackList);
    os_iterFree(process_procContextData->procThreadList);
    os_iterFree(process_procContextData->procGlobalVarList);
    semDelete(process_procContextData->procDataSem);
    os_free((char *)process_procContextData->procName);
    os_free((char *)process_procContextData);
    os_free((char *)process_procContextData->arguments);
    os_free((char *)process_procContextData->executable);
}
/*
 *===========================================================================
 *                    ipcom_spinlock_delete
 *===========================================================================
 * Description:
 * Parameters:
 * Returns:
 *
 */
IP_PUBLIC Ip_err
ipcom_spinlock_delete(Ipcom_spinlock *sl_handle)
{
#ifdef IPCOM_USE_SMP
    Ipcom_vxworks_spinlock_t *sl = (Ipcom_vxworks_spinlock_t*) *sl_handle;
    Ip_err                    ret;

    ret = semDelete(sl->sem);
    *sl_handle = IPCOM_SPINLOCK_INVALID;
    ipcom_free(sl);

    return (ret == OK) ? IPCOM_SUCCESS : IPCOM_ERR_FAILED;
#else
    *sl_handle = IPCOM_SPINLOCK_INVALID;
    return IPCOM_SUCCESS;
#endif
}
Exemple #8
0
static void manageCond(MprCond *cp, int flags)
{
    assert(cp);

    if (flags & MPR_MANAGE_MARK) {
        mprMark(cp->mutex);

    } else if (flags & MPR_MANAGE_FREE) {
#if ME_WIN_LIKE
        CloseHandle(cp->cv);
#elif VXWORKS
        semDelete(cp->cv);
#else
        pthread_cond_destroy(&cp->cv);
#endif
    }
}
Exemple #9
0
static void manageSpinLock(MprSpin *lock, int flags)
{
    if (flags & MPR_MANAGE_FREE) {
        assert(lock);
#if USE_MPR_LOCK || MACOSX
        ;
#elif ME_UNIX_LIKE && ME_COMPILER_HAS_SPINLOCK
        pthread_spin_destroy(&lock->cs);
#elif ME_UNIX_LIKE
        pthread_mutex_destroy(&lock->cs);
#elif ME_WIN_LIKE
        lock->freed = 1;
        DeleteCriticalSection(&lock->cs);
#elif VXWORKS
        semDelete(lock->cs);
#endif
    }
}
Exemple #10
0
int main(int argc, char *const argv[])
{
	TASK_ID tid;
	int ret;

	traceobj_init(&trobj, argv[0], 0);

	tid = taskSpawn("rootTask", 50, 0, 0, rootTask,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, tid != ERROR);

	traceobj_join(&trobj);

	ret = semDelete(sem_id);
	traceobj_assert(&trobj, ret == OK);

	exit(0);
}
Exemple #11
0
/**************************************************************
*
*  semClose - Close a semaphore.
*
* This routine closes a System V semaphore that already exist.
*This is the normal routine used by an application to close the
*a semaphore that it is done with or prior to exiting.
*
*
* RETURNS:
* VOID
*
*       Author Greg Brissey 6/24/94
*/
void semClose(int id)
/* int id - Semaphore ID */
{
    int semval;
    sigset_t signalMask;

    blockSignals(&signalMask);

    /* First Obtain Race Lock */
    if (semop(id, &semCloseOps[0], 3) < 0)
    {
        errLogSysRet(ErrLogOp,debugInfo,
                     "semClose: semid: %d, semop() can't get lock",id);
    }

    /* if last process to be using semaphore then remove it, else
    decrement the process count */

    if ( (semval = semctl(id, PROC_CNT, GETVAL, 0)) < 0)
    {
        errLogSysRet(ErrLogOp,debugInfo,
                     "semClose: semid: %d, semctl() can't GETVAL on PROC_CNT",id);
    }

    if (semval > INITCOUNT)
    {
        errLogRet(ErrLogOp,debugInfo,"semClose: PROC_CNT greater than initial value");
    }
    else if (semval == INITCOUNT)
    {
        DPRINT1(1,"semClose: delete semaphore: %d\n",id);
        semDelete(id);
    }
    else
    {
        DPRINT1(1,"semClose: just decrement process count for semaphore: %d\n",id);
        if (semop(id, &semUnlockOps[0], 1) < 0)
            errLogSysRet(ErrLogOp,debugInfo,
                         "semClose: semid: %d, semop() can't Unlock",id);
    }

    unblockSignals(&signalMask);
}
Exemple #12
0
/*******************************************************************************
* osSemDelete
*
* DESCRIPTION:
*       Delete semaphore.
*
* INPUTS:
*       smid - semaphore Id
*
* OUTPUTS:
*       None
*
* RETURNS:
*       GT_OK   - on success
*       GT_FAIL - on error
*
* COMMENTS:
*       None
*
*******************************************************************************/
GT_STATUS osSemDelete(GT_SEM smid)
{
#ifdef _VXWORKS
	STATUS rc;

	rc = semDelete((SEM_ID) smid);
	if (rc != OK)
		return GT_FAIL;

#elif defined(WIN32)
	if (CloseHandle((HANDLE)smid) == 0)
		return GT_FAIL;

#elif defined(LINUX)
	sem_destroy((semaphore*) smid);
#else
	return GT_OK;
#endif

	return GT_OK;
}
Exemple #13
0
void endObjectUnload
    (
    END_OBJ* pEnd
    )
    {
    if (pEnd->txSem != NULL)
        semDelete (pEnd->txSem);

    lstFree (&pEnd->multiList); 
    if (pEnd->pSnarf != NULL)
        {
        KHEAP_FREE (pEnd->pSnarf);
        }

    pEnd->dummyBinding = NULL;

    pEnd->pSnarf = NULL;
    pEnd->pTyped = NULL;
    pEnd->pPromisc = NULL;
    pEnd->pStop = NULL;
    pEnd->nProtoSlots = 0;
    }
Exemple #14
0
int arretConditionnement() {
	wdDelete(wdReparation);

	taskDelete(tidTraitementPalette);
	taskDelete(tidTraitementCarton);

	msgQDelete(fileConvoyage);

	semDelete(semClapet);
	semDelete(semCompteurPalette);
	semDelete(semEtatEmb);
	semDelete(semCapteurPalette);
	semDelete(semEtatImp);
	semDelete(semCapteurCarton);

	return OK;
}
Exemple #15
0
/*!*****************************************************************************
 *******************************************************************************
\note  motor_servo
\date  Feb 1999
\remarks 

        This program is clocked by the ISR indirectly throught the
	motor_servo_sem semaphore.

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

        none

 ******************************************************************************/
void
motor_servo(void)

{
  int    j,i;
  int    last_tick=0;
  double dt;

  if (motor_servo_calls == 1) {
    
    /* do some initializations if necessary */
    
  }
    
  /**********************************************************************
   * start the loop 
   */
  
  while (servo_enabled) {

    /* wait to take semaphore */
    semTake(motor_servo_sem,WAIT_FOREVER); 

    /* execute the motor servo functions */
    if (!run_motor_servo())
      break;

    if (no_receive_flag)
      dta(d2a_hwm,d2a_bm,d2a_cm,2000);
    else
      dta(d2a_hwm,d2a_bm,d2a_cm,0);
    
  }  /* end servo while loop */
  
  semDelete(motor_servo_sem);
  printf("Motor Servo Error Count = %d\n",motor_servo_errors);

}
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;
}
static tEplKernel EplApiProcessImageDeleteCompletion(
    tEplApiProcessImageCopyJobInt* pCopyJob_p)
{
tEplKernel      Ret = kEplSuccessful;

#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
    if (pCopyJob_p->m_Event.m_pCompletion != NULL)
    {
        EplApiProcessImagePutUserPages(
                pCopyJob_p->m_Event.m_pCompletion->m_apPageIn, FALSE);
        EplApiProcessImagePutUserPages(
                pCopyJob_p->m_Event.m_pCompletion->m_apPageOut, TRUE);
        EPL_FREE(pCopyJob_p->m_Event.m_pCompletion);
        pCopyJob_p->m_Event.m_pCompletion = NULL;
    }

#elif (TARGET_SYSTEM == _LINUX_) && !defined(__KERNEL__)
    sem_destroy(&pCopyJob_p->m_Event.m_semCompletion);

#elif (TARGET_SYSTEM == _WIN32_)
    if ((pCopyJob_p->m_Event.m_hEvent != NULL)
        && (pCopyJob_p->m_Event.m_hEvent != INVALID_HANDLE_VALUE))
    {
        CloseHandle(pCopyJob_p->m_Event.m_hEvent);
        pCopyJob_p->m_Event.m_hEvent = INVALID_HANDLE_VALUE;
    }
#elif (TARGET_SYSTEM == _VXWORKS_)
    semDelete(pCopyJob_p->m_Event.m_semCompletion);
    
#else    
#error "OS currently not supported by EplApiProcessImage!"
#endif

//Exit:
    return Ret;
}
Exemple #18
0
STATUS 
commonStructDelete(const void *pCommonStruct) /* Adresse de base de la structure */
{
    COMMON_STRUCT_ID strId;       /* Id de la structure */
    
    /* Obtenir l'adresse de base de la structure */
    strId = (COMMON_STRUCT_ID)pCommonStruct - 1;
    
    /* Verifier si la structure existe */
    if (strId->initFlag != COMMON_STRUCT_INIT_FLAG) {
	errnoSet (S_commonStructLib_ISNT_COMMON_STRUCT);
	return (ERROR);
    }
    
    /* Indiquer que la structure commune de donnees a ete supprimee */
    strId->initFlag = FALSE;
    
    /* Destroy mutex semaphore */
    semDelete(strId->semId);
    
    /* Liberer le pool de memoire et retourner */
    free((char *) strId);
    return (OK);
}
Exemple #19
0
/**************************************************************
*
*  semClose - Close a Windows semaphore.
*
* This routine closes a Windows semaphore that already exist.
* Here fro compatibilty with Unix API
*
*
* RETURNS:
* VOID
*
*       Author Greg Brissey 5/17/2006
*/
void semClose(SEM_HANDLE id)
/* int id - Semaphore ID */
{
    semDelete(id);
}
Exemple #20
0
void virtualStackTest
    (
    )
    {
    int count;
    VSID myStacks[VSID_MAX];
    
    printf ("Starting Virtual Stack Library Test...\n");

    for (count = 0; count < VSID_MAX; count++)
        {
        printf ("Creating stack %d\n", count);
        myStacks[count] = NULL;
        virtualStackCreate(NULL, &myStacks[count]);
        }

    printf ("Creating complete, checking for failures...\n");
    
    for (count = 0; count < VSID_MAX; count++)
        {
        printf ("Checking stack %d\n", count);
        if (myStacks[count] == NULL)
            {
            printf ("Stack creation on %d failed\n", count);
            goto cleanup;
            }
        }        

    printf ("Stacks 0 through %d created.\n", count);

    printf ("Getting stack information...\n");

    for (count = 0; count < VSID_MAX; count++)
        {
        virtualStackInfo (myStacks[count]);
        }        

    printf ("Checking task variable madness...\n");
    
    virtualStackTestSem = semBCreate (SEM_Q_FIFO, SEM_EMPTY);

    /*
     * Set the number to 0, then let them count them up
     * and down and release the semaphore.
     */
    numTestTasks = 0;
    for (count = 0; count < VSID_MAX; count++)
        {
        taskSpawn (NULL, 255, 0, 20000, (FUNCPTR)virtualStackTestDummy,
                   count, 2, 3, 4, 5, 6, 7 , 8 , 9, 10);
        }        

    /* Wait here for all the sub tasks to end. */

    semTake (virtualStackTestSem, WAIT_FOREVER);
    
    printf ("Done testing...\n");
    
cleanup:
    printf ("Cleaning up...\n");
    for (count = 0; count < VSID_MAX; count++)
        {
        if (myStacks[count] != NULL)
            virtualStackDelete (myStacks[count]);
        }
    semDelete(virtualStackTestSem);

    }
Exemple #21
0
NetworkQueue::~NetworkQueue()
{
	semDelete(m_dataLock);
}
Exemple #22
0
ADC_ID adcCreate(char* baseAddr,int vector,int level)
/* char* baseAddr - base address of ADC */
/* int   vector  - VME Interrupt vector number */
/* int   level   - VME Interrupt level */
{
    char sr;

     /* ------- malloc space for adc Object --------- */
     if ( (adcObj = (ADC_OBJ *) malloc( sizeof(ADC_OBJ) ) ) == NULL )
     {
       LOGMSG(ALL_PORTS,ERROR,"adcCreate: ");
       return(NULL);
     }

     /* zero out structure so we don't free something by mistake */
     memset(adcObj,0,sizeof(ADC_OBJ));

     /* ------ Translate Bus address to CPU Board local address ----- */
     if (sysBusToLocalAdrs(VME_AM_SUP_SHORT_IO,
                         baseAddr,&(adcObj->adcBaseAddr)) == -1)
     {
       LOGMSG(ALL_PORTS,ERROR,"adcCreate: ");
       free(adcObj);
       return(NULL);
     }

     /* ------ Test for Boards Presents ---------- */
     if ( vxMemProbe((char*) (adcObj->adcBaseAddr + ADC_SR), 
		     VX_READ, BYTE, &sr) == ERROR)
     { 
       LOGMSG(ALL_PORTS,OK,"adcCreate: Could not read ADC's Status register\n");
       free(adcObj);
       return(NULL);
     }
     else
     {
        adcObj->adcBrdVersion = (sr >> 4) & 0x0f;
        LOGMSG1(ALL_PORTS,OK,"adcCreate: ADC Board Version %d present.\n",
		adcObj->adcBrdVersion);
     }
     
     adcObj->pSemAdcStateChg = semBCreate(SEM_Q_FIFO,SEM_EMPTY);

     adcObj->pAdcMutex =  semMCreate(SEM_Q_PRIORITY | 
				            SEM_INVERSION_SAFE |
                                            SEM_DELETE_SAFE);

     pSemAdcOvrFlow = semCCreate(SEM_Q_FIFO,SEM_EMPTY);

     if ( (adcObj->pSemAdcStateChg == NULL) || 
          (adcObj->pAdcMutex == NULL) || 
          (pSemAdcOvrFlow == NULL) )
     {
        LOGMSG(ALL_PORTS,ERROR,"adcCreate: ");

	if (adcObj->pSemAdcStateChg != NULL)
	   semDelete(adcObj->pSemAdcStateChg);
	if (adcObj->pAdcMutex != NULL)
	   semDelete(adcObj->pAdcMutex);

	if (pSemAdcOvrFlow != NULL)
	   semDelete(pSemAdcOvrFlow);

        return(NULL);
     }

     if ( (vector < MIN_VME_ITRP_VEC) || (vector > MAX_VME_ITRP_VEC) )
     {
        LOGMSG3(ALL_PORTS,OK,"adcCreate: vector: 0x%x out of bounds (0x%x-0x%x)\n",
		vector,MIN_VME_ITRP_VEC,MAX_VME_ITRP_VEC);
	semDelete(adcObj->pSemAdcStateChg);
	semDelete(adcObj->pAdcMutex);
        free(adcObj);
	return(NULL);
     }
     else
     {
        adcObj->vmeItrVector = vector;
     }

     if ( (level >= MIN_VME_ITRP_LEVEL) && (level <= MAX_VME_ITRP_LEVEL) )
     {
       adcObj->vmeItrLevel = level;
     }
     else
     {
        LOGMSG3(ALL_PORTS,OK,"stmCreate: vme level: %d out of bounds (%d-%d)\n",
	   level,MIN_VME_ITRP_LEVEL,MAX_VME_ITRP_LEVEL);
	semDelete(adcObj->pSemAdcStateChg);
	semDelete(adcObj->pAdcMutex);
        free(adcObj);
        return(NULL);
     }

     adcObj->adcControl = 0;
     adcObj->adcState = OK;

     /*
     intConnect( INUM_TO_IVEC( adcObj->vmeItrVector ),  semGive, pSemAdcOvrFlow);
     */

     /* Spawn the Interrupt Service Tasks */

/*
     taskSpawn("tAdcOvrFlow", ADC_FULL_IST_PRIORTY, ADC_IST_TASK_OPTIONS,
		ADC_IST_STACK_SIZE, adcOvrFlow, adcObj, ARG2,
		ARG3,ARG4,ARG5,ARG6,ARG7,ARG8,ARG9,ARG10);
*/

     return( adcObj );
}
Exemple #23
0
Target::~Target()
{
    semDelete(m_sem);
}
CANJaguar::~CANJaguar()
{
	semDelete(m_transactionSemaphore);
	m_transactionSemaphore = NULL;
}
void sysHandler(int type,void *arg) {
	if(arg == NULL){
		USLOSS_Console("USLOSS_Sysargs is NULL!\n");
		return;
	}
	USLOSS_Sysargs *sysArgs = (USLOSS_Sysargs *) arg;
	int retVal = 0;
	int retVal2 = 0;
	int sectSize = 0;
	int sectors = 0;
	int tracks = 0;
	interruptsOn();
	switch (sysArgs->number) {
	case SYS_TERMREAD:
		retVal = P2_TermRead((int)sysArgs->arg3, (int)sysArgs->arg2, sysArgs->arg1);
                if(retVal >= 0){
                        sysArgs->arg4 = (void *)0;
                        sysArgs->arg2 = (void *)retVal;
                }else{
                        sysArgs->arg4 = (void *)-1;
                }
                break;
	case SYS_TERMWRITE:
		retVal = P2_TermWrite((int)sysArgs->arg3,(int)sysArgs->arg2,(char *)sysArgs->arg1);
                if(retVal >= 0){
                        sysArgs->arg4 = (void *)0;
                        sysArgs->arg2 = (void *)retVal;
                }else{
                        sysArgs->arg4 = (void *)-1;
                }
		break;
	case SYS_SPAWN: //Part 1
		retVal = P2_Spawn(sysArgs->arg5, sysArgs->arg1, sysArgs->arg2,
				(int) sysArgs->arg3, (int) sysArgs->arg4);
		if (retVal == -3 || retVal == -2) {
			sysArgs->arg4 = (void *) -1;
			sysArgs->arg1 = (void *) -1;
		} else {
			sysArgs->arg1 = (void *) retVal;
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_WAIT: //Part 1
		retVal = P2_Wait(&retVal2);
		if(retVal == -1){
			sysArgs->arg1 = (void *)-1;
			sysArgs->arg4 = (void *)-1;
			sysArgs->arg2 = (void *)-1;
		}else{
			sysArgs->arg1 = (void *)retVal;
			sysArgs->arg2 = (void *)retVal2;
			sysArgs->arg4 = (void *)0;
		}
		break;
	case SYS_TERMINATE: //Part 1
		P2_Terminate((int)sysArgs->arg1);
		break;
	case SYS_SLEEP: // Part 1
		retVal = P2_Sleep((int)sysArgs->arg1);
		sysArgs->arg4 = (void *) retVal;
		break;
	case SYS_DISKREAD:
		retVal = P2_DiskRead((int)sysArgs->arg5,(int)sysArgs->arg3,(int) sysArgs->arg4,(int)sysArgs->arg2,(void *)sysArgs->arg1);
                if (retVal == -1) {
                        sysArgs->arg1 = (void *)retVal;
                        sysArgs->arg4 = (void *)-1;
                }
                else if (retVal == 0) {
                        sysArgs->arg1 = (void *)0;
                        sysArgs->arg4 = (void *)0;
                }else {
                        sysArgs->arg1 = (void *)retVal; //output is the disk's status register
                        sysArgs->arg4 = (void *)0;
                }
		break;
	case SYS_DISKWRITE:
		retVal = P2_DiskWrite((int)sysArgs->arg5,(int)sysArgs->arg3,(int) sysArgs->arg4,(int)sysArgs->arg2,(void *)sysArgs->arg1);
		if (retVal == -1) {
			sysArgs->arg1 = (void *)retVal;
			sysArgs->arg4 = (void *)-1;
		}
		else if (retVal == 0) {
			sysArgs->arg1 = (void *)0;
			sysArgs->arg4 = (void *)0;
		}else {
			sysArgs->arg1 = (void *)retVal; //output is the disk's status register
			sysArgs->arg4 = (void *)0;
		}
		break;
	case SYS_DISKSIZE:
		retVal = P2_DiskSize((int)sysArgs->arg1,&sectSize,&sectors,&tracks);
		if (retVal == -1) {
			sysArgs->arg4 = (void *)-1;
		}else {
			sysArgs->arg4 = (void *)0;
			sysArgs->arg1 = (void *)sectSize;
			sysArgs->arg2 = (void *)sectors;
			sysArgs->arg3 = (void *)tracks;
		}
		break;
	case SYS_GETTIMEOFDAY: //Part 1
		sysArgs->arg1 = (void *)USLOSS_Clock();
		break;
	case SYS_CPUTIME: //Part 1
		sysArgs->arg1 = (void *)P1_ReadTime();
		break;
	case SYS_DUMPPROCESSES: //Part 1
		P1_DumpProcesses();
		break;
	case SYS_GETPID: //Part 1
		sysArgs->arg1 = (void *) P1_GetPID();
		break;
	case SYS_SEMCREATE: //Part 1
		retVal = (int)sysArgs->arg1;
		if(retVal < 0){
			sysArgs->arg4 = (void *)-1;
		}else{
			sysArgs->arg4 = (void *)0;
			sysArgs->arg1 = (void *) semAdd(P1_SemCreate(retVal));
		}
		break;
	case SYS_SEMP: // Part 1
		if(validSem((int)sysArgs->arg1) == 0){
			sysArgs->arg4 = (void *) -1;
			return;
		}
		retVal = P1_P(userSemList[(int)sysArgs->arg1].sem);
		if(retVal < 0){
			sysArgs->arg4 = (void *) -1;
		}
		else{
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_SEMV: // Part 1
                if(validSem((int)sysArgs->arg1) == 0){
                        sysArgs->arg4 = (void *) -1;
                        return;
                }
		retVal = P1_V(userSemList[(int)sysArgs->arg1].sem);
		if(retVal < 0){
			sysArgs->arg4 = (void *) -1;
		}
		else{
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_SEMFREE: // Part 1
                if(validSem((int)sysArgs->arg1) == 0){
                        sysArgs->arg4 = (void *) -1;
                        return;
                }
		
		retVal = semDelete((int)sysArgs->arg1);
		if(retVal < 0){
			sysArgs->arg4 = (void *) -1;
		}
		else{
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_MBOXCREATE: //Part 1
		retVal = P2_MboxCreate((int)sysArgs->arg1,(int)sysArgs->arg2);
		if(retVal == -2){
			sysArgs->arg1 = (void *) -1;
			sysArgs->arg4 = (void *) -1;
		}else{
			sysArgs->arg1 = (void *) retVal;
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_MBOXRELEASE: // Part 1
		retVal = P2_MboxRelease((int)sysArgs->arg1);
		if(retVal < 0){
			sysArgs->arg4 = (void *) -1;
		}else{
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_MBOXSEND: // Part 1
		retVal = P2_MboxSend((int)sysArgs->arg1,sysArgs->arg2,(int *)&sysArgs->arg3);
		if(retVal < 0){
			sysArgs->arg4 = (void *) -1;
		}else{
			sysArgs->arg4 = (void *) 0;
		}
		break;
	case SYS_MBOXRECEIVE: // Part 1
                retVal = P2_MboxReceive((int)sysArgs->arg1,sysArgs->arg2,(int *)&sysArgs->arg3);
                if(retVal < 0){
                        sysArgs->arg4 = (void *) -1;
                }else{
                        sysArgs->arg4 = (void *) 0;
			sysArgs->arg2 = (void *) retVal;
                }
		break;
	case SYS_MBOXCONDSEND: // Part 1
                retVal = P2_MboxCondSend((int)sysArgs->arg1,sysArgs->arg2,(int *)&sysArgs->arg3);
                if(retVal == -1){
                        sysArgs->arg4 = (void *) -1;
                }else if(retVal == -2){
			sysArgs->arg4 = (void *) 1;
		}
		else{
                        sysArgs->arg4 = (void *) 0;
                }
		break;
	case SYS_MBOXCONDRECEIVE: // Part 1
                retVal = P2_MboxCondReceive((int)sysArgs->arg1,sysArgs->arg2,(int *)&sysArgs->arg3);
                if(retVal == -1){
                        sysArgs->arg4 = (void *) -1;
                }else if(retVal == -2){
                        sysArgs->arg4 = (void *) 1;
                }
                else{
                        sysArgs->arg4 = (void *) 0;
			sysArgs->arg2 = (void *) retVal;
                }
		break;
	default:
		P1_Quit(1);
	}
}
Exemple #26
0
STATUS 
c792Init (UINT32 addr, UINT32 addr_inc, int nadc, UINT16 crateID)
{
  int ii, res, rdata, errFlag = 0;
  int boardID = 0;
  unsigned long laddr, lladdr;
  volatile struct c792_ROM_struct *rp;

  
  /* Check for valid address */
  if(addr==0) {
    printf("c792Init: ERROR: Must specify a Bus (VME-based A32/A24) address for QDC 0\n");
    return(ERROR);
  }else if(addr < 0x00ffffff) { /* A24 Addressing */
    if((addr_inc==0)||(nadc==0))
      nadc = 1; /* assume only one QDC to initialize */

    /* get the QDCs address */
#ifdef VXWORKS
    res = sysBusToLocalAdrs(0x39,(char *)addr,(char **)&laddr);
    if (res != 0) {
      printf("c792Init: ERROR in sysBusToLocalAdrs(0x39,0x%x,&laddr) \n",addr);
      return(ERROR);
    }
#else
    res = vmeBusToLocalAdrs(0x39,(char *)addr,(char **)&laddr);
    if (res != 0) {
      printf("c792Init: ERROR in vmeBusToLocalAdrs(0x39,0x%x,&laddr) \n",addr);
      return(ERROR);
    }
#endif
    c792MemOffset = laddr - addr;
  }else{ /* A32 Addressing */


    if((addr_inc==0)||(nadc==0))
      nadc = 1; /* assume only one QDC to initialize */

    /* get the QDC address */
#ifdef VXWORKS
    res = sysBusToLocalAdrs(0x09,(char *)addr,(char **)&laddr);
    if (res != 0) {
      printf("c792Init: ERROR in sysBusToLocalAdrs(0x09,0x%x,&laddr) \n",addr);
      return(ERROR);
    }
#else
    res = vmeBusToLocalAdrs(0x09,(char *)addr,(char **)&laddr);
    if (res != 0) {
      printf("c792Init: ERROR in vmeBusToLocalAdrs(0x09,0x%x,&laddr) \n",addr);
      return(ERROR);
    }
#endif
    c792MemOffset = laddr - addr;
  }

  lladdr = laddr;

  Nc792 = 0;
  for (ii=0;ii<nadc;ii++)
  {
    c792p[ii] = (struct c792_struct *)(laddr + ii*addr_inc);
    c792pl[ii]  = (struct c792_struct *)(lladdr + ii*addr_inc);
    /* Check if Board exists at that address */
#ifdef VXWORKS
    res = vxMemProbe((char *) &(c792p[ii]->rev),0,2,(char *)&rdata);
#else
    res = vmeMemProbe((char *) &(c792p[ii]->rev),2,(char *)&rdata);
#endif
    if(res < 0)
    {
      printf("c792Init: ERROR: No addressable board at addr=0x%x\n",(UINT32) c792p[ii]);
      c792p[ii] = NULL;
      /*sergey: errFlag = 1;*/
      break;
    }
    else
    {
      /* Check if this is a Model 792 */
      rp = (struct c792_ROM_struct *)((UINT32)c792p[ii] + C792_ROM_OFFSET);
      boardID = ((c792Read(&rp->ID_3)&(0xff))<<16) + 
	     ((c792Read(&rp->ID_2)&(0xff))<<8) + (c792Read(&rp->ID_1)&(0xff)); 

      /* set 1 for tdc, 2 for adc */
      if(boardID == C775_BOARD_ID)      use792[Nc792] = 1;
      else if(boardID == C792_BOARD_ID) use792[Nc792] = 2;
      else
      {
	    printf(" ERROR: Board ID does not match: %d \n",boardID);
	    return(ERROR);
      }
    }
    Nc792++;
#ifdef VXWORKS
    printf("Initialized QDC ID %d at address 0x%08x \n",ii,(UINT32) c792p[ii]);
#else
    printf("Initialized QDC ID %d at VME (USER) address 0x%08x (0x%08x) \n",ii,
	   (UINT32)(c792p[ii]) - c792MemOffset, (UINT32) c792p[ii]);
#endif
  }

#ifdef VXWORKS
  /* Initialize/Create Semephore */
  if(c792Sem != 0) {
    semFlush(c792Sem);
    semDelete(c792Sem);
  }
  c792Sem = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY);
  if(c792Sem <= 0) {
    printf("c792Init: ERROR: Unable to create Binary Semephore\n");
    return(ERROR);
  }
#endif
  
  /* Disable/Clear all QDCs */
  for(ii=0;ii<Nc792;ii++) {
    C792_EXEC_SOFT_RESET(ii);
    C792_EXEC_DATA_RESET(ii);
    c792Write(&c792p[ii]->intLevel,0);        /* Disable Interrupts */
    c792Write(&c792p[ii]->evTrigger,0);       /* Zero interrupt trigger count */
    c792Write(&c792p[ii]->crateSelect,crateID);  /* Set Crate ID Register */
    c792Write(&c792p[ii]->bitClear2,C792_INCR_ALL_TRIG); /* Increment event count only on
							    accepted gates */

    c792EventCount[ii] =  0;          /* Initialize the Event Count */
    c792EvtReadCnt[ii] = -1;          /* Initialize the Read Count */
  }
  /* Initialize Interrupt variables */
  c792IntID = -1;
  c792IntRunning = FALSE;
  c792IntLevel = 0;
  c792IntVec = 0;
  c792IntRoutine = NULL;
  c792IntArg = 0;
  c792IntEvCount = 0;
    
#ifdef VXWORKSPPC
  bzero((char *)&c792Fpr,sizeof(c792Fpr));
#endif

  if(Nc792 > 0) printf("c792Init: %d QDC(s) successfully initialized\n",Nc792);
  if(errFlag > 0)
  {
    printf("c792Init: ERROR: Unable to initialize all QDC Modules, errFlag=%d\n",errFlag);
    return(ERROR);
  }
  else
  {
    return(Nc792);
  }

}
DriverStationLCD::~DriverStationLCD()
{
	semDelete(m_textBufferSemaphore);
	delete [] m_textBuffer;
	m_instance = NULL;
}
Exemple #28
0
CSVReader::~CSVReader()
{
	semTake(m_lock,WAIT_FOREVER);
	semDelete(m_lock);
}
Exemple #29
0
/*
    Gather the child's exit status.
    WARNING: this may be called with a false-positive, ie. SIGCHLD will get invoked for all process deaths and not just
    when this cmd has completed.
 */
static void reapCmd(MprCmd *cmd, bool finalizing)
{
    if (cmd->pid == 0) {
        return;
    }
#if ME_UNIX_LIKE
{
    int     status, rc;

    status = 0;
    if ((rc = waitpid(cmd->pid, &status, WNOHANG | __WALL)) < 0) {
        mprLog("error mpr cmd", 0, "Waitpid failed for pid %d, errno %d", cmd->pid, errno);

    } else if (rc == cmd->pid) {
        if (!WIFSTOPPED(status)) {
            if (WIFEXITED(status)) {
                cmd->status = WEXITSTATUS(status);
                mprDebug("mpr cmd", 6, "Process exited pid %d, status %d", cmd->pid, cmd->status);
            } else if (WIFSIGNALED(status)) {
                cmd->status = WTERMSIG(status);
            }
            cmd->pid = 0;
            if (cmd->signal) {
                mprRemoveSignalHandler(cmd->signal);
                cmd->signal = 0;
            }
        }
    } else {
        mprDebug("mpr cmd", 6, "Still running pid %d, thread %s", cmd->pid, mprGetCurrentThreadName());
    }
}
#endif
#if VXWORKS
    /*
        The command exit status (cmd->status) is set in cmdTaskEntry
     */
    if (!cmd->stopped) {
        if (semTake(cmd->exitCond, MPR_TIMEOUT_STOP_TASK) != OK) {
            mprLog("error mpr cmd", 0, "Child %s did not exit, errno %d", cmd->program, errno);
            return;
        }
    }
    semDelete(cmd->exitCond);
    cmd->exitCond = 0;
    cmd->pid = 0;
#endif
#if ME_WIN_LIKE
{
    int     status, rc;

    status = 0;

    if (GetExitCodeProcess(cmd->process, (ulong*) &status) == 0) {
        mprLog("error mpr cmd", 0, "GetExitProcess error");
        return;
    }
    if (status != STILL_ACTIVE) {
        cmd->status = status;
        rc = CloseHandle(cmd->process);
        assert(rc != 0);
        rc = CloseHandle(cmd->thread);
        assert(rc != 0);
        cmd->process = 0;
        cmd->thread = 0;
        cmd->pid = 0;
    }
}
#endif
    if (cmd->pid == 0) {
        if (cmd->eofCount >= cmd->requiredEof) {
            completeCommand(cmd);
        }
        mprDebug("mpr cmd", 6, "Process reaped: status %d, pid %d, eof %d / %d", cmd->status, cmd->pid,
                cmd->eofCount, cmd->requiredEof);
        if (cmd->callback) {
            (cmd->callback)(cmd, -1, cmd->callbackData);
        }
    }
}
MAILBOX_EXTERN void mailbox_del_completion(void **wait)
{
    (void)semDelete(*wait);
}