Search code examples
macoskerneldarwinkernel-extensionxnu

What is the effect of sleep and wakeup process on Kernel extension on OSx


I would like to know what is going on during sleep and wakeup process on OSx Kernel.

Does a Kernel extension receive a new address space and start all over again its initialization process or the kernel simply puts the extension back in the same address space?

Does internal kernel extensions (IOKit drivers for example) also behave the same? Perhaps they are loaded into a different location in the memory?

Basically the question is: will my driver, which obtained an interface to a IOService, will be able to use its address after sleep without a problem.


Solution

  • On sleep, memory is "frozen", and on resume, it's restored to its original state. So unless you actively participate in power management, your kext won't notice anything has changed. If you're dealing directly with hardware, you will HAVE to care about power management, though, as your device will have power-cycled and will need to be reinitialised.