[Asterisk-Dev] why not disable clock when using multiple Zaptel cards?

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Sun Nov 28 08:49:17 MST 2004


On November 28, 2004 04:23 am, Peter Svensson wrote:
> If there are several digium cards with 1kHz interrupts then maybe only one
> of them should be causing interrupts. The other cards could be serviced
> from within that handler. It does sound a bit tricky.

This is what I'm not getting; why it's tricky.

Say you have an ISR with a list of cards to service.  Normally the list has 
only one entry: the entry for its own card.

Now with two cards installed, the module init code would see the second card, 
disable the timer interrupt on the second and add card 2's address to the 
list of cards to service.

Something like (oversimplified I am sure):

Existing way:
init_card(void *card)
{
 enable_timer(card);
}

process_interrupt(void *card)
{
 process(card);
}



new way:

void *cardlist[MAX_CARDS];
static int n_cards = 0;

init_card(void *card)
{
 cardlist[n_cards++] = card;
 if(n_cards == 1)
  disable_timer(card)
 else
  enable_timer(card);
}

process_interrupt(void **cardlist)
{
 int i;
 void *card;

 for(i=0; i<n_cards; i++)
    {
    card = cardlist[i];
    process(card);
    }
}




More information about the asterisk-dev mailing list