Пример #1
0
STATUS UrgencyLibInit (void)
    {
    static BOOL done = FALSE;

    if (done)
	return (UrgencyTaskId == ERROR ? ERROR : OK);

    if (semBInit (&UrgencyJobInfo.sem, SEM_Q_FIFO, SEM_EMPTY) == ERROR)
	return (ERROR);

#ifdef BSP_VIRTUAL_STACK_DELETE
    semBInit (UrgencyTaskDelSemId, SEM_Q_PRIORITY, SEM_FULL);

    if (UrgencyTaskDelSemId == NULL)
	return (ERROR);
#endif

    done = TRUE;

    if (UrgencyJobAlloc (UrgencyJobNum) != OK)
      {
      panic ("UrgencyLibInit: couldn't allocate job nodes\n");
      return ERROR;
      }

    UrgencyTaskId = taskSpawn ("tUrgencyTask", UrgencyTaskPriority,
		           UrgencyTaskOptions, UrgencyTaskStackSize,
			   (FUNCPTR)UrgencyTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

    
    return (UrgencyTaskId == ERROR ? ERROR : OK);
    }
Пример #2
0
SEM_ID semBCreate(
    int         options,
    SEM_B_STATE state
    )
{
    SEM_ID semId;

    /* Check if lib is installed */
    if (semBLibInstalled != TRUE)
    {
        errnoSet(S_semLib_NOT_INSTALLED);
        semId = NULL;
    }
    else
    {
        /* Allocate memory */
        semId = (SEM_ID) objAlloc(semClassId);
        if (semId != NULL)
        {
            /* Initialze structure */
            if (semBInit(semId, options, state) != OK)
            {
                objFree(semClassId, semId);
                semId = NULL;
            }
        }
    }

    return semId;
}
Пример #3
0
SEM_ID semBCreate
(
    int         options,                /* semaphore options */
    SEM_B_STATE initialState            /* initial semaphore state */
)
{
    SEM_ID semId;

    if ((!semBLibInstalled) && (semBLibInit () != OK))	/* initialize package */
    {
		return (NULL);
    }

    if ((semId = (SEM_ID) objAlloc (semClassId)) == NULL)
    {
		return (NULL);
    }

    /* initialize allocated semaphore */

    if (semBInit (semId, options, initialState) != OK)
	{
		objFree (semClassId, (char *) semId);
		return (NULL);
	}

    return (semId);
}
Пример #4
0
LOCAL void memPartSemInit
    (
    PART_ID partId		/* partition to initialize semaphore for */
    )
    {
    semBInit (&partId->sem, SEM_Q_PRIORITY, SEM_FULL);
    }
Пример #5
0
STATUS netLibInit(void)
{
  if (netLibInstalled == TRUE) {

    /* Return error if task not initialized */
    if (netTaskId == (int) NULL)
      return ERROR;

    return OK;
  }

  /* Mark as initialized */
  netLibInstalled = TRUE;

  /* Create network ring buffer */
  netWorkRing = rngCreate(NET_LIB_RING_SIZE);
  if (netWorkRing == NULL)
    return ERROR;

  /* Initialize network semaphore */
  semBInit(netTaskSemId, SEM_Q_PRIORITY, SEM_EMPTY);

  /* Start network task */
  netTaskId = taskSpawn("tNetTask", netTaskPriority,
                        netTaskOptions, netTaskStackSize,
                        (FUNCPTR) netTask,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  if (netTaskId == (int) NULL)
    return ERROR;

  return OK;
}
Пример #6
0
STATUS semInit
    (
    SEMAPHORE *pSemaphore       /* 4.x semaphore to initialize */
    )
    {
    if ((!semOLibInstalled) && (semOLibInit () != OK))	/* initialize package */
	return (ERROR);

    if (semBInit (pSemaphore, SEM_Q_PRIORITY, SEM_EMPTY) != OK)
	return (ERROR);

    pSemaphore->semType = SEM_TYPE_OLD;

    return (OK);
    }
Пример #7
0
STATUS semInit(
    SEM_ID semId,
    int    type,
    int    options
    )
{
    STATUS status;

    if (semLibInstalled != TRUE)
    {
        errnoSet(S_semLib_NOT_INSTALLED);
        status = ERROR;
    }
    else
    {
        /* Create semaphore of correct type */
        switch(type & SEM_TYPE_MASK)
        {
            case SEM_TYPE_BINARY:
                status = semBInit(semId, options, SEM_FULL);
                break;

            case SEM_TYPE_MUTEX:
                status = semMInit(semId, options);
                break;

            case SEM_TYPE_COUNTING:
                status = semCInit(semId, options, 1);
                break;

            default:
                status = ERROR;
                errnoSet(S_semLib_INVALID_OPTION);
                break;
        }
    }

    return status;
}
Пример #8
0
Файл: bio.c Проект: phoboz/vmx
LOCAL void bio_new (
    struct buf *bp
    ) {
    struct bio *pBio;

    /* Allocate struct */
    pBio = (struct bio *) malloc (sizeof (struct bio));
    if (pBio == NULL) {
        panic ("bio: out of memory");
    }

    /* Clear struct */
    memset (pBio, 0, sizeof(struct bio));

    /* Fill the vital parts of the bio struct */
    pBio->bio_dev    = bp->b_dev;
    pBio->bio_data   = bp->b_data;
    pBio->bio_flags  = (bp->b_flags & B_READ) ? BIO_READ : BIO_WRITE;

    semBInit (&pBio->bio_sem, SEM_Q_PRIORITY, SEM_EMPTY);

    /* Fill in pointer to struct in buffer */
    bp->b_bio = pBio;
}
Пример #9
0
static void memPartSemInit(PART_ID partId)
{
	semBInit(&semMemSysPartition, SEM_Q_FIFO, SEM_FULL);

	partId->semPartId = &semMemSysPartition;
}