iostat -x -d
可以显示许多I/O统计信息。 对于UTIL的iostat中,解释是:在此期间,I/O请求被发送到设备(频带宽度利用率的装置)如何计算iostat的util?
百分比CPU的时间。当此值接近100%时发生设备饱和
我想知道util是如何计算的?
我做了一个实验(参见下面的代码),启动40个线程来随机读取40个文件。我想磁盘util应该很高,但我错了,iostat是如下,任何人都可以给出为什么? THX
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sdb1 0.01 0.44 0.24 0.57 3.44 8.14 14.34 0.00 2.28 0.66 0.05
代码:
#include <iostream>
#include <fstream>
#include <pthread.h>
using namespace std;
void* work(void* a)
{
int* id = (int*)a;
string file = "sys.partition";
char buf[100];
sprintf(buf, "%d", *id);
file.append(string(buf));
ifstream in(file.c_str());
in.seekg(0, ios_base::end);
size_t len = in.tellg();
cout << "open file : " << file << " , " << len << endl;
srand(time(NULL));
while(true)
{
size_t pos = rand() % len;
in.seekg(pos);
//cout << pos << endl;
in.read(buf, 10);
system("sync");
}
in.close();
}
int main(int argc, char** argv)
{
static const int num = 40;
pthread_t threads[num];
for (int i = 0; i < num; i++) {
pthread_create(&threads[i], NULL, work, &i);
}
for (int i = 0; i < num; i++) {
pthread_join(threads[i], NULL);
}
return 0;
}
格式完全改变,溢出应该改进编辑器。 – Raymond 2010-12-16 06:52:45
溢出救援!改进完成! – zengr 2010-12-16 06:56:18
要么查看@zengr对您的问题所做的更改,要么阅读格式帮助:http://stackoverflow.com/editing-help – 2010-12-16 07:02:44