how can I decide whether my code is running in interrupt context or not?

Perhaps there is, but you'd better describe what you actually want to do. The model of interrupt handling in FreeBSD is much different from the one used in Linux - in Linux, the basic synchronisation primitive is the spinlock, and since spinning in interrupt would be fatal ("Aieee, killing interrupt handler"), one has to know the context to use correct routines - spin_lock/spin_unlock vs. spin_lock_irqsave/spin_unlock_irqrestore. FreeBSD, on the other hand, uses interrupt threads, which fixes this problem altogether - just use mtx_lock/mtx_unlock and ignore the context.
 
Back
Top