Search code examples
multithreadingmutexsolarisdevice-driveropensolaris

OracleSolaris 11.2 -- getinfo entry point and multi-thread access


I'm at the beginning of implementing a first Solaris device driver. When implementing getinfo entry point routine, do we have to care that this can be called by different kernel threads? Normally this function updates per-instance softstate data structure, and in case of multi-threaded access, the structure has to be protected by mutex.

So my question is if getinfo callback can be invoked by multiple threads of the system, or it's guaranteed by OS that only one thread calls it? The man getinfo isn't very clear about it.

Thanks.


Solution

  • I can't find a clear answer either. I'd recommend being safe and setting up a mutex. You'll spend less time doing that than you would continuing to look for a definitive answer that proves simultaneous calls can't happen (or are always safe).

    Worst case, you cost a millisecond or less for each call. Best case, you've protected yourself from perhaps a kernel panic or corrupt data somewhere. And in either case, you learn a bit more about writing Solaris device drivers.

    This can be a typical problem with Solaris documentation - something like this is probably buried somewhere on some man page, but if you don't know which one to look at you can't find it. (And now now I've answered, just watch: someone who does know where to look will post the definitive answer...)