/* * This module emits "Hello, world" on printk when loaded. * * It is designed to be used for basic evaluation of the module loading * subsystem (for example when validating module signing/verification). It * lacks any extra dependencies, and will not normally be loaded by the * system unless explicitly requested by name. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include #include #include #include struct bigstr { spinlock_t biglock; }; struct bigstr *il; struct hrtimer bigtimer; int release_now; static enum hrtimer_restart bigtimer_handle(struct hrtimer *timer) { printk(KERN_ERR "timer fired 2\n"); spin_lock(&il->biglock); spin_unlock(&il->biglock); release_now = 1; return HRTIMER_NORESTART; } void init_bigstr(struct bigstr *b) { spin_lock_init(&b->biglock); } static int __init test_module_init(void) { struct bigstr b1, b2; struct hrtimer *timer; release_now = 0; init_bigstr(&b1); init_bigstr(&b2); timer = &bigtimer; timer->debug = 1; hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); timer->function = bigtimer_handle; il = &b2; spin_lock(&b1.biglock); printk(KERN_ERR "Starting timer\n"); hrtimer_start(timer, ns_to_ktime(50000ULL), HRTIMER_MODE_REL_PINNED); while(release_now == 0) cpu_relax(); spin_unlock(&b1.biglock); return -1; } module_init(test_module_init); static void __exit test_module_exit(void) { } module_exit(test_module_exit); MODULE_AUTHOR("Joel Fernandes "); MODULE_LICENSE("GPL");