Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux kernel 旋转锁定irqsave_Linux Kernel_Linux Device Driver - Fatal编程技术网

Linux kernel 旋转锁定irqsave

Linux kernel 旋转锁定irqsave,linux-kernel,linux-device-driver,Linux Kernel,Linux Device Driver,我在单处理器机器上面临自旋锁irqsave的奇怪问题。 我有一段关键代码/函数,名为rx_进程,由两个函数rx_timeout和rx_callback共享。它位于Linux内核驱动程序omap serial.c下 rx_process ( uartNum) { //critical section } rx_timeout (uartNum)//this is called from softIrq context upon timer expiry { rx_process (uar

我在单处理器机器上面临自旋锁irqsave的奇怪问题。 我有一段关键代码/函数,名为rx_进程,由两个函数rx_timeout和rx_callback共享。它位于Linux内核驱动程序omap serial.c下

rx_process ( uartNum)
{
//critical section
}

rx_timeout (uartNum)//this is called from softIrq context upon timer expiry
{ 
   rx_process (uartNum);
}
rx_callback(uartNum)//this is called when interrupt handler registers upon interrupt and when 4k buf is full in rx_process function which invokes start_rx_dma which results in this call back function.
{
   rx_process (uartNum);
}
我发现竞争条件发生在这两个函数之间,因此我决定在函数开始和结束时在rx_进程中引入spin_lock_irqsave,但它仍然会导致竞争条件,有时我会观察到数据丢失和内核死机

rx_process ( uartNum)
{ spin_lock_irqsave(&lock, flags);
 //critical section
 spin_unlock_irqrestore(&lock, flags);
}
rx_timeout (uartNum)//this is called from softIrq context upon timer expiry
{ 
  rx_process (uartNum);
}
rx_callback(uartNum)//this is called when interrupt handler registers upon interrupt and when 4k buf is full in rx_process function which invokes start_rx_dma which results in this call back function
{
 rx_process (uartNum);
}
现在,我将spin_lock_irqsave移动到rx_timeout以及rx_回调函数,我看不到竞争条件

 rx_process ( uartNum)
    { 
     //critical section
     spin_unlock_irqrestore(&lock, flags);
    }
    rx_timeout (uartNum)//this is called from softIrq context upon timer expiry
    { 
      spin_lock_irqsave(&lock, flags);
      rx_process (uartNum);
      spin_unlock_irqrestore(&lock, flags);
    }
    rx_callback(uartNum)//this is called when interrupt handler registers upon interrupt and when 4k buf is full in rx_process function which invokes start_rx_dma which results in this call back function
    {
     spin_lock_irqsave(&lock, flags);
     rx_process (uartNum);
     spin_unlock_irqrestore(&lock, flags);
    }

如果有人能解释为什么rx_过程中使用的自旋锁irqsave失败了,并且没有阻止比赛条件,我将不胜感激

可能有一些代码从另一个上下文访问相同的数据结构,而锁没有覆盖这些数据结构。可能这两种情况都不安全,但不安全的代码往往是混乱的,无意义的更改会导致问题发生或不发生。