Hello everybody, I'm finishing a degree in computer science :stud, and my final project is a module in freebsd, is the first time I'm working with KLD on freebsd and I need help.
I'm using an example of kld, and it would like to know how to use kernel_threads, how to put the thread to run on the following function kt_log_rw_arq, when KLD load;
I'm using an example of kld, and it would like to know how to use kernel_threads, how to put the thread to run on the following function kt_log_rw_arq, when KLD load;
Code:
#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/kthread.h>
static void kt_log_rw_arq(void* data)
{
printf("In thread\n");
}
static int load(struct module *module, int cmd, void *arg)
{
int error=0;
switch(cmd)
{
case MOD_LOAD:
uprintf("KT_LOG Carregada\n");
//kthread_create(kt_log_rw_arq,NULL)
kt_log_rw_arq(NULL)
break;
case MOD_UNLOAD:
uprintf("KT_LOG Descarregada\n");
break;
default:
error=EOPNOTSUPP;
break;
}
return (error);
}
static moduledata_t kt_log_module_data =
{
"kt_log", // nome do modulo //
load, // Event Handler //
NULL // Extra Data //
};
DECLARE_MODULE(kt_log, kt_log_module_data, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);