Exemplo n.º 1
0
static int _SemMux_Give(int type, void * priv)
{
	struct MUX_t * mux;
	struct SEM_t * sem;

	bool r = pdTRUE;

	uint8_t CurrentTaskId = rtos_get_current_task();

	switch (type) {

	case BINARY_MUTEX:

		mux = (struct MUX_t *) priv;

		rtos_mutex_unlock(mux->muxid);

		break;

	case RECURSIVE_MUTEX:
		mux = (struct MUX_t *) priv;

		if (rtos_get_mutex_holder(mux->muxid) == CurrentTaskId) {
			assert(mux->TskHoldCnt > 0);
			mux->TskHoldCnt--;
			if (mux->TskHoldCnt == 0) {
				rtos_mutex_unlock(mux->muxid);
			}
		} else {
			r = pdFALSE;
		}

		break;

	case SEMAPHORE:
	case COUNTING_SEMAPHORE:
		sem = (struct SEM_t *)priv;

		r = rtos_sem_post_max(sem->semid, sem->max_count);

		break;

	default:
		r = pdFALSE;
		break;
	}

	return r;
}
Exemplo n.º 2
0
bool thread_a_write_foo_data(/* THREAD_ID tid,  */ const test__dt_rec * elem ) {

   bool result = true;

    /////////////////////////////////////////////////////////////////////////
    // here is where we would branch based on thread instance id.
    // For now we support only one thread instance per thread implementation.
    // In this case we would split on destination thread id: thread_a_instance_0
    /////////////////////////////////////////////////////////////////////////


   rtos_mutex_lock(MUTEX_ID_MUTEX_DATAP_INSTANCE_1);
   memcpy(&var_datap_Instance_1, elem, sizeof(test__dt_rec  ));
   rtos_mutex_unlock(MUTEX_ID_MUTEX_DATAP_INSTANCE_1);
   return result;
}
Exemplo n.º 3
0
bool thread_b_is_empty_datap(/* THREAD_ID tid,  */ ) {

   bool result = false;

    /////////////////////////////////////////////////////////////////////////
    // here is where we would branch based on thread instance id.
    // For now we support only one thread instance per thread implementation.
    // In this case we would split on destination thread id: thread_b_instance_1
    /////////////////////////////////////////////////////////////////////////


   rtos_mutex_lock(MUTEX_ID_MUTEX_DATAP_INSTANCE_1);
   result = false; 
   rtos_mutex_unlock(MUTEX_ID_MUTEX_DATAP_INSTANCE_1);
   return result;
}
Exemplo n.º 4
0
	    virtual void unlock()
	    {
	        rtos_mutex_unlock( &m );
	    }