diff options
Diffstat (limited to 'nest/locks.c')
-rw-r--r-- | nest/locks.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/nest/locks.c b/nest/locks.c index e378fb1f..fb245cdc 100644 --- a/nest/locks.c +++ b/nest/locks.c @@ -38,6 +38,11 @@ static list olock_list; +DEFINE_DOMAIN(attrs); +static DOMAIN(attrs) olock_domain; +#define OBJ_LOCK LOCK_DOMAIN(attrs, olock_domain) +#define OBJ_UNLOCK UNLOCK_DOMAIN(attrs, olock_domain) + static inline int olock_same(struct object_lock *x, struct object_lock *y) { @@ -57,6 +62,7 @@ olock_free(resource *r) struct object_lock *l = SKIP_BACK(struct object_lock, r, r); node *n; + OBJ_LOCK; DBG("olock: Freeing %p\n", l); switch (l->state) { @@ -87,7 +93,7 @@ olock_free(resource *r) /* Inform */ q->state = OLOCK_STATE_LOCKED; - ev_schedule(&q->event); + ev_send(q->target, &q->event); } break; case OLOCK_STATE_WAITING: @@ -97,6 +103,7 @@ olock_free(resource *r) default: ASSERT(0); } + OBJ_UNLOCK; } static void @@ -154,6 +161,8 @@ olock_acquire(struct object_lock *l) node *n; struct object_lock *q; + OBJ_LOCK; + WALK_LIST(n, olock_list) { q = SKIP_BACK(struct object_lock, n, n); @@ -163,6 +172,7 @@ olock_acquire(struct object_lock *l) add_tail(&q->waiters, &l->n); DBG("olock: %p waits\n", l); + OBJ_UNLOCK; return; } } @@ -171,7 +181,9 @@ olock_acquire(struct object_lock *l) add_head(&olock_list, &l->n); l->state = OLOCK_STATE_LOCKED; - ev_schedule(&l->event); + ev_send(l->target, &l->event); + + OBJ_UNLOCK; } /** @@ -185,4 +197,5 @@ olock_init(void) { DBG("olock: init\n"); init_list(&olock_list); + olock_domain = DOMAIN_NEW(attrs, "Object lock"); } |