Skip to content

Commit 6ac4aff

Browse files
Eric Holkgraydon
authored andcommitted
---
yaml --- r: 4285 b: refs/heads/master c: d1dbb99 h: refs/heads/master i: 4283: 8d930e0 v: v3
1 parent 3eede93 commit 6ac4aff

18 files changed

+65
-691
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: bc4e9afe2547fa88b55ffc31fef041dffe864b2b
2+
refs/heads/master: d1dbb99984064eedb77c0f55300430bcb35ce109

trunk/mk/rt.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ RUNTIME_CS := rt/sync/timer.cpp \
1818
rt/rust_port.cpp \
1919
rt/rust_upcall.cpp \
2020
rt/rust_log.cpp \
21-
rt/rust_message.cpp \
2221
rt/rust_timer.cpp \
2322
rt/circular_buffer.cpp \
2423
rt/isaac/randport.cpp \
@@ -44,9 +43,7 @@ RUNTIME_HDR := rt/globals.h \
4443
rt/rust_scheduler.h \
4544
rt/rust_task.h \
4645
rt/rust_task_list.h \
47-
rt/rust_proxy.h \
4846
rt/rust_log.h \
49-
rt/rust_message.h \
5047
rt/circular_buffer.h \
5148
rt/util/array_list.h \
5249
rt/util/indexed_list.h \

trunk/src/rt/rust.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
9393

9494
rust_srv *srv = new rust_srv(env);
9595
rust_kernel *kernel = new rust_kernel(srv, env->num_sched_threads);
96-
kernel->start();
9796
rust_task *root_task = kernel->create_task(NULL, "main");
9897
rust_scheduler *sched = root_task->sched;
9998
command_line_args *args

trunk/src/rt/rust_chan.cpp

Lines changed: 39 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* Create a new rust channel and associate it with the specified port.
66
*/
7-
rust_chan::rust_chan(rust_kernel *kernel, maybe_proxy<rust_port> *port,
7+
rust_chan::rust_chan(rust_kernel *kernel, rust_port *port,
88
size_t unit_sz)
99
: ref_count(1),
1010
kernel(kernel),
@@ -29,18 +29,16 @@ rust_chan::~rust_chan() {
2929
/**
3030
* Link this channel with the specified port.
3131
*/
32-
void rust_chan::associate(maybe_proxy<rust_port> *port) {
32+
void rust_chan::associate(rust_port *port) {
3333
this->port = port;
34-
if (port->is_proxy() == false) {
35-
scoped_lock with(port->referent()->lock);
36-
KLOG(kernel, task,
37-
"associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
38-
this, port);
39-
++this->ref_count;
40-
this->task = port->referent()->task;
41-
this->task->ref();
42-
this->port->referent()->chans.push(this);
43-
}
34+
scoped_lock with(port->lock);
35+
KLOG(kernel, task,
36+
"associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
37+
this, port);
38+
++this->ref_count;
39+
this->task = port->task;
40+
this->task->ref();
41+
this->port->chans.push(this);
4442
}
4543

4644
bool rust_chan::is_associated() {
@@ -52,19 +50,17 @@ bool rust_chan::is_associated() {
5250
*/
5351
void rust_chan::disassociate() {
5452
A(kernel,
55-
port->referent()->lock.lock_held_by_current_thread(),
53+
port->lock.lock_held_by_current_thread(),
5654
"Port referent lock must be held to call rust_chan::disassociate");
5755
A(kernel, is_associated(),
5856
"Channel must be associated with a port.");
59-
if (port->is_proxy() == false) {
60-
KLOG(kernel, task,
61-
"disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
62-
this, port->referent());
63-
--this->ref_count;
64-
task->deref();
65-
this->task = NULL;
66-
port->referent()->chans.swap_delete(this);
67-
}
57+
KLOG(kernel, task,
58+
"disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
59+
this, port);
60+
--this->ref_count;
61+
task->deref();
62+
this->task = NULL;
63+
port->chans.swap_delete(this);
6864

6965
// Delete reference to the port.
7066
port = NULL;
@@ -74,12 +70,7 @@ void rust_chan::disassociate() {
7470
* Attempt to send data to the associated port.
7571
*/
7672
void rust_chan::send(void *sptr) {
77-
I(kernel, !port->is_proxy());
78-
79-
rust_port *target_port = port->referent();
80-
// TODO: We can probably avoid this lock by using atomic operations in
81-
// circular_buffer.
82-
scoped_lock with(target_port->lock);
73+
scoped_lock with(port->lock);
8374

8475
buffer.enqueue(sptr);
8576

@@ -92,28 +83,17 @@ void rust_chan::send(void *sptr) {
9283
A(kernel, !buffer.is_empty(),
9384
"rust_chan::transmit with nothing to send.");
9485

95-
if (port->is_proxy()) {
96-
data_message::send(buffer.peek(), buffer.unit_sz, "send data",
97-
task->get_handle(), port->as_proxy()->handle());
98-
buffer.dequeue(NULL);
99-
} else {
100-
if (target_port->task->blocked_on(target_port)) {
101-
KLOG(kernel, comm, "dequeued in rendezvous_ptr");
102-
buffer.dequeue(target_port->task->rendezvous_ptr);
103-
target_port->task->rendezvous_ptr = 0;
104-
target_port->task->wakeup(target_port);
105-
return;
106-
}
86+
if (port->task->blocked_on(port)) {
87+
KLOG(kernel, comm, "dequeued in rendezvous_ptr");
88+
buffer.dequeue(port->task->rendezvous_ptr);
89+
port->task->rendezvous_ptr = 0;
90+
port->task->wakeup(port);
10791
}
108-
109-
return;
11092
}
11193

11294
rust_chan *rust_chan::clone(rust_task *target) {
113-
size_t unit_sz = buffer.unit_sz;
114-
maybe_proxy<rust_port> *port = this->port;
11595
return new (target->kernel, "cloned chan")
116-
rust_chan(kernel, port, unit_sz);
96+
rust_chan(kernel, port, buffer.unit_sz);
11797
}
11898

11999
/**
@@ -125,30 +105,21 @@ void rust_chan::destroy() {
125105
"Channel's ref count should be zero.");
126106

127107
if (is_associated()) {
128-
if (port->is_proxy()) {
129-
// Here is a good place to delete the port proxy we allocated
130-
// in upcall_clone_chan.
131-
rust_proxy<rust_port> *proxy = port->as_proxy();
132-
scoped_lock with(port->referent()->lock);
133-
disassociate();
134-
delete proxy;
135-
} else {
136-
// We're trying to delete a channel that another task may be
137-
// reading from. We have two options:
138-
//
139-
// 1. We can flush the channel by blocking in upcall_flush_chan()
140-
// and resuming only when the channel is flushed. The problem
141-
// here is that we can get ourselves in a deadlock if the
142-
// parent task tries to join us.
143-
//
144-
// 2. We can leave the channel in a "dormnat" state by not freeing
145-
// it and letting the receiver task delete it for us instead.
146-
if (buffer.is_empty() == false) {
147-
return;
148-
}
149-
scoped_lock with(port->referent()->lock);
150-
disassociate();
108+
// We're trying to delete a channel that another task may be
109+
// reading from. We have two options:
110+
//
111+
// 1. We can flush the channel by blocking in upcall_flush_chan()
112+
// and resuming only when the channel is flushed. The problem
113+
// here is that we can get ourselves in a deadlock if the
114+
// parent task tries to join us.
115+
//
116+
// 2. We can leave the channel in a "dormnat" state by not freeing
117+
// it and letting the receiver task delete it for us instead.
118+
if (buffer.is_empty() == false) {
119+
return;
151120
}
121+
scoped_lock with(port->lock);
122+
disassociate();
152123
}
153124
delete this;
154125
}

trunk/src/rt/rust_chan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ class rust_chan : public kernel_owned<rust_chan>,
55
public rust_cond {
66
public:
77
RUST_REFCOUNTED_WITH_DTOR(rust_chan, destroy())
8-
rust_chan(rust_kernel *kernel, maybe_proxy<rust_port> *port,
8+
rust_chan(rust_kernel *kernel, rust_port *port,
99
size_t unit_sz);
1010

1111
~rust_chan();
1212

1313
rust_kernel *kernel;
1414
rust_task *task;
15-
maybe_proxy<rust_port> *port;
15+
rust_port *port;
1616
size_t idx;
1717
circular_buffer buffer;
1818

19-
void associate(maybe_proxy<rust_port> *port);
19+
void associate(rust_port *port);
2020
void disassociate();
2121
bool is_associated();
2222

trunk/src/rt/rust_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ template <typename T> class ptr_vec : public task_owned<ptr_vec<T> > {
219219
#include "memory_region.h"
220220
#include "rust_srv.h"
221221
#include "rust_log.h"
222-
#include "rust_proxy.h"
223222
#include "rust_kernel.h"
224-
#include "rust_message.h"
225223
#include "rust_scheduler.h"
226224

227225
struct rust_timer {

0 commit comments

Comments
 (0)