libc/semaphore:Set the flag need AND SEM_PRIO_MASK

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-06-19 15:49:45 +08:00 committed by Xiang Xiao
parent 42abf22eef
commit 1711a298a8
2 changed files with 9 additions and 4 deletions

View File

@ -89,7 +89,11 @@ int nxmutex_init(FAR mutex_t *mutex)
}
mutex->holder = NXMUTEX_NO_HOLDER;
#ifdef CONFIG_PRIORITY_INHERITANCE
_SEM_SETPROTOCOL(&mutex->sem, SEM_TYPE_MUTEX | SEM_PRIO_INHERIT);
#else
_SEM_SETPROTOCOL(&mutex->sem, SEM_TYPE_MUTEX);
#endif
return ret;
}

View File

@ -77,20 +77,21 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
{
DEBUGASSERT(sem != NULL);
switch (protocol)
switch (protocol & SEM_PRIO_MASK)
{
case SEM_PRIO_NONE:
return OK;
break;
case SEM_PRIO_INHERIT:
case SEM_PRIO_PROTECT:
return -ENOTSUP;
default:
break;
return -EINVAL;
}
return -EINVAL;
sem->flags = protocol;
return OK;
}
/****************************************************************************