Hello,
Excuse me if I'm "abusing" the forum but I can't find a solution.
I want to run a single function in all the CPUs.
I tried with:
But i see only one (randomly) of:
"hello world from 0 cpu!"
"hello world from 1 cpu!"
"hello world from 2 cpu!"
I expected to see it 3 times with different number.
What's wrong?
Thanks.
Excuse me if I'm "abusing" the forum but I can't find a solution.
I want to run a single function in all the CPUs.
I tried with:
C:
static void print()
{
uprintf("hello world from %d cpu!\r\n", PCPU_GET(cpuid));
}
/* --- */
//call "print" function in all CPUs
smp_rendezvous(NULL, print, NULL, NULL);
But i see only one (randomly) of:
"hello world from 0 cpu!"
"hello world from 1 cpu!"
"hello world from 2 cpu!"
I expected to see it 3 times with different number.
What's wrong?
C:
#include <sys/types.h>
#include <sys/module.h>
#include <sys/systm.h> /* uprintf */
#include <sys/errno.h>
#include <sys/param.h> /* defines used in kernel.h */
#include <sys/kernel.h> /* types used in module initialization */
#include <sys/smp.h>
static void print()
{
uprintf("hello world from %d cpu!\r\n", PCPU_GET(cpuid));
}
static int
skel_loader(struct module *m, int what, void *arg)
{
int err = 0;
switch (what) {
case MOD_LOAD: /* kldload */
smp_rendezvous(NULL, print, NULL, NULL);
uprintf("Skeleton KLD loaded.\n");
break;
case MOD_UNLOAD:
uprintf("Skeleton KLD unloaded.\n");
break;
default:
err = EOPNOTSUPP;
break;
}
return(err);
}
/* Declare this module to the rest of the kernel */
static moduledata_t skel_mod = {
"skel",
skel_loader,
NULL
};
DECLARE_MODULE(skeleton, skel_mod, SI_SUB_KLD, SI_ORDER_ANY);
Thanks.