From f619d5e9e2461c1ef3fb53cbbff325cfb04fb181 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 13 Nov 2011 16:38:34 -0800 Subject: rt: Add locking invariants to rust_port --- src/rt/rust_port.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/rt/rust_port.cpp') diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp index ff743eeeb40..84cbb02e83b 100644 --- a/src/rt/rust_port.cpp +++ b/src/rt/rust_port.cpp @@ -22,8 +22,7 @@ rust_port::~rust_port() { } void rust_port::send(void *sptr) { - // FIXME: Is this lock really necessary? Why do we send with the lock - // but not receive with the lock? + I(task->sched, !lock.lock_held_by_current_thread()); scoped_lock with(lock); buffer.enqueue(sptr); @@ -40,6 +39,7 @@ void rust_port::send(void *sptr) { } bool rust_port::receive(void *dptr) { + I(task->sched, lock.lock_held_by_current_thread()); if (buffer.is_empty() == false) { buffer.dequeue(dptr); LOG(task, comm, "<=== read data ==="); @@ -49,6 +49,7 @@ bool rust_port::receive(void *dptr) { } size_t rust_port::size() { + I(task->sched, !lock.lock_held_by_current_thread()); scoped_lock with(lock); return buffer.size(); } -- cgit 1.4.1-3-g733a5