mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-06 12:29:02 +08:00
CONDVAR(9): Use lock class
This commit is contained in:
parent
dce8247e38
commit
e01f6e0ea5
@ -7,10 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
|
* Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved.
|
||||||
*
|
*
|
||||||
* Dornierstr. 4
|
* Dornierstr. 4
|
||||||
* Obere Lagerstr. 30
|
|
||||||
* 82178 Puchheim
|
* 82178 Puchheim
|
||||||
* Germany
|
* Germany
|
||||||
* <rtems@embedded-brains.de>
|
* <rtems@embedded-brains.de>
|
||||||
@ -78,12 +77,14 @@ cv_destroy(struct cv *cv)
|
|||||||
|
|
||||||
static int _cv_wait_support(struct cv *cv, struct lock_object *lock, int timo, bool relock)
|
static int _cv_wait_support(struct cv *cv, struct lock_object *lock, int timo, bool relock)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
|
||||||
int eno = 0;
|
int eno = 0;
|
||||||
Objects_Locations location = OBJECTS_ERROR;
|
Objects_Locations location = OBJECTS_ERROR;
|
||||||
POSIX_Condition_variables_Control *pcv = _POSIX_Condition_variables_Get(&cv->cv_id, &location);
|
POSIX_Condition_variables_Control *pcv = _POSIX_Condition_variables_Get(&cv->cv_id, &location);
|
||||||
|
|
||||||
if (location == OBJECTS_LOCAL) {
|
if (location == OBJECTS_LOCAL) {
|
||||||
|
struct lock_class *class = LOCK_CLASS(lock);
|
||||||
|
int lock_state;
|
||||||
|
|
||||||
if (pcv->Mutex != POSIX_CONDITION_VARIABLES_NO_MUTEX && pcv->Mutex != lock->lo_id) {
|
if (pcv->Mutex != POSIX_CONDITION_VARIABLES_NO_MUTEX && pcv->Mutex != lock->lo_id) {
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
|
|
||||||
@ -92,14 +93,7 @@ static int _cv_wait_support(struct cv *cv, struct lock_object *lock, int timo, b
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = rtems_semaphore_release(lock->lo_id);
|
lock_state = (*class->lc_unlock)(lock);
|
||||||
if (sc != RTEMS_SUCCESSFUL) {
|
|
||||||
_Thread_Enable_dispatch();
|
|
||||||
|
|
||||||
BSD_ASSERT(false);
|
|
||||||
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcv->Mutex = lock->lo_id;
|
pcv->Mutex = lock->lo_id;
|
||||||
|
|
||||||
@ -129,12 +123,7 @@ static int _cv_wait_support(struct cv *cv, struct lock_object *lock, int timo, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (relock) {
|
if (relock) {
|
||||||
sc = rtems_semaphore_obtain(lock->lo_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
(*class->lc_lock)(lock, lock_state);
|
||||||
if (sc != RTEMS_SUCCESSFUL) {
|
|
||||||
BSD_ASSERT(false);
|
|
||||||
|
|
||||||
eno = EINVAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return eno;
|
return eno;
|
||||||
@ -187,7 +176,7 @@ int
|
|||||||
_cv_wait_sig(struct cv *cvp, struct lock_object *lock)
|
_cv_wait_sig(struct cv *cvp, struct lock_object *lock)
|
||||||
{
|
{
|
||||||
/* XXX */
|
/* XXX */
|
||||||
_cv_wait_support(cvp, lock, 0, true);
|
return _cv_wait_support(cvp, lock, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user