hello.c close to the simples module possible, init_module, cleanup_module as with all modules, and start_routine, the actual task, which is only a periodic rtl_printk of a message and any arguments received. After inserting hello.o with insmod, simply execute dmesg, and it will talk to you.
#include <rtl.h>
#include <time.h>
#include <pthread.h>
pthread_t thread;
void * start_routine(void *arg)
{
struct sched_param p;
p . sched_priority = 1;
pthread_setschedparam (pthread_self(),
SCHED_FIFO, &p);
pthread_make_periodic_np (pthread_self(),
gethrtime(), 500000000);
while (1) {
pthread_wait_np ();
rtl_printf("I'm here; my arg is %x\n",
(unsigned) arg);
}
return 0;
}
int init_module(void) {
return pthread_create (&thread, NULL,
start_routine, 0);
}
void cleanup_module(void) {
pthread_delete_np (thread);
}