#include <rtl.h>
#include <linux/time.h>
#include <linux/module.h>
#include <pthread.h>

pthread_t thread;
extern int rtl_var_debug;
unsigned int voltes = 0;

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(),5000000000);

	rtl_var_debug = 0;

	while (1) {
		pthread_wait_np ();
		rtl_printf("I'm here; my arg is %x\n", (unsigned) arg);
		voltes++;
		rtl_var_debug++;
	}
	return 0;
}

int init_module(void) {
        printk("start_routine: %x, voltes: %x\n", &start_routine, &voltes);
	return pthread_create (&thread, NULL, start_routine, 0);
}

void cleanup_module(void) {
	pthread_delete_np (thread);
}
