2010-07-19 16:05:18 -05:00
|
|
|
#ifndef RUST_DOM_H
|
|
|
|
#define RUST_DOM_H
|
|
|
|
|
2010-09-07 20:39:07 -05:00
|
|
|
struct rust_dom : public kernel_owned<rust_dom>, rc_base<rust_dom>
|
2010-07-19 16:05:18 -05:00
|
|
|
{
|
|
|
|
// Fields known to the compiler:
|
|
|
|
uintptr_t interrupt_flag;
|
|
|
|
|
|
|
|
// Fields known only by the runtime:
|
|
|
|
|
|
|
|
// NB: the root crate must remain in memory until the root of the
|
|
|
|
// tree of domains exits. All domains within this tree have a
|
|
|
|
// copy of this root_crate value and use it for finding utility
|
|
|
|
// glue.
|
|
|
|
rust_crate const *root_crate;
|
|
|
|
rust_log _log;
|
|
|
|
rust_srv *srv;
|
2010-08-18 01:40:07 -05:00
|
|
|
memory_region local_region;
|
|
|
|
memory_region synchronized_region;
|
2010-08-08 21:24:35 -05:00
|
|
|
const char *const name;
|
2010-07-19 16:05:18 -05:00
|
|
|
ptr_vec<rust_task> running_tasks;
|
|
|
|
ptr_vec<rust_task> blocked_tasks;
|
|
|
|
ptr_vec<rust_task> dead_tasks;
|
|
|
|
ptr_vec<rust_crate_cache> caches;
|
|
|
|
randctx rctx;
|
|
|
|
rust_task *root_task;
|
|
|
|
rust_task *curr_task;
|
|
|
|
int rval;
|
|
|
|
|
2010-09-07 20:39:07 -05:00
|
|
|
rust_kernel *kernel;
|
2010-08-27 20:26:36 -05:00
|
|
|
int32_t list_index;
|
|
|
|
|
2010-07-28 18:24:50 -05:00
|
|
|
hash_map<rust_task *, rust_proxy<rust_task> *> _task_proxies;
|
2010-07-28 18:46:13 -05:00
|
|
|
hash_map<rust_port *, rust_proxy<rust_port> *> _port_proxies;
|
2010-07-28 18:24:50 -05:00
|
|
|
|
2010-07-19 16:05:18 -05:00
|
|
|
// Incoming messages from other domains.
|
2010-09-07 20:39:07 -05:00
|
|
|
rust_message_queue *message_queue;
|
2010-07-19 16:05:18 -05:00
|
|
|
|
|
|
|
#ifndef __WIN32__
|
|
|
|
pthread_attr_t attr;
|
|
|
|
#endif
|
|
|
|
|
2010-08-08 21:24:35 -05:00
|
|
|
// Only a pointer to 'name' is kept, so it must live as long as this
|
|
|
|
// domain.
|
2010-09-07 20:39:07 -05:00
|
|
|
rust_dom(rust_kernel *kernel,
|
|
|
|
rust_message_queue *message_queue, rust_srv *srv,
|
|
|
|
rust_crate const *root_crate, const char *name);
|
2010-07-19 16:05:18 -05:00
|
|
|
~rust_dom();
|
|
|
|
void activate(rust_task *task);
|
|
|
|
void log(rust_task *task, uint32_t logbit, char const *fmt, ...);
|
|
|
|
void log(uint32_t logbit, char const *fmt, ...);
|
|
|
|
rust_log & get_log();
|
|
|
|
void logptr(char const *msg, uintptr_t ptrval);
|
|
|
|
template<typename T>
|
|
|
|
void logptr(char const *msg, T* ptrval);
|
|
|
|
void fail();
|
2010-08-18 01:40:07 -05:00
|
|
|
void *malloc(size_t size);
|
|
|
|
void *malloc(size_t size, memory_region::memory_region_type type);
|
|
|
|
void *calloc(size_t size);
|
|
|
|
void *calloc(size_t size, memory_region::memory_region_type type);
|
|
|
|
void *realloc(void *mem, size_t size);
|
|
|
|
void *realloc(void *mem, size_t size,
|
|
|
|
memory_region::memory_region_type type);
|
|
|
|
void free(void *mem);
|
|
|
|
void free(void *mem, memory_region::memory_region_type type);
|
2010-07-19 16:05:18 -05:00
|
|
|
|
2010-08-24 23:06:56 -05:00
|
|
|
void drain_incoming_message_queue(bool process);
|
2010-07-19 16:05:18 -05:00
|
|
|
|
|
|
|
#ifdef __WIN32__
|
|
|
|
void win32_require(LPCTSTR fn, BOOL ok);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rust_crate_cache *get_cache(rust_crate const *crate);
|
|
|
|
size_t n_live_tasks();
|
|
|
|
void add_task_to_state_vec(ptr_vec<rust_task> *v, rust_task *task);
|
|
|
|
void remove_task_from_state_vec(ptr_vec<rust_task> *v, rust_task *task);
|
|
|
|
const char *state_vec_name(ptr_vec<rust_task> *v);
|
|
|
|
|
|
|
|
void reap_dead_tasks();
|
|
|
|
rust_task *schedule_task();
|
2010-09-07 20:39:07 -05:00
|
|
|
|
2010-07-19 16:05:18 -05:00
|
|
|
int start_main_loop();
|
2010-07-28 16:53:08 -05:00
|
|
|
|
|
|
|
void log_state();
|
2010-08-09 09:34:11 -05:00
|
|
|
static void log_all_state();
|
2010-07-19 16:05:18 -05:00
|
|
|
};
|
|
|
|
|
2010-07-28 02:36:35 -05:00
|
|
|
//
|
|
|
|
// Local Variables:
|
|
|
|
// mode: C++
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
|
|
|
// End:
|
|
|
|
//
|
|
|
|
|
2010-07-19 16:05:18 -05:00
|
|
|
#endif /* RUST_DOM_H */
|