c - Explanation of __do_IRQ function -


i'm preparing presentation on how linux kernel handles interrupts based on book understanding linux kernel ny bovet & cesati. cover says covers version 2.6. however, can't quite figure out how given __do_irq() function supposed work. although i've done (basic) c programming, can't understand of instructions.

    spin_lock(&(irq_desc[irq].lock));     irq_desc[irq].handler->ack(irq);     irq_desc[irq].status &= ~(irq_replay | irq_waiting);     irq_desc[irq].status |= irq_pending;     if (!(irq_desc[irq].status & (irq_disabled | irq_inprogress)) && irq_desc[irq].action){ irq_desc[irq].status |= irq_inprogress;     do{      irq_desc[irq].status &= ~irq_pending;      spin_unlock(&(irq_desc[irq].lock));      handle_irq_event(irq,regs,irq_desc[irq].action);      spin_lock(&(irq_desc[irq].lock));    }while (irq_desc[irq].status & irq_pending);    irq_desc[irq].status &= ~irq_inprogress; }    irq_desc[irq].handler->end(irq);    spin_unlock(&(irq_desc[irq].lock)); 

my questions following:

  1. how assignment of .status work? book says set of flags. flags uppercase variables, how accessed in scenario? shouldn't .status.irq_something or that?

  2. what single "&" mean in condition of if expression?

i'm going answer in reverse order.

the & "bitwise and" operator; | "bitwise or" operator. given integer variable x, expression:

  x |= (1u << n); 

sets bit n of x 1. conversely:

  x &= ~(1u << n); 

clears bit n of x, setting 0.

given understanding of operator, can see how .status field works - integer field, , various flags turned on , off using operators mentioned above. flags checked using & operator:

  irq_desc[irq].status & (irq_disabled | irq_inprogress) 

yields true result when either of irq_disabled or irq_inprogress bits set in .status field.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -