Hi,

I'm trying to use PERCPU macro in application or module.

I tried using cpu::notifier, but it seems a_init is not called.


class A {
public:
A() { printf("init: %p\n", this); }
void test() { printf("test: %d\n", x); }
int x = 123;
};
PERCPU(A *, a);
static sched::cpu::notifier a_init([]() { *a = new A(); });


Also, I used constructor function to initialize As, but it aborts.

static __attribute__((constructor)) void a_init() {
for (auto c : sched::cpus) {
sched::thread *th = sched::thread::make([] { *a = new A(); },
sched::thread::attr().pin(c));
th->start();
th->join();
}
}


Any hint for this case?

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/1f565100-2533-4c6b-bd5d-42e30ffaff6d%40googlegroups.com.

Reply via email to