int main(int argc, char **argv) { //this is the bootstrap copy of the domain if (strcmp(argv[argc - 1], "SpAwNeD") != 0) { bsp_datagatherer = true; } else { bsp_datagatherer = false; } core_id = disp_get_core_id(); skb_client_connect(); #ifdef SPAWN_YOUR_SELF if (bsp_datagatherer) { spawnmyself(); } #endif //gather different types of data //run cpuid gather_cpuid_data(core_id); //get the number of running cores and their APIC IDs from the monitor if (bsp_datagatherer) { gather_nr_running_cores(get_monitor_binding()); } else { nr_cores_done = true; } //adding the numer of cores is the last operation performed by the datagatherer. //therefore the domain can exit after this. process events as long as the number //of cores has not yet been added to the SKB. struct waitset *ws = get_default_waitset(); while (!nr_cores_done) { errval_t err = event_dispatch(ws); if (err_is_fail(err)) { DEBUG_ERR(err, "in event_dispatch"); break; } } skb_add_fact("datagatherer_done."); if (bsp_datagatherer) { int length = nr_of_running_cores + 1; while (length != nr_of_running_cores) { skb_execute_query("findall(X, datagatherer_done, L),length(L,Len),write(Len)."); skb_read_output("%d", &length); thread_yield(); } errval_t err = nameservice_register("datagatherer_done", 0); if (err_is_fail(err)) { DEBUG_ERR(err, "nameservice_register failed"); } } return 0; }
static void memory_affinity(int core, uint64_t* min, uint64_t* max) { errval_t r; r = skb_execute_query("local_memory_affinity(%d, B, L)," "write(base(B)),write(limit(L)).", core); assert(err_is_ok(r)); r = skb_read_output("base(%lu)limit(%lu).", min, max); assert(err_is_ok(r)); }