English 中文(简体)
C++/HCH校对
原标题:Threads ordering in C++/Linux

目前,Im正在C++模拟硬磁盘驱动仪,而Im则使用透镜和磁盘在磁盘上读书。

但 我试图通过订购我的镜来优化阅读时间。 问题在于,我的磁盘目前正在阅读一个部门,而且有人要求阅读,其中的任何内容都将得到执行。 我想要的是命令他们,以便与最接近的部门一道执行请求。

This way, the head of the virtual hard disk drive won t move excessively.

My question is : Is using Linux process priority system a good way to make sure that the closest reading request will be executed before the others? If not, what could I rely on to do this?

PS:为我的办公室提供服务。

感谢您的帮助。

最佳回答

依赖程序优先办法的确切行为,特别是像Ltino这样的一般用途操作系统,是非常鲜有的好的想法,因为它们没有真正保障你的任何具体行为。 如果在记忆中提及某些地址,或一些I/O呼吁立即放弃,那么将获得最高度的优先考虑,那么,操作系统将取代某些较低的优先进程,你将毫不奇怪。

如果你想要确定完成磁盘I/O申请的顺序,或者为了模拟,你可以建立一个线索,保存一份待决的I/O清单,并要求在时间执行请求,以便控制。

问题回答

短链氯化石蜡的I/O表板可以重新排列顺序和编码,读(并在一定程度上写),以便像你所描述的那样,对磁盘更有利。 这影响到处理进度表(也考虑到校对),因为等待I/O的校对也获得“重新排序”——他们的读写要求按磁盘送达的顺序填写,而不是按他们提出请求的顺序填写。 (这非常简单地反映了实际发生的情况。)

但是,如果你重新模拟第I/O号磁盘,即如果你实际上不做真正的I/O,那么I/O的定盘就完全涉及。 只有程序时间表。 而程序时间表人并不认为你重新“模拟”硬盘――它没有关于这些过程的信息,只是关于这些进程是否需要通用报告格式资源的信息。 (这是对事情如何运作的简化观点)。

因此,程序时间表将无助于你重新排列或合并你对阅读请求的模拟。 你需要在你的法典中落实这一逻辑。 (重新制定I/O时间表是一个伟大的想法。)

If you do submit real I/O, then doing the re-ordering yourself could improve performance in some situations, and indeed the I/O scheduler s algorithms for optimizing throughput or latency will affect the way your threads are scheduled (for blocking I/O anyway - asynchronous I/O makes it a bit more complicated still).





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签