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

pthread_t thread;
unsigned int count = 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(),1500000000);
	pthread_make_periodic_np (pthread_self(), gethrtime(), 1000000);

	while (1) {
		pthread_wait_np ();
		count++;
	}
	return 0;
}

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

void cleanup_module(void) {
    	printk("Hello 2: %d loops\n", count);
	pthread_delete_np (thread);
}
