Skip to content

Commit 42affa0

Browse files
author
Eric Holk
committed
---
yaml --- r: 3703 b: refs/heads/master c: a0f45f4 h: refs/heads/master i: 3701: bd55da4 3699: c8c2a1e 3695: f96bf13 v: v3
1 parent 2dea01e commit 42affa0

File tree

5 files changed

+47
-76
lines changed

5 files changed

+47
-76
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e7111fe1473733e78775e280c0e597a2897d4411
2+
refs/heads/master: a0f45f4456de5e9811d80b20df243d7078c45918

trunk/src/rt/rust_builtin.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,12 @@ task_yield(rust_task *task) {
392392

393393
extern "C" CDECL void
394394
task_join(rust_task *task, rust_task *join_task) {
395-
task->kernel->scheduler_lock.lock();
396395
// If the other task is already dying, we don't have to wait for it.
397396
if (join_task->dead() == false) {
398397
join_task->tasks_waiting_to_join.push(task);
399398
task->block(join_task, "joining local task");
400-
task->kernel->scheduler_lock.unlock();
401399
task->yield(2);
402400
}
403-
else {
404-
task->kernel->scheduler_lock.unlock();
405-
}
406401
}
407402

408403
/* Debug builtins for std.dbg. */

trunk/src/rt/rust_srv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ rust_srv::fatal(const char *expression,
5454
"fatal, '%s' failed, %s:%d %s",
5555
expression, file, (int)line, buf);
5656
log(msg);
57-
exit(1);
57+
abort();
5858
}
5959

6060
void

trunk/src/rt/rust_task.cpp

+7-18
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,12 @@ void task_start_wrapper(spawn_args *a)
120120

121121
LOG(task, task, "task exited with value %d", rval);
122122

123-
{
124-
scoped_lock with(task->kernel->scheduler_lock);
123+
LOG(task, task, "task ref_count: %d", task->ref_count);
124+
A(task->sched, task->ref_count >= 0,
125+
"Task ref_count should not be negative on exit!");
126+
task->die();
127+
task->notify_tasks_waiting_to_join();
125128

126-
// FIXME: the old exit glue does some magical argument copying
127-
// stuff. This is probably still needed.
128-
129-
// This is duplicated from upcall_exit, which is probably dead code by
130-
// now.
131-
LOG(task, task, "task ref_count: %d", task->ref_count);
132-
A(task->sched, task->ref_count >= 0,
133-
"Task ref_count should not be negative on exit!");
134-
task->die();
135-
task->notify_tasks_waiting_to_join();
136-
137-
}
138129
task->yield(1);
139130
}
140131

@@ -145,10 +136,7 @@ rust_task::start(uintptr_t spawnee_fn,
145136
LOGPTR(sched, "from spawnee", spawnee_fn);
146137

147138
I(sched, stk->data != NULL);
148-
I(sched, !kernel->scheduler_lock.lock_held_by_current_thread());
149139

150-
scoped_lock with(kernel->scheduler_lock);
151-
152140
char *sp = (char *)rust_sp;
153141

154142
sp -= sizeof(spawn_args);
@@ -399,7 +387,8 @@ rust_task::free(void *p, bool is_gc)
399387

400388
void
401389
rust_task::transition(rust_task_list *src, rust_task_list *dst) {
402-
I(sched, kernel->scheduler_lock.lock_held_by_current_thread());
390+
I(sched, !kernel->scheduler_lock.lock_held_by_current_thread());
391+
scoped_lock with(kernel->scheduler_lock);
403392
DLOG(sched, task,
404393
"task %s " PTR " state change '%s' -> '%s' while in '%s'",
405394
name, (uintptr_t)this, src->name, dst->name, state->name);

trunk/src/rt/rust_upcall.cpp

+38-51
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ upcall_trace_str(rust_task *task, char const *c) {
9090
extern "C" CDECL rust_port*
9191
upcall_new_port(rust_task *task, size_t unit_sz) {
9292
LOG_UPCALL_ENTRY(task);
93-
scoped_lock with(task->kernel->scheduler_lock);
9493
LOG(task, comm, "upcall_new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)",
9594
(uintptr_t) task, task->name, unit_sz);
9695
return new (task) rust_port(task, unit_sz);
@@ -99,7 +98,6 @@ upcall_new_port(rust_task *task, size_t unit_sz) {
9998
extern "C" CDECL void
10099
upcall_del_port(rust_task *task, rust_port *port) {
101100
LOG_UPCALL_ENTRY(task);
102-
scoped_lock with(task->kernel->scheduler_lock);
103101
LOG(task, comm, "upcall del_port(0x%" PRIxPTR ")", (uintptr_t) port);
104102
I(task->sched, !port->ref_count);
105103
delete port;
@@ -139,7 +137,6 @@ upcall_flush_chan(rust_task *task, rust_chan *chan) {
139137
extern "C" CDECL
140138
void upcall_del_chan(rust_task *task, rust_chan *chan) {
141139
LOG_UPCALL_ENTRY(task);
142-
scoped_lock with(task->kernel->scheduler_lock);
143140

144141
LOG(task, comm, "upcall del_chan(0x%" PRIxPTR ")", (uintptr_t) chan);
145142
chan->destroy();
@@ -153,7 +150,6 @@ extern "C" CDECL rust_chan *
153150
upcall_clone_chan(rust_task *task, maybe_proxy<rust_task> *target,
154151
rust_chan *chan) {
155152
LOG_UPCALL_ENTRY(task);
156-
scoped_lock with(task->kernel->scheduler_lock);
157153
return chan->clone(target);
158154
}
159155

@@ -181,34 +177,31 @@ upcall_sleep(rust_task *task, size_t time_in_us) {
181177
extern "C" CDECL void
182178
upcall_send(rust_task *task, rust_chan *chan, void *sptr) {
183179
LOG_UPCALL_ENTRY(task);
184-
scoped_lock with(task->kernel->scheduler_lock);
185180
chan->send(sptr);
186181
LOG(task, comm, "=== sent data ===>");
187182
}
188183

189184
extern "C" CDECL void
190185
upcall_recv(rust_task *task, uintptr_t *dptr, rust_port *port) {
191-
{
192-
LOG_UPCALL_ENTRY(task);
193-
scoped_lock with(task->kernel->scheduler_lock);
194-
195-
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
196-
", size: 0x%" PRIxPTR ", chan_no: %d",
197-
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz,
198-
port->chans.length());
199-
200-
if (port->receive(dptr)) {
201-
return;
202-
}
203-
204-
// No data was buffered on any incoming channel, so block this task
205-
// on the port. Remember the rendezvous location so that any sender
206-
// task can write to it before waking up this task.
207-
208-
LOG(task, comm, "<=== waiting for rendezvous data ===");
209-
task->rendezvous_ptr = dptr;
210-
task->block(port, "waiting for rendezvous data");
186+
LOG_UPCALL_ENTRY(task);
187+
188+
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
189+
", size: 0x%" PRIxPTR ", chan_no: %d",
190+
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz,
191+
port->chans.length());
192+
193+
if (port->receive(dptr)) {
194+
return;
211195
}
196+
197+
// No data was buffered on any incoming channel, so block this task on the
198+
// port. Remember the rendezvous location so that any sender task can
199+
// write to it before waking up this task.
200+
201+
LOG(task, comm, "<=== waiting for rendezvous data ===");
202+
task->rendezvous_ptr = dptr;
203+
task->block(port, "waiting for rendezvous data");
204+
212205
task->yield(3);
213206
}
214207

@@ -228,7 +221,7 @@ upcall_fail(rust_task *task,
228221
extern "C" CDECL void
229222
upcall_kill(rust_task *task, maybe_proxy<rust_task> *target) {
230223
LOG_UPCALL_ENTRY(task);
231-
scoped_lock with(task->kernel->scheduler_lock);
224+
232225
if (target->is_proxy()) {
233226
notify_message::
234227
send(notify_message::KILL, "kill", task->get_handle(),
@@ -245,33 +238,31 @@ upcall_kill(rust_task *task, maybe_proxy<rust_task> *target) {
245238
*/
246239
extern "C" CDECL void
247240
upcall_exit(rust_task *task) {
248-
{
249-
LOG_UPCALL_ENTRY(task);
250-
scoped_lock with(task->kernel->scheduler_lock);
251-
LOG(task, task, "task ref_count: %d", task->ref_count);
252-
A(task->sched, task->ref_count >= 0,
253-
"Task ref_count should not be negative on exit!");
254-
task->die();
255-
task->notify_tasks_waiting_to_join();
256-
}
241+
LOG_UPCALL_ENTRY(task);
242+
LOG(task, task, "task ref_count: %d", task->ref_count);
243+
A(task->sched, task->ref_count >= 0,
244+
"Task ref_count should not be negative on exit!");
245+
task->die();
246+
task->notify_tasks_waiting_to_join();
257247
task->yield(1);
258248
}
259249

260250
extern "C" CDECL uintptr_t
261251
upcall_malloc(rust_task *task, size_t nbytes, type_desc *td) {
262252
LOG_UPCALL_ENTRY(task);
263-
scoped_lock with(task->kernel->scheduler_lock);
264253

265254
LOG(task, mem,
266-
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR ")"
267-
" with gc-chain head = 0x%" PRIxPTR,
268-
nbytes, td, task->gc_alloc_chain);
255+
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR ")"
256+
" with gc-chain head = 0x%" PRIxPTR,
257+
nbytes, td, task->gc_alloc_chain);
258+
269259
void *p = task->malloc(nbytes, td);
260+
270261
LOG(task, mem,
271-
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR
272-
") = 0x%" PRIxPTR
273-
" with gc-chain head = 0x%" PRIxPTR,
274-
nbytes, td, (uintptr_t)p, task->gc_alloc_chain);
262+
"upcall malloc(%" PRIdPTR ", 0x%" PRIxPTR
263+
") = 0x%" PRIxPTR
264+
" with gc-chain head = 0x%" PRIxPTR,
265+
nbytes, td, (uintptr_t)p, task->gc_alloc_chain);
275266
return (uintptr_t) p;
276267
}
277268

@@ -281,7 +272,7 @@ upcall_malloc(rust_task *task, size_t nbytes, type_desc *td) {
281272
extern "C" CDECL void
282273
upcall_free(rust_task *task, void* ptr, uintptr_t is_gc) {
283274
LOG_UPCALL_ENTRY(task);
284-
scoped_lock with(task->kernel->scheduler_lock);
275+
285276
rust_scheduler *sched = task->sched;
286277
DLOG(sched, mem,
287278
"upcall free(0x%" PRIxPTR ", is_gc=%" PRIdPTR ")",
@@ -322,7 +313,6 @@ upcall_shared_free(rust_task *task, void* ptr) {
322313
extern "C" CDECL uintptr_t
323314
upcall_mark(rust_task *task, void* ptr) {
324315
LOG_UPCALL_ENTRY(task);
325-
scoped_lock with(task->kernel->scheduler_lock);
326316

327317
rust_scheduler *sched = task->sched;
328318
if (ptr) {
@@ -354,23 +344,21 @@ rust_str *make_str(rust_task *task, char const *s, size_t fill) {
354344
extern "C" CDECL rust_str *
355345
upcall_new_str(rust_task *task, char const *s, size_t fill) {
356346
LOG_UPCALL_ENTRY(task);
357-
scoped_lock with(task->kernel->scheduler_lock);
358347

359348
return make_str(task, s, fill);
360349
}
361350

362351
extern "C" CDECL rust_str *
363352
upcall_dup_str(rust_task *task, rust_task *target, rust_str *str) {
364353
LOG_UPCALL_ENTRY(task);
365-
scoped_lock with(task->kernel->scheduler_lock);
366354

367355
return make_str(target, (char const *)str->data, str->fill);
368356
}
369357

370358
extern "C" CDECL rust_vec *
371359
upcall_new_vec(rust_task *task, size_t fill, type_desc *td) {
372360
LOG_UPCALL_ENTRY(task);
373-
scoped_lock with(task->kernel->scheduler_lock);
361+
374362
rust_scheduler *sched = task->sched;
375363
DLOG(sched, mem, "upcall new_vec(%" PRIdPTR ")", fill);
376364
size_t alloc = next_power_of_two(sizeof(rust_vec) + fill);
@@ -511,7 +499,7 @@ upcall_get_type_desc(rust_task *task,
511499
type_desc const **descs) {
512500
check_stack(task);
513501
LOG_UPCALL_ENTRY(task);
514-
scoped_lock with(task->kernel->scheduler_lock);
502+
515503
LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR
516504
", align=%" PRIdPTR ", %" PRIdPTR " descs", size, align,
517505
n_descs);
@@ -568,7 +556,7 @@ upcall_ivec_resize(rust_task *task,
568556
rust_ivec *v,
569557
size_t newsz) {
570558
LOG_UPCALL_ENTRY(task);
571-
scoped_lock with(task->kernel->scheduler_lock);
559+
572560
I(task->sched, !v->fill);
573561

574562
size_t new_alloc = next_power_of_two(newsz);
@@ -588,7 +576,6 @@ upcall_ivec_spill(rust_task *task,
588576
rust_ivec *v,
589577
size_t newsz) {
590578
LOG_UPCALL_ENTRY(task);
591-
scoped_lock with(task->kernel->scheduler_lock);
592579
size_t new_alloc = next_power_of_two(newsz);
593580

594581
rust_ivec_heap *heap_part = (rust_ivec_heap *)

0 commit comments

Comments
 (0)