9.15.2009

Pointer Marshalling in CE 6

就是 這一篇 Windows CE 6 Memory Architecture 的最後一個 section 說的.

CE 6.0 的 memory (addressing space) 管理改變了。
以往 5.0 有 slot 架構,每個 process 佔一個 slot,只有 running process 會switch 到 slot 0。

CE 6.0 沒有 slot,所有 process 都'共用 bottom 2G 的 memory space',但是只有running process 會實際 佔據 memory space。

Kernel 部份, 5.0 和 6.0 一樣,都是佔用 upper 2G space,恆久存在。

這樣的架構,在 user process 和 kernel process 共用 pointer (space) 時會發生問題。
例如 iocontrol 送 pointer 進 kernel driver 處理


雖然 user process 在 call io control 時,他自己一定是在 running state,所以他實際佔有 bottom 2G 的 memory space。
但是萬一在 io control service 中,user process 被 switch 掉了。那麼原來 iocontrol code 拿到的 address 將不再有效(因為 botton 2G 已經換人用了)。

這樣就會發生問題。

所以 6.0 就修改了 mapping user/kernel space 的 方法 (和新function call)。
Manage 的動作就叫 marshalling pointer.
(在MSDN 中可以在很多地方看到這個名字)



其實就是 重新 alloc 一份在 kernel space (所以那一塊 physical memory 被 mapping 到兩個 memory address - 一個在 user space, 一個在 kernel space)。

這樣會佔用 kernel address space,所以 kernel 在'用完' (不再需要 access 那一塊 memory) 時,要呼叫 free? ,釋放掉 kernel address space

這一篇 Memory Marshalling in Windows CE 有圖示的說明。

2 則留言:

Non-human 提到...

這篇的說法, 實際上有點怪怪的, CE5一樣會有這個問題 CE5下的 取得執行權的 APP 會切到 Slot 0, 所以當User space 的App 被切換一樣會有 這個問題 CE5用 MapPtrToProcess/MapCallerPtr 處理這樣的問題

checko 提到...

所以我才在想5.0使用slot 的方式,是不是就是為了這個問題。

嗯,使用 slot 0 Memory Address 也是一樣。