site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On May 9, 2007, at 5:03 AM, darwin-dev-request@lists.apple.com wrote: the answer to this is probably easy to find in the right place, but is there a memory allocation routine that is interrupt safe? From the documentation for IOMalloc it is clear that it is not, so is there a function that is? Or would I have to allocate all my memory prior to going into interrupt context? There are two separate things to consider here. = Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... First; you should go to great lengths to avoid allocating memory on any I/O path. A couple of good ideas: - Keep a pre-allocated pool of your work structures; consider subclassing IOCommand and use an IOCommandPool. If the pool is empty when new work arrives, it's OK to block and better to block up front than halfway into your setup when an allocation fails and you've run the kernel out of address space. - Avoid using buffers for your data. You don't want to copy data anyway, so this will tend to improve the performance of your driver as a side effect. Use scatter/gather lists rather. Second; unless you are using an IOFilterInterruptEventSource, you are not running any code in interrupt context. IOInterruptEventSource handlers run in "regular" thread context. You can (but per the above, should not make a habit of) allocate memory in the latter. This email sent to site_archiver@lists.apple.com