Skip to content

Commit f619d5e

Browse files
committed
rt: Add locking invariants to rust_port
1 parent 58e923d commit f619d5e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/rt/rust_port.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ rust_port::~rust_port() {
2222
}
2323

2424
void rust_port::send(void *sptr) {
25-
// FIXME: Is this lock really necessary? Why do we send with the lock
26-
// but not receive with the lock?
25+
I(task->sched, !lock.lock_held_by_current_thread());
2726
scoped_lock with(lock);
2827

2928
buffer.enqueue(sptr);
@@ -40,6 +39,7 @@ void rust_port::send(void *sptr) {
4039
}
4140

4241
bool rust_port::receive(void *dptr) {
42+
I(task->sched, lock.lock_held_by_current_thread());
4343
if (buffer.is_empty() == false) {
4444
buffer.dequeue(dptr);
4545
LOG(task, comm, "<=== read data ===");
@@ -49,6 +49,7 @@ bool rust_port::receive(void *dptr) {
4949
}
5050

5151
size_t rust_port::size() {
52+
I(task->sched, !lock.lock_held_by_current_thread());
5253
scoped_lock with(lock);
5354
return buffer.size();
5455
}

0 commit comments

Comments
 (0)