Ejemplo n.º 1
0
pte_osResult pte_osSemaphorePend(pte_osSemaphoreHandle handle, unsigned int *pTimeoutMsecs)
{
    u64 timeoutUsecs;
    s32 result;
    pte_osResult osResult;

    if (pTimeoutMsecs == NULL)
        timeoutUsecs = 0;
    else
        timeoutUsecs = *pTimeoutMsecs * 1000;

    result = sysSemWait(handle, timeoutUsecs);

    if (result == 0)
    {
        osResult = PTE_OS_OK;
    }
    else if (result == 0x8001000b)
    {
        osResult = PTE_OS_TIMEOUT;
    }
    else
    {
        osResult = PTE_OS_GENERAL_FAILURE;
    }

    return osResult;
}
Ejemplo n.º 2
0
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
	int32_t val;
	int retval;

	if (!sem) {
		SDL_SetError("Passed a NULL semaphore");
		return -1;
	}

	int finished = 0;
	while( finished == 0)
	{
		// Do not wait
		if( timeout == 0) {
			val = sysSemTryWait( sem->id);
		// Wait Forever
		} else if (timeout == SDL_MUTEX_MAXWAIT) {
			val = sysSemWait(sem->id, 0);
		// Wait until timeout
		} else {
			timeout *= 1000;     /* PS 3uses a timeout in microseconds */
			val = sysSemWait(sem->id, timeout);
		}
		switch (val) {
			case EINTR:
				break;
			case 0:
				retval = 0;
				finished = 1;
				break;
			case ETIMEDOUT:
				retval = SDL_MUTEX_TIMEDOUT;
				finished = 1;
				break;
			default:
				SDL_SetError("sysSem[Try]Wait() failed");
				retval = -1;
				finished = 1;
				break;
		}
	}
	return retval;
}
Ejemplo n.º 3
0
inline void
videoDrawFrame ( videoData *vdata )
{
  /* wait vsync */
  rescWaitFlip () ;

  /* update text */
  sysSemWait ( vdata->fon_buffer->sem, NO_TIMEOUT ) ;
  fontBufferDraw ( vdata->context, vdata->fon_buffer, &vdata->rsx_buffers[vdata->currentBuffer] ) ;
  sysSemPost ( vdata->fon_buffer->sem, 1 ) ;

  /* flip buffer to screen */
  rescFlip ( vdata ) ;
}