22 v->active_receptor_count = 0;
23 v->receptor_count = 0;
24 v->installed_receptors =
_s_new(RECEPTOR_IDENTIFIER,RECEPTOR_SURFACE);
25 v->vm_thread.state = 0;
26 v->clock_thread.state = 0;
48 VMHost *v = __v_init(r,sem);
52 r =
_r_new(sem,COMPOSITORY);
53 _v_new_receptor(v,v->
r,COMPOSITORY,r);
55 r =
_r_new(sem,DEV_COMPOSITORY);
56 _v_new_receptor(v,v->
r,DEV_COMPOSITORY,r);
58 r =
_r_new(sem,TEST_RECEPTOR);
59 _v_new_receptor(v,v->
r,TEST_RECEPTOR,r);
61 _r_defineClockReceptor(sem);
73 _s_free(v->installed_receptors);
92 raise_error(
"not implemented");
110 raise_error(
"not implemented");
117 if (!(is_null_xaddr(x)))
return G_null_xaddr;
118 _s_add(v->installed_receptors,h,package);
125 if (c%2) {raise_error(
"manifest must have even number of children!");}
145 raise_error(
"fix semtable");
147 return _v_new_receptor(v,v->
r,s,r);
152 if (v->receptor_count+1 >= MAX_RECEPTORS) {
153 raise_error(
"too many receptors");
155 int c = v->receptor_count++;
156 v->routing_table[c].r=r;
157 v->routing_table[c].s=s;
173 if (v->active_receptor_count+1 >= MAX_ACTIVE_RECEPTORS) {
174 raise_error(
"too many active receptors");
178 int c = v->active_receptor_count++;
183 if (semeq(x.symbol,CLOCK_RECEPTOR)) {
236 T *signals = sender->pending_signals;
240 T *head =
_t_getv(s,SignalMessageIdx,MessageHeadIdx,TREE_PATH_TERMINATOR);
248 if (fromP->addr == SELF_RECEPTOR_ADDR) {
249 *fromP = __r_get_self_address(sender);
253 if (toP->addr == SELF_RECEPTOR_ADDR) {
254 *toP = __r_get_self_address(sender);
257 if (toP->addr >= v->receptor_count) {
258 raise_error(
"to address: %d doesn't exist!",toP->addr);
260 r = v->routing_table[toP->addr].r;
265 raise_error(
"delivery error: %d",err);
277 while(v->
r->
state == Alive) {
290 for (i=0;v->
r->
state == Alive && i<v->active_receptor_count;i++) {
304 for (i=0;i<v->active_receptor_count;i++) {
317 void _v_start_vmhost(
VMHost *v) {
326 Xaddr clock = _v_new_receptor(v,v->
r,CLOCK_RECEPTOR,r);
332 void _v_start_thread(
thread *t,
void *(*start_routine)(
void*),
void *arg) {
335 raise_error(
"attempt to double-start a thread");
337 rc = pthread_create(&t->pthread,0,start_routine,arg);
339 raise_error(
"Error starting thread; return code from pthread_create() is %d\n", rc);
344 void _v_join_thread(
thread *t) {
349 rc = pthread_join(t->pthread, &status);
351 raise_error(
"ERROR; return code from pthread_join() is %d\n", rc);
char * _sem_get_name(SemTable *sem, SemanticID s)
Scape * _s_new(Symbol key_source, Symbol data_source)
int state
state information about the receptor that the vmhost manages
Xaddr _s_get(Scape *s, TreeHash h)
void _v_send(VMHost *v, ReceptorAddress from, ReceptorAddress to, Aspect aspect, Symbol carrier, T *contents)
T * _t_detach_by_idx(T *t, int i)
T * _t_new_receptor(T *parent, Symbol symbol, Receptor *r)
Xaddr _v_load_receptor_package(VMHost *v, T *p)
TreeHash _t_hash(SemTable *sem, T *t)
void _v_instantiate_builtins(VMHost *v)
void _r_free(Receptor *r)
semantic trees header file
T * _t_child(T *t, int i)
Xaddr _v_install_r(VMHost *v, Xaddr package, T *bindings, char *label)
Receptor * __r_get_receptor(T *installed_receptor)
void * __v_process(void *arg)
vmhost implementation header file
Receptor * _r_new_receptor_from_package(SemTable *sem, Symbol s, T *p, T *bindings)
Creates a new receptor from a receptor package.
ReceptorAddress addr
the address by which to get messages to this receptor instance
VMHost * _v_new()
Creates a new virtual machine host.
void _v_send_signals(VMHost *v, T *signals)
void _v_activate(VMHost *v, Xaddr x)
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
SemTable * sem
Semantic Table for definitions on this host.
T * _r_send(Receptor *r, T *signal)
int contexts_count
number of active processes
T * __r_make_signal(ReceptorAddress from, ReceptorAddress to, Aspect aspect, Symbol carrier, T *signal_contents, UUIDt *in_response_to, T *until, T *cid)
SemTable * sem
pointer back to the genotype table for this receptor's vmhost instance
ActiveReceptor active_receptors[MAX_ACTIVE_RECEPTORS]
pointer to array that holds all currently active receptors
T * _r_get_instance(Receptor *r, Xaddr x)
void * ___clock_thread(void *arg)
Receptor * r
Receptor data for this vm host.
Qe * completed
completed processes (pending cleanup)
Symbol _r_define_symbol(Receptor *r, Structure s, char *label)
void _v_deliver_signals(VMHost *v, Receptor *sender)
Error _r_deliver(Receptor *r, T *signal)
header file for the accumulator
void _s_add(Scape *s, TreeHash h, Xaddr x)
Xaddr _r_new_instance(Receptor *r, T *t)