Re: non blocking memory allocation api
Re: non blocking memory allocation api
- Subject: Re: non blocking memory allocation api
- From: Brian Bergstrand <email@hidden>
- Date: Thu, 27 Jan 2005 10:09:16 -0600
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
#include <kern/kalloc.h>
kalloc_noblock()
This can (and will) return NULL, so you have to be prepared for that.
In particular it will always fail for allocations larger than 8KB.
You have to match this with a call to kfree(), which can and will
block, and there isn't a noblock version of it. So you cannot release
memory while under a spinlock. kfree() also requires the size of the
memory that you are releasing.
The kalloc functions sit on top of the zalloc functions. Everything
other memory api in the system (IOKit, BSD) uses kalloc, so kalloc can
be called from any driver type.
HTH.
On Jan 27, 2005, at 1:53 AM, Parav Pandit wrote:
> Hi,
> I am seaching for API in IOKit which provides non
> blocking memory allocation functionallity.
> But I think IOkit has only IOMalloc one,
>
> is there any non blocking api available through i can
> allocate memory, when i held the spin lock?
> I searched the xnu code and there was one called
> zalloc_noblock()
> header : /osfmk/kern/zalloc.h
>
> but it uses some zone ...
> is it the one which i should use?
> if yes any idea how to use this zone in the code?
> Can i use it at IOkit driver level?
> any sample availble or this is for xnu kernel only?
>
Brian Bergstrand <http://www.bergstrand.org/brian/>, AIM: triryche206
PGP Key: <http://www.bergstrand.org/brian/misc/public_key.txt>
It is easy to convert a bug to a feature; document it. - The Microsoft
Employee Handbook, p.215, section B, article VII
As of 09:56:07 AM, iTunes is playing "Here To Stay" from "Untouchables"
by "Korn"
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1
iQA/AwUBQfkEKHnR2Fu2x7aiEQK/SgCfQpXmD+z9yEgy4YYDpX8sEPMekUMAnAsG
naAotDW0AXG2+pVhBIBvbeKS
=zf+K
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden