Exemplo n.º 1
0
/** Delete a semaphore
 * @param mutex the mutex to delete */
void sys_mutex_free(sys_mutex_t *mutex)
{
	if (sys_mutex_valid(mutex)) {
		SYS_STATS_DEC(mutex.used);
		vSemaphoreDelete(*mutex);
	}
}
Exemplo n.º 2
0
/** Create a new mutex
 * @param mutex pointer to the mutex to create
 * @return a new mutex */
err_t sys_mutex_new(sys_mutex_t *mutex)
{
	err_t ercd = ERR_MEM;

	*mutex = xSemaphoreCreateMutex();

	if (sys_mutex_valid(mutex)) {
		ercd = ERR_OK;
		SYS_STATS_INC_USED( mutex );
	} else {
		SYS_STATS_INC( mutex.err );
	}

	return ercd;
}
Exemplo n.º 3
0
/*********************************************************************************************************
** 函数名称: __rtSafeRun
** 功能描述: 安全的运行一个回调函数, 不能破坏协议栈
** 输 入  : pfuncHook     执行函数
**           pvArg0...5    参数
** 输 出  : 执行结果
** 全局变量: 
** 调用模块: 
*********************************************************************************************************/
static INT __rtSafeRun (FUNCPTR  pfuncHook,
                        PVOID    pvArg0,
                        PVOID    pvArg1,
                        PVOID    pvArg2,
                        PVOID    pvArg3,
                        PVOID    pvArg4,
                        PVOID    pvArg5)
{
#if LWIP_TCPIP_CORE_LOCKING < 1
#error sylixos need LWIP_TCPIP_CORE_LOCKING > 0
#endif                                                                  /*  LWIP_TCPIP_CORE_LOCKING     */

    INT     iError;

    if (sys_mutex_valid(&lock_tcpip_core)) {
        LOCK_TCPIP_CORE();
        iError = pfuncHook(pvArg0, pvArg1, pvArg2, pvArg3, pvArg4, pvArg5);
        UNLOCK_TCPIP_CORE();
    } else {
        iError = pfuncHook(pvArg0, pvArg1, pvArg2, pvArg3, pvArg4, pvArg5);
    }
    
    return  (iError);
}
Exemplo n.º 4
0
/** Unlock a mutex
 * @param mutex the mutex to unlock */
void sys_mutex_unlock(sys_mutex_t *mutex)
{
	if (sys_mutex_valid(mutex)) {
		xSemaphoreGive(*mutex);
	}
}
Exemplo n.º 5
0
/** Lock a mutex
 * @param mutex the mutex to lock */
void sys_mutex_lock(sys_mutex_t *mutex)
{
	if (sys_mutex_valid(mutex)) {
		while (xSemaphoreTake(*mutex, portMAX_DELAY) != pdTRUE);
	}
}