zoukankan      html  css  js  c++  java
  • i2c导致内核报错(i2c_transfer)

    在定时器中调用i2c_transfer或者i2c_smbus_read_byte将会导致内核崩溃,c出错内容部分如下:

    WARNING: at kernel/mutex.c:  mutex_trylock   i2c

    原因:i2c_transfer或者i2c_smbus_read_byte都会进行schedule,也就是任务切换,但是若在非进程上下文环境中schedule那么也就必然会导致内核崩溃。改用work queue问题解决。

    ====

    中断下半部执行方法:

    1.tasklet   中断上下文

    使用:

    void my_tasklet_func(unsigned long);

    DECLARE_TASKLET(my_tastlet,my_tasklet_func,data);

    tasklet_schedule(&my_tasklet);

    2.work queue   处于进程上下文

    使用:

    #include <linux/workqueue.h>

    struct work_struct my_wq;

    void my_wq_func(struct work_struct *work);

    INIT_WORK(&my_wq,my_wq_func);

    schedule_work(&my_wq);

    3.软中断    中断上下文

    4.timerlist  中断上下文

    struct timer_list timer_my;

    void timer_func(unsigned long arg){};

    init_timer(&timer_my);

    timer_my.function = timer_func;

    timer_my.expires = jiffies + delay;
    add_timer(&timer_my); 

    mod_timer(&timer_my, jiffies + delay);

    del_timer(&timer_my);

  • 相关阅读:
    iptables防火墙-SNAT和DNAT
    exists & in
    系统演化之路
    promethue 采集traefik指标列表
    Grafana中变量
    Wireshark抓包
    http协议格式 基于ABNF语义定义
    Prometheus 管理常用知识点
    python时间转换
    通过salt-api获取minion的ip地址
  • 原文地址:https://www.cnblogs.com/leaven/p/1845967.html
Copyright © 2011-2022 走看看