A little tidying in rt.
This commit is contained in:
parent
022ebc198b
commit
bc9fa31618
7 changed files with 24 additions and 31 deletions
|
|
@ -2,7 +2,7 @@
|
|||
* The Rust runtime uses memory regions to provide a primitive level of
|
||||
* memory management and isolation between tasks, and domains.
|
||||
*
|
||||
* TODO: Implement a custom lock-free malloc / free instead of relying solely
|
||||
* FIXME: Implement a custom lock-free malloc / free instead of relying solely
|
||||
* on the standard malloc / free.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ int get_num_threads()
|
|||
if(num > 0)
|
||||
return num;
|
||||
}
|
||||
// TODO: in this case, determine the number of CPUs present on the
|
||||
// FIXME: in this case, determine the number of CPUs present on the
|
||||
// machine.
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,7 +269,11 @@ rust_dom::start_main_loop(int id) {
|
|||
scheduler_lock.lock();
|
||||
|
||||
// Make sure someone is watching, to pull us out of infinite loops.
|
||||
//rust_timer timer(this);
|
||||
//
|
||||
// FIXME: time-based interruption is not presently working; worked
|
||||
// in rustboot and has been completely broken in rustc.
|
||||
//
|
||||
// rust_timer timer(this);
|
||||
|
||||
DLOG(this, dom, "started domain loop %d", id);
|
||||
|
||||
|
|
@ -332,14 +336,6 @@ rust_dom::start_main_loop(int id) {
|
|||
scheduled_task->rust_sp,
|
||||
id);
|
||||
|
||||
/*
|
||||
// These invariants are no longer valid, as rust_sp is not
|
||||
// updated.
|
||||
I(this, scheduled_task->rust_sp >=
|
||||
(uintptr_t) &scheduled_task->stk->data[0]);
|
||||
I(this, scheduled_task->rust_sp < scheduled_task->stk->limit);
|
||||
*/
|
||||
|
||||
reap_dead_tasks();
|
||||
}
|
||||
|
||||
|
|
@ -371,14 +367,14 @@ rust_dom::start_main_loop(int id) {
|
|||
int rust_dom::start_main_loops(int num_threads)
|
||||
{
|
||||
dom_worker *worker = NULL;
|
||||
|
||||
|
||||
// -1, because this thread will also be a worker.
|
||||
for(int i = 0; i < num_threads - 1; ++i) {
|
||||
worker = new dom_worker(i + 1, this);
|
||||
worker->start();
|
||||
threads.push(worker);
|
||||
}
|
||||
|
||||
|
||||
start_main_loop(0);
|
||||
|
||||
while(threads.pop(&worker)) {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
// FIXME (issue #151): This should be 0x300; the change here is for
|
||||
// practicality's sake until stack growth is working.
|
||||
//static size_t const min_stk_bytes = 0x300000;
|
||||
//static size_t const min_stk_bytes = 0x10000;
|
||||
|
||||
static size_t const min_stk_bytes = 0x100000;
|
||||
|
||||
// Task stack segments. Heap allocated and chained together.
|
||||
|
|
@ -120,7 +119,7 @@ struct spawn_args {
|
|||
rust_task *task;
|
||||
uintptr_t a3;
|
||||
uintptr_t a4;
|
||||
void (*CDECL f)(int *, rust_task *,
|
||||
void (*CDECL f)(int *, rust_task *,
|
||||
uintptr_t, uintptr_t);
|
||||
};
|
||||
|
||||
|
|
@ -129,15 +128,15 @@ void task_start_wrapper(spawn_args *a)
|
|||
{
|
||||
rust_task *task = a->task;
|
||||
int rval = 42;
|
||||
|
||||
|
||||
a->f(&rval, task, a->a3, a->a4);
|
||||
|
||||
|
||||
LOG(task, task, "task exited with value %d", rval);
|
||||
|
||||
{
|
||||
scoped_lock with(task->dom->scheduler_lock);
|
||||
|
||||
// TODO: the old exit glue does some magical argument copying
|
||||
|
||||
// FIXME: the old exit glue does some magical argument copying
|
||||
// stuff. This is probably still needed.
|
||||
|
||||
// This is duplicated from upcall_exit, which is probably dead code by
|
||||
|
|
@ -160,7 +159,7 @@ rust_task::start(uintptr_t spawnee_fn,
|
|||
|
||||
I(dom, stk->data != NULL);
|
||||
I(dom, !dom->scheduler_lock.lock_held_by_current_thread());
|
||||
|
||||
|
||||
scoped_lock with(dom->scheduler_lock);
|
||||
|
||||
char *sp = (char *)rust_sp;
|
||||
|
|
@ -174,7 +173,7 @@ rust_task::start(uintptr_t spawnee_fn,
|
|||
a->a4 = args;
|
||||
void **f = (void **)&a->f;
|
||||
*f = (void *)spawnee_fn;
|
||||
|
||||
|
||||
ctx.call((void *)task_start_wrapper, a, sp);
|
||||
|
||||
yield_timer.reset(0);
|
||||
|
|
@ -201,7 +200,7 @@ rust_task::yield(size_t nargs, size_t time_in_us) {
|
|||
LOG(this, task, "task %s @0x%" PRIxPTR " yielding for %d us",
|
||||
name, this, time_in_us);
|
||||
|
||||
// TODO: what is nargs for, and is it safe to ignore?
|
||||
// FIXME: what is nargs for, and is it safe to ignore?
|
||||
|
||||
yield_timer.reset(time_in_us);
|
||||
|
||||
|
|
@ -254,9 +253,9 @@ rust_task::fail(size_t nargs) {
|
|||
void
|
||||
rust_task::gc(size_t nargs)
|
||||
{
|
||||
// FIXME: not presently implemented; was broken by rustc.
|
||||
DLOG(dom, task,
|
||||
"task %s @0x%" PRIxPTR " garbage collecting", name, this);
|
||||
// run_after_return(nargs, rust_gc_glue);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -346,7 +345,7 @@ void *
|
|||
rust_task::malloc(size_t sz, type_desc *td)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// Effects, GC-memory classification are all wrong.
|
||||
// GC-memory classification is all wrong.
|
||||
td = NULL;
|
||||
|
||||
if (td) {
|
||||
|
|
@ -373,7 +372,7 @@ void *
|
|||
rust_task::realloc(void *data, size_t sz, bool is_gc)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// Effects, GC-memory classification are all wrong.
|
||||
// Effects, GC-memory classification is all wrong.
|
||||
is_gc = false;
|
||||
if (is_gc) {
|
||||
gc_alloc *gcm = (gc_alloc*)(((char *)data) - sizeof(gc_alloc));
|
||||
|
|
@ -397,7 +396,7 @@ void
|
|||
rust_task::free(void *p, bool is_gc)
|
||||
{
|
||||
// FIXME: GC is disabled for now.
|
||||
// Effects, GC-memory classification are all wrong.
|
||||
// GC-memory classification is all wrong.
|
||||
is_gc = false;
|
||||
if (is_gc) {
|
||||
gc_alloc *gcm = (gc_alloc*)(((char *)p) - sizeof(gc_alloc));
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ upcall_new_thread(rust_task *task, const char *name) {
|
|||
return child_task_proxy;
|
||||
}
|
||||
|
||||
#if 0 /* TODO: this code will be re-enabled once we have multithreading. */
|
||||
#if 0 /* FIXME: this code will be re-enabled once we have multithreading. */
|
||||
|
||||
#if defined(__WIN32__)
|
||||
static DWORD WINAPI rust_thread_start(void *ptr)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#if defined(__WIN32__)
|
||||
lock_and_signal::lock_and_signal() {
|
||||
// TODO: In order to match the behavior of pthread_cond_broadcast on
|
||||
// FIXME: In order to match the behavior of pthread_cond_broadcast on
|
||||
// Windows, we create manual reset events. This however breaks the
|
||||
// behavior of pthread_cond_signal, fixing this is quite involved:
|
||||
// refer to: http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
#include "rust_test_runtime.h"
|
||||
|
||||
rust_test_runtime::rust_test_runtime() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
rust_test_runtime::~rust_test_runtime() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
#define DOMAINS 32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue