Mac OS X のメモリ管理

  • ドライバも仮想メモリ空間で動作
    • DMA する際とか明示的にアドレス変換が必要
    • TLB cache のクリアコストとかどういう風に設計してるのか
Mac OS X のドライバ色々書いた感想 - kazuhoのメモ置き場

の件、O'Reilly Media - Technology and Business TrainingMac OS X Internals: A Systems Approach を読めるようにしてあったことを思い出したので、確認してみた。

この点については「8.8. Kernel and User Address Space Layouts」にまとまっていて、

Mac OS X does not map the kernel into each user address space, and therefore each user/kernel transition (in either direction) requires an address space switch.

Because of the address space switch (the kernel uses the entire 4GB address space), copy-in/copy-out operations, particularly on small amounts of memory, can be expensive. System calls become expensive as well.

とのこと。ちなみに、copy-in/copy-out ってのは、たとえば read(2) や write(2) の際に、ユーザー空間の仮想メモリカーネル空間の仮想メモリにマップすること。