模拟文件系统访问 [英] Simulating file system access

查看:135
本文介绍了模拟文件系统访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用户空间设计一个文件系统,需要测试它。我不想使用可用的基准测试工具,因为我的要求不同。所以要测试文件系统我想模拟文件访问操作。为此,我首先使用ftw()函数遍历现有文件系统(实验),并列出文件中的所有文件和目录。然后我调用一个模拟器来模拟许多进程的文件访问。因此,模拟器随机启动一个过程,即它分派一个线程,这个线程完成了真正的过程。线程随机选择文件操作(读取,写入,重命名等)从列表中选择参数(由ftw()生成)。线程执行一些这样的文件操作,然后退出标记进程的结束。模拟器继续产生线程;线程执行可以像实际进程一样重叠。现在,由于线程执行的操作,文件被插入,删除,重命名,并在文件列表中更新。



我还没有开始编码。计划看起来是否理智?我也不知道如何编写模拟器...如何在一段时间内产生线程。我应该使用一些随机延迟来做到这一点。

谢谢 解决方案

这听起来正确的一个体面的测试案例只是为了确保它的工作。您可以使用sleep()在产卵线程之间等待,或者只是一次产生它们,让他们做一个操作,然后等待一下,然后做另一个操作,等等...如果你碰到很多请求,它的工作,那么你的文件系统可能会很好的机会。以PostMark为例,它所做的一切都是疯狂地追加到不同位置的随机读取/写入的不同文件和其他基准,以确保页面必须从磁盘读取。


I am designing a file system in user space and need to test it. I do not want to use the available benchmarking tools as my requirements are different. So to test the file system I wish to simulate file access operation. To do this, I first use the ftw() function to walk through one f my existing file system(experimental) and list all the files and directories in a file.

Then I invoke a simulator to simulate file access by a number of processes. Thus, the simulator randomly starts a process i.e it forks a thread which does what a real process would have done. The thread randomly selects a file operation (read, write, rename etc) selects arguments to this operation from the list(generated by ftw()) . The thread does a number of such file operations and then exits marking the end of a process. The simulator continues to spawn threads; thread execution can overlap just as real processes do. Now, as operations are performed by threads, files get inserted, deleted, renamed and this is updated in the list of files.

I have not yet started coding. Does the plan seem sane? I am also not sure how to code the simulator...how will it spawn threads over a period of time. Should I be using some random delay to do this.

Thanks

解决方案

That sounds about right for a decent test case just to make sure it's working. You could use sleep() to wait between spawning threads or just spawn them all at once and have them do an operation then wait a bit, then do another operation, etc... IMO if you hit it hard with a lot of requests and it works then there's a likely chance your filesystem will do just fine. Take an example from PostMark which all it does is append like crazy to different files and other benchmarks that do random access reads/writes in different locations to make sure that the page has to be read from disk.

这篇关于模拟文件系统访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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