2011-06-28 12:54:41 -07:00
|
|
|
#include "rust_test_runtime.h"
|
|
|
|
|
|
|
|
|
|
rust_test_runtime::rust_test_runtime() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rust_test_runtime::~rust_test_runtime() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define DOMAINS 32
|
|
|
|
|
#define TASKS 32
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
rust_domain_test::worker::run() {
|
|
|
|
|
for (int i = 0; i < TASKS; i++) {
|
2011-07-23 19:03:02 -07:00
|
|
|
kernel->create_task(NULL, "child");
|
2011-06-28 12:54:41 -07:00
|
|
|
}
|
2011-07-23 19:03:02 -07:00
|
|
|
//sync::sleep(rand(&handle->rctx) % 1000);
|
2011-06-28 12:54:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
rust_domain_test::run() {
|
|
|
|
|
rust_srv srv;
|
2011-07-23 19:03:02 -07:00
|
|
|
rust_kernel kernel(&srv, 1);
|
2011-06-28 12:54:41 -07:00
|
|
|
|
|
|
|
|
array_list<worker *> workers;
|
|
|
|
|
for (int i = 0; i < DOMAINS; i++) {
|
|
|
|
|
worker *worker = new rust_domain_test::worker (&kernel);
|
|
|
|
|
workers.append(worker);
|
|
|
|
|
worker->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We don't join the worker threads here in order to simulate ad-hoc
|
|
|
|
|
// termination of domains. If we join_all_domains before all domains
|
|
|
|
|
// are actually spawned, this could crash, thus the reason for the
|
|
|
|
|
// sleep below.
|
|
|
|
|
|
|
|
|
|
sync::sleep(100);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void task_entry() {
|
|
|
|
|
printf("task entry\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
rust_task_test::worker::run() {
|
2011-07-23 14:01:43 -07:00
|
|
|
rust_task *root_task = kernel->create_task(NULL, "main");
|
|
|
|
|
root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
|
2011-07-23 19:03:02 -07:00
|
|
|
root_task->sched->start_main_loop();
|
2011-06-28 12:54:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
rust_task_test::run() {
|
|
|
|
|
rust_srv srv;
|
2011-07-23 19:03:02 -07:00
|
|
|
rust_kernel kernel(&srv, 1);
|
2011-06-28 12:54:41 -07:00
|
|
|
|
|
|
|
|
array_list<worker *> workers;
|
|
|
|
|
for (int i = 0; i < DOMAINS; i++) {
|
|
|
|
|
worker *worker = new rust_task_test::worker (&kernel, this);
|
|
|
|
|
workers.append(worker);
|
|
|
|
|
worker->start();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 19:03:02 -07:00
|
|
|
//sync::sleep(rand(&kernel.sched->rctx) % 1000);
|
2011-06-28 12:54:41 -07:00
|
|
|
return true;
|
|
|
|
|
}
|