Beispiel #1
0
void LmuxRelease(lmutex_t *mux)
{
    unsigned my_id;

    my_id = ThrGetThreadInfo()->id;
    if (mux->locks > 1)
    {
	if (mux->owner != my_id)
	{
	    _wdprintf(L"LmuxRelease(%p/%u): incorrect owner %u, should be %u\n",
		mux, mux->mutex, mux->owner, my_id);
	    __asm__("int3");
	}

	mux->eip = 0;
	mux->owner = 0;
	if (!SemUp(mux->mutex))
	    __asm__("int3");
    }
    else
    {
	mux->eip = 0;
	mux->locks = 0;
	mux->owner = 0;
    }
}
Beispiel #2
0
/* after popping, producer can produce +1 items, and consumer can consume -1 items
in comparison to before */ 
ADTErr SafeQueuePop(SafeQueue* _queue, void** _dataPtr)
{
	ADTErr error;
		
	if (NULL == _queue)
	{
		return  ERR_NOT_INITIALIZED;
	}	
	
	error = SemDown(&_queue->m_consSem);
	if (error != ERR_OK)
	{
		return error;
	}

	pthread_mutex_lock(&_queue->m_mutex); 
	error = QueueRemove(_queue->m_queue, _dataPtr);
	if (error != ERR_OK)
	{
		return error;
	}
	pthread_mutex_unlock(&_queue->m_mutex);

	error = SemUp(&_queue->m_prodSem);
	if (error != ERR_OK)
	{
		return error;
	}

	return ERR_OK;
}
Beispiel #3
0
static void DevCallLoader(load_request_t *load)
{
    event_t *evt_done;

    evt_done = EvtCreate(false);
    load->evt_done = evt_done;

    SemDown(mux_load);
    LIST_ADD(load, load);
    SemUp(mux_load);

    wprintf(L"DevCallLoader: submitting request\n");
    SemUp(sem_load);
    ThrWaitHandle(current(), &evt_done->hdr);
    KeYield();

    HndClose(&evt_done->hdr);
}
Beispiel #4
0
static void DevLoaderThread(void)
{
    load_request_t *load;
    event_t *evt_done;

    while (true)
    {
        wprintf(L"DevLoaderThread: waiting for request\n");
        SemDown(sem_load);
        wprintf(L"DevLoaderThread: got request\n");

        SemDown(mux_load);
        load = load_first;
        LIST_REMOVE(load, load);
        SemUp(mux_load);

        evt_done = (event_t*) HndCopy(&load->evt_done->hdr);

        switch (load->action)
        {
        case LOAD_ACTION_LOAD_DRIVER:
            load->status = DevDoLoadDriver(load->u.load_driver.name, 
                &load->u.load_driver.driver);
            break;

        case LOAD_ACTION_ADD_DEVICE:
            load->u.add_device.driver->add_device(load->u.add_device.driver,
                load->u.add_device.name,
                load->u.add_device.config);
            load->status = 0;
            break;

        default:
            wprintf(L"DevLoaderThread: invalid action: %u\n", load->action);
            assert(load->action == LOAD_ACTION_LOAD_DRIVER ||
                load->action == LOAD_ACTION_ADD_DEVICE);
            break;
        }

        EvtSignal(evt_done, true);
        HndClose(&evt_done->hdr);
    }
}
Beispiel #5
0
void LmuxRelease(lmutex_t *mux)
{
    SemUp(mux->mutex);
}