在Mac OS X清除缓冲区高速缓存 [英] clear buffer cache on Mac OS X

查看:479
本文介绍了在Mac OS X清除缓冲区高速缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在C编程清除在Mac上,$ P $缓冲区高速缓存pferrably?

Is there a way to programatically clear the buffer cache on the Mac, preferrably in C?

基本上,我正在寻找的10.5(或以上)源等效的清除命令。 修改我现在看到这是的CHUD工具,它似乎源是不能直接使用的部分。不过,我仍然在寻找一些code做相同的。

Basically, I'm looking for the equivalent of the source of 10.5 (and greater)'s purge command. I now see this is part of the CHUD tools, for which it seems the source isn't directly available. However, I'm still looking for some code to do the same.

推荐答案

我拆开有问题的功能( _utilPurgeDiskBuffers )从CHUD框架。该功能似乎并不很复杂,但因为我不是MacOS的程序员,进口,并呼吁SYS API没有多大意义了我。

I've disassembled the function in question (_utilPurgeDiskBuffers) from the CHUD framework. The function doesn't seem to be very complex, but since I'm no MacOS programmer, the imports and called sys APIs don't make much sense to me.

的API做的第一件事就是打电话给另外一个功能,即 _miscUtilsUserClientConnect_internal 。这个功能似乎建立到CHUD内核扩展的连接。

要做到这一点,它调用 _getCHUDUtilsKextService 它试图通过使用进口 IORegistryCreateIterator 枚举所有的kext找到CHUD内核扩展在I / O套件。该KEXT被发现后,通过 _IOServiceOpen 打开。

The first thing the API does is to call another function, namely _miscUtilsUserClientConnect_internal. This function seems to establish a connection to the CHUD kernel extension.
To do this, it calls _getCHUDUtilsKextService which tries to locate the CHUD kernel extension by enumerating all kexts using the IORegistryCreateIterator imported from the I/O kit. After the kext has been found, it is opened via _IOServiceOpen.

在这一点上,我们必须对CHUD的kext的连接(至少这是从反汇编列表我的理解)。

At this point we have a connection to the CHUD kext (at least that's my understanding from the disassembly listing).

最后一个呼叫 IOConnectMethodStructureIStructureO 处理完毕,我想进行真正的魔术。

如果不知道一些内部的细节或本函数签名的参数没有道理给我。

Finally a call to IOConnectMethodStructureIStructureO is made, which I guess carries out the real magic.
Without knowing some internal details or the signature of this function the parameters don't make sense to me.

这里的拆装,虽然:

__text:4B0157A7 lea     eax, [ebp+var_1C]
__text:4B0157AA mov     dword ptr [esp+14h], 0
__text:4B0157B2 mov     [esp+10h], eax
__text:4B0157B6 mov     [esp+0Ch], eax
__text:4B0157BA mov     dword ptr [esp+8], 0
__text:4B0157C2 mov     dword ptr [esp+4], 0Eh
__text:4B0157CA mov     [esp], edx
__text:4B0157CD call    _IOConnectMethodStructureIStr

注意 var_1C 之前已经清零。

希望你们中的一些可以更有意义掉那些系统调用。如果您想了解更多信息,请让我知道。

Hopefully some of you can make more sense out of those syscalls. If you want more information, let me know.

更新:

为了让您一开始,只取从IO套件SDK中的 AppleSamplePCIClient.c 的例子。这基本上不会从CHUD工具清除应用程序的功能。

你将不得不改变的唯一一件事是参数到最后 _IOConnectMethodStructureIStr 电话。从上面的拆解上市服食。我无法测试所有这些东西,因为我没有一台Mac。

Update:
To get you started, just take the AppleSamplePCIClient.c example from the IO kit SDK. This does basically what the purge application from the CHUD tools does.
The only thing you would have to change are the parameters to the final _IOConnectMethodStructureIStr call. Take them from the disassembly listing above. I cannot test all this stuff since I don't have a Mac.

这篇关于在Mac OS X清除缓冲区高速缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆