LINUX核心tasklet小任務機制

來源:互聯網
上載者:User

標籤:

    在核心中的中斷機制中,為了防止解決中斷嵌套(防止一個中斷打斷另一個中斷)的問題,引進小任務機制:

      使用小任務機制需要三步:

        第一:定義一個struct tasklet_struct的類;

        第二步:初始化taskelet將處理任務的函數和takslet任務捆綁;

        第三步:調度tasklet :tasklet_schedule(&tasklet);

 

    

 12 #include <linux/delay.h> 13 #include <linux/clk.h> 14 #include <linux/miscdevice.h> 15 #include <linux/io.h> 16 #include <linux/ioport.h> 17 #include <asm/uaccess.h> 18  19 #include <linux/gpio.h> 20 #include <mach/gpio.h> 21 #include <plat/gpio-cfg.h> 22  23 MODULE_LICENSE("GPL"); 24 MODULE_AUTHOR("bunfly"); 25  26 void my_tasklet_func(unsigned long data); 27 struct tasklet_struct  my_tasklet; 28  29 int test_init() 30 { 31     printk("hello kernel\n"); 32     tasklet_init(&my_tasklet,my_tasklet_func, 0); 33     tasklet_schedule(&my_tasklet); 34     return 0; 35 } 36  37 void test_exit() 38 { 39     tasklet_kill(&my_tasklet); 40     printk("exit\n"); 41 } 42  43 module_init(test_init); 44 module_exit(test_exit); 45  46 void my_tasklet_func(unsigned long data) 47 { 48     printk("wang wang wang\n"); 49 } 50 

 

LINUX核心tasklet小任務機制

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.