Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Restriction in Kext




On Aug 23, 2007, at 11:38 AM, JanakiRam wrote:

I'm a newbie to the kernel programming. Can any one clarify my following querie(s).

i) Is there any restriction imposed on the memory to be allocated inside a KEXT and its related functions .

There are several restrictions. They are all pretty generous; if you hit any of them, you have a serious design problem.


ii) If so , Whats the maximum limit ?

There are serveral.

- Kernel stacks are small. Do not allocate large auto variables. Ever.

- Small allocations come from the zone allocator. The zone submap is constrained; the constraint may vary based on the amount of physical memory in the system. It is, fortunately, fairly fast.

- Larger allocations come from the kernel map. You are constrained here by both the available kernel virtual space and the physical memory present in the system, since kernel memory is normally wired down.

iii) Can i allocate 1MB ( i.e. char [1024][1024] ) memory in generic kext start function ?

Yes, although you may want to do this with an IOBufferMemoryDescriptor so that you have the memory pre-wrapped for I/O purposes.


As a general rule, however, if you are allocating large amounts of memory in a driver it's because you think that copying into/out of that memory is a good idea.

Usually, you'll be wrong about that. You should, wherever possible, pursue designs that avoid copying, intermediate buffers, handoff between threads and other such obscenities. 8)

 = Mike

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/email@hidden

This email sent to email@hidden
References: 
 >Memory Restriction in Kext (From: JanakiRam <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.