Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Mar 2001 18:25:30 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        arch@FreeBSD.org
Subject:   Proposal for the CPU interrupt API
Message-ID:  <XFMail.010315182530.jhb@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
<bikeshed color="green"/

I've got a couple of changes I'd like to make to the rather simple API we have
for maintaining CPU interrupt state.  Currently we have this:

void    disable_intr(void);     - disable interrupts
void    enable_intr(void);      - enable interrupts
u_int   save_intr(void);        - get interrupt state
void    restore_intr(u_int);    - set interrupt state

Typically, interrupts are disabled in the following fashion:

        u_int foo = save_intr();
        disable_intr();
        ...
        restore_intr(foo);

Unfortunately, this can be somewhat expensive on the Alpha, as both
save_intr() and disable_intr() involve a PAL call.  However, the Alpha
returns the previous state whenever you set the interrupt state, which
allows you to only make 1 PAL call.  Thus, I'm proposing to change
disable/enable_intr to return the previous state in addition to setting
the state.  This then removes the need for save_intr(), and
restore_intr() can stay the same.

Another suggestion I've received is to use intrmask_t as the type
for holding interrupt state rather than u_int.

Finally, another suggestion has been to fudge the names some to stick
all of these functions in one intr_* namespace.

The end result of these changes would be this:

intrmask_t      intr_disable(void);
intrmask_t      intr_enable(void);
void    intr_restore(intrmask_t);

and the code above would become this instead:

        intrmask_t foo = intr_disable();
        ...
        intr_restore(foo);

Comments, objections?

/

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.010315182530.jhb>