# protect common resources in kernel



## choupani (Dec 2, 2012)

Dears,
I'm working on kernel in FreeBSD-9. I need to protect a common resource (for example a queue). There are 4 points for access (read/write) this common resource as bellows:

    1. ether_input() â€“ hardware interrupt
    2. ip_input() & ip_output() â€“ software interrupt
    3. dev_ioctl() â€“ local io control in our own kernel module
    4. another kernel thread

Which scenario is proper to use for this purpose:

    1. kernel mutex (MTX_DEF)
    2. kernel mutex (MTX_SPIN)
    3. kernel share/exclusive lock
    4. kernel reader/writer lock


----------

