Hi all,
I need allocate memory in kernel, I have gone through the forums, got lot of information, but I need some more clarification.
I am going to implement hash table that stores file paths. As our driver is a virtual I/O kit driver, we are planning to use IOMalloc for this purpose. I have following questions regarding memory allocation in kernel:
As mentioned about IOMalloc "This function may block and so should not be called from interrupt level or while a simple lock is held".
As explained http://lists.apple.com/archives/darwin-dev/2007/May/msg00039.html
This means the only location where we are not allowed to call this function is "directly via an interrupt handler (primary interrupt)" & this is required only in case of Hardware device driver.
Can we use IOMalloc in a virtual IOKit driver.
I have gone through http://lists.apple.com/archives/darwin-drivers/2007/Jul/msg00055.html
As seen they have internally used locking like lock_zone & vm_map_lock in kmem_alloc.
Does it means that I need not make my calls to IOMalloc thread safe ?
As mentioned in the article http://developer.apple.com/library/mac/#qa/qa1197/_index.html
"The kernel zalloc pool is of a limited fixed size and is shared by all code running in the kernel. If your code makes heavy use of IOMalloc, it is possible to exhaust this pool and panic the kernel."
What is the limitation of IOMalloc in terms of size ? If we need memory more than 16 MB then do we need to to use IOBufferMemoryDescriptor?
- What care should we take to avoid fragmentation?
Thanks & Regards,
Sheetal.