标签: interrupt-handling

IRQ编号冲突

来自:http: //software.intel.com/en-us/articles/introduction-to-pc-architecture/

例外号10h对应于"浮点错误",但软件中断10h也对应于"视频支持"BIOS中断(均为实模式).

我错过了什么?

x86 assembly interrupt bios interrupt-handling

3
推荐指数
1
解决办法
634
查看次数

在中断中获取 current->pid

我正在 linux 调度程序上写一些东西,我需要知道在我的中断进来之前哪个进程正在运行..当前的结构是否可用?如果我在中断处理程序中执行 current->pid ,我是否可以获得我中断的进程的 pid?

linux kernel scheduling linux-kernel interrupt-handling

3
推荐指数
1
解决办法
2304
查看次数

工作队列的这些标志是什么意思?

在研究工作队列时,我遇到了内核中定义的工作队列标志和常量。我有以下疑问,我无法理解。

  1. 排水和救援人员在这里到底是什么意思?

    WQ_DRAINING             = 1 << 6, /* internal: workqueue is draining */
    WQ_RESCUER              = 1 << 7, /* internal: workqueue has rescuer */
    
    Run Code Online (Sandbox Code Playgroud)
  2. 为未绑定工作队列定义的 CPU 数量是 4。如果我有一个八核处理器会怎样。无界 wq 将如何绑定到 cpus。他们如何决定运行哪些 CPU,因为他们现在有 8 个 cpu 而不是 4 个 cpu。是这样,它们可以在 8 个或仅 4 个特定 cpu 中的任何一个上运行吗?

    WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */

c scheduled-tasks linux-kernel interrupt-handling workqueue

3
推荐指数
1
解决办法
1542
查看次数

何时使用 thread.interrupt() 以及何时抛出 InterruptedException

我有一些使用Java中断机制来完成我的工作的经验,但目前我不太清楚我应该什么时候设置当前线程的中断状态,什么时候应该抛出InterruptedException?

而且,为了让您更清楚,这里是我之前编写的示例。

这是我开始工作之前的代码:

/*
 * Run a command which locates on a certain remote machine, with the
 * specified timeout in milliseconds.
 * 
 * This method will be invoked by means of
 *     java.util.concurrent.FutureTask
 * which will further submmited to a dedicated
 *     java.util.concurrent.ExecutorService
 */
public void runRemoteSript(String command, long timeout) {
    Process cmd = null;
    try {
        cmd = Runtime.getRuntime().exec(command);

        boolean returnCodeOk = false;
        long endTime = System.currentTimeMillis() + timeout;

        // wait for the command to complete
        while (!returnCodeOk …
Run Code Online (Sandbox Code Playgroud)

java multithreading interrupt-handling

3
推荐指数
1
解决办法
5034
查看次数

检测内核模块中GPIO的中断

我使用Atmel uC将输入切换到BeagleBone上的GPIO线,每500 ms从高到低.我在我的Linux内核模块中为此注册了一个处理程序,但由于某种原因没有调用处理程序.

我的模块代码是 -

#define GPIO 54
#define GPIO_INT_NAME  "gpio_int"

#define GPIO_HIGH gpio_get_value(GPIO)
#define GPIO_LOW (gpio_get_value(GPIO) == 0)
short int irq_any_gpio    = 0;
int count =0;

enum { falling, rising } type; 
static irqreturn_t r_irq_handler(int irq, void *dev_id)
 {
      count++;
    printk(KERN_DEBUG "interrupt received (irq: %d)\n", irq);
        if (irq == gpio_to_irq(GPIO)) 
    {

        type = GPIO_LOW ? falling : rising;

        if(type == falling)
        {
            printk("gpio pin is low\n");    
        }
        else
            printk("gpio pin is high\n");

    }

    return IRQ_HANDLED;
}


void r_int_config(void) { …
Run Code Online (Sandbox Code Playgroud)

linux interrupt linux-device-driver interrupt-handling gpio

3
推荐指数
1
解决办法
2万
查看次数

通过VFIO分配设备的中断处理

我试图了解通过VFIO分配给VM(来宾KVM)的设备的中断处理的工作原理,但是没有任何线索?

假设我有一个通过VFIO直接分配给Guest VM的设备(设备直通),并且该设备有硬件中断吗?

接下来发生什么?

arm kvm linux-device-driver interrupt-handling vfio

3
推荐指数
1
解决办法
1576
查看次数

Linux IRQ处理程序中的固有竞争条件

假设有一个端口映射的I/O设备,它可以在IRQ线上任意产生中断.可以通过outb对特定寄存器的单次调用来清除设备的待处理中断.

此外,假设通过以下方式将跟随中断处理程序分配给相关的IRQ线request_irq:

irqreturn_t handler(int irq, void *data)
{
        /* clear pending IRQ on device */
        outb(0, CLEAR_IRQ_REGISTER_ADDR);

        /* device may generate another IRQ at this point,
         * but this handler function has not yet returned */

        /* signal kernel that IRQ has been handled */
        return IRQ_HANDLED;
}
Run Code Online (Sandbox Code Playgroud)

这个IRQ处理程序中是否存在固有的竞争条件?例如,如果设备在"清除IRQ" outb调用之后但在handler函数返回之前生成另一个中断IRQ_HANDLED,会发生什么?

我可以想到三种情况:

  1. 由于设备和Linux内核之间的死锁,IRQ线冻结并且无法再处理.
  2. handler返回后,Linux内核立即再次执行,以便处理第二个中断.
  3. Linux内核中断handler第二次调用handler.

linux interrupt race-condition linux-kernel interrupt-handling

3
推荐指数
1
解决办法
452
查看次数

在拿着自旋锁时自动不安全返回?

受人尊敬的书籍Linux Driver Development

flags传递给的参数spin_unlock_irqrestore必须是传递给的相同变量spin_lock_irqsave.你还必须打电话spin_lock_irqsavespin_unlock_irqrestore使用相同的功能; 否则你的代码可能会破坏某些架构.

然而,我找不到与内核代码本身捆绑在一起的官方文档所要求的任何此类限制.我发现违反此指南的驱动程序代码.

显然,调用spin_lock_irqsavespin_unlock_irqrestore从单独的函数调用并不是一个好主意,因为你应该在保持锁定的同时最小化完成的工作(禁用中断,不能少!).但是如果对内核进行了更改,那么如果小心翼翼地完成它,它是否真的不会违反API合同,或者它是否仍然禁止这样做?

如果在某些时候删除了限制,它是否适用于版本3.10.17?

linux-device-driver linux-kernel interrupt-handling spinlock

3
推荐指数
1
解决办法
253
查看次数

__even_in_range(UCA0IV,0x08)是什么意思

我从TI的MSP430FR57xx的UART示例代码中找到了这部分。我不明白这__even_in_range(UCA0IV,0x08)是什么意思?

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
    switch(__even_in_range(UCA0IV,0x08))
    {
    case 0:break;                             // Vector 0 - no interrupt
    case 2:                                   // Vector 2 - RXIFG
        while (!(UCA0IFG&UCTXIFG));           // USCI_A0 TX buffer ready?
        UCA0TXBUF = UCA0RXBUF;                // TX -> RXed character
        break;
    case 4:break;                             // Vector 4 - TXIFG
    default: break;
    }
}
Run Code Online (Sandbox Code Playgroud)

msp430 interrupt-handling

3
推荐指数
1
解决办法
768
查看次数

一次中断后,C上的中断处理程序不起作用

我正在尝试使用C和QEMU实现键盘中断处理程序。但是,当我执行程序时,我的处理程序仅打印一个字符。之后,处理程序将根本无法工作。

我的IDT设置:

struct IDT_entry {
    unsigned short int offset_lowerbits;
    unsigned short int selector;
    unsigned char zero;
    unsigned char type_attr;
    unsigned short int offset_higherbits;
};

void setup_idt() {
    struct IDT_entry IDT[256];
    unsigned long keyboard_address;
    unsigned long idt_address;
    unsigned long idt_ptr[2];

    keyboard_address = (unsigned long) keyboard_handler;
    IDT[0x21].offset_lowerbits = keyboard_address & 0xffff;
    IDT[0x21].selector = 0x8;
    IDT[0x21].zero = 0;
    IDT[0x21].type_attr = 0x8e;
    IDT[0x21].offset_higherbits = (keyboard_address & 0xffff0000) >> 16;

    /*
                PIC1   PIC2
    Commands    0x20   0xA0
    Data        0x21   0xA1

    */

    // ICW1 - init
    outb(0x20, …
Run Code Online (Sandbox Code Playgroud)

c assembly gcc osdev interrupt-handling

3
推荐指数
1
解决办法
117
查看次数