Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kanren3 committed Mar 3, 2024
1 parent 9dd1559 commit b182430
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions _posts/2024-03-03-windows-page-memory-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,49 @@ image:

这个问题的答案很简单,因为系统做过特殊的处理,下面我们直接来看Windows 2003的源码:

![](/assets/2024-03-03-windows-page-memory-access/1.jpg)
![](/assets/2024-03-03-windows-page-memory-access/1.png)

首先系统会调用IoPageRead去磁盘上读取分页内存。

------

![](/assets/2024-03-03-windows-page-memory-access/2.jpg)
![](/assets/2024-03-03-windows-page-memory-access/2.png)

这里我们看到IoPageRead是IopPageReadInternal的包装。

------

![](/assets/2024-03-03-windows-page-memory-access/7.jpg)
![](/assets/2024-03-03-windows-page-memory-access/7.png)

IopPageReadInternal的最后一个参数Async,表示PageRead的过程是异步还是同步,而IoPageRead传入的是FALSE,所以IoPageRead是同步的。

------

![](/assets/2024-03-03-windows-page-memory-access/3.jpg)
![](/assets/2024-03-03-windows-page-memory-access/3.png)

既然有同步,自然也有异步,IoAsynchronousPageRead,两者的区别后面会说。

------

![](/assets/2024-03-03-windows-page-memory-access/4.jpg)
![](/assets/2024-03-03-windows-page-memory-access/4.png)

IopPageReadInternal确实在做I/O操作,根据Async给不同的Flags,这个Flags在I/O Complete的时候会用到。

------

![](/assets/2024-03-03-windows-page-memory-access/5.jpg)
![](/assets/2024-03-03-windows-page-memory-access/5.png)

在IopfCompleteRequest里,找到了我们想要的东西,但是先前传入的Flags无论是同步还是异步,最后所执行的流程是完全一样的,都会去调KeSetEvent做同步处理,等于说IoAsynchronousPageRead和IoPageRead两个函数是没有任何区别的,IoAsynchronousPageRead并不是真的异步操作。

------

![](/assets/2024-03-03-windows-page-memory-access/8.jpg)
![](/assets/2024-03-03-windows-page-memory-access/8.png)

在MiPfExecuteReadList中用到了IoAsynchronousPageRead,但是不够,我们还需要在往上找。

------

![](/assets/2024-03-03-windows-page-memory-access/9.jpg)
![](/assets/2024-03-03-windows-page-memory-access/9.png)

再往上走一层,我们便可以知道为什么叫 **Asynchronous** ,因为它是一个预取列表有多个I/O操作,系统会同时等待全部I/O操作完成,这样性能更好,举个例子:

Expand All @@ -100,7 +100,7 @@ IopPageReadInternal确实在做I/O操作,根据Async给不同的Flags,这个

------

![](/assets/2024-03-03-windows-page-memory-access/6.jpg)
![](/assets/2024-03-03-windows-page-memory-access/6.png)

既然存在IoAsynchronousPageRead,那也存在IoAsynchronousPageWrite,但是和IoAsynchronousPageRead不同的是,IoAsynchronousPageWrite是一个真正的异步操作,使用Special Kernel APC异步调用IopCompletePageWrite来完成I/O操作。

Expand Down

0 comments on commit b182430

Please sign in to comment.