Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <linux/module.h>
- #include <linux/timer.h>
- static struct timer_list timer;
- static __u8 liczba_max_aktywacji = 10;
- static __u8 obecna_aktywacja = 0;
- static __u8 opoznienie = 2;
- static void timer_handler(unsigned long int data) {
- pr_info("Licznik %lu obecna aktywacja %d \n", data, ++obecna_aktywacja);
- if (obecna_aktywacja < liczba_max_aktywacji) {
- timer.expires = jiffies + opoznienie*HZ;
- add_timer(&timer);
- }
- }
- static int __init module_constructor(void) {
- init_timer(&timer);
- timer.data = 1;
- timer.function = timer_handler;
- timer.expires = jiffies + opoznienie*HZ;
- add_timer(&timer);
- return 0;
- }
- static void __exit module_destructor(void) {
- if (del_timer_sync(&timer)) {
- pr_notice("Timer was not active\n");
- }
- }
- module_init(module_constructor);
- module_exit(module_destructor);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("Piotr Zieba, Karol Wrona");
- MODULE_VERSION("1.0");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement