KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it safe to use lseek(fd,0) and then read(fd,buf) for /proc/stat file instead of reopening it to get updated contents of this file next time? And what does the mmap() call after opening this file really do (see below)? The problem I am encountering is that top reports way too low CPU usage (10% vs 100% for software interrupts). The strace tool indicates that top does not reopen this file but instead lseeks to beginning and reads it once again. And somehow the contents which are read from this file next time does not match with what I would get when I run cat for /proc/stat file alone. Also If I run top and cat /proc/stat in a loop at the same time then top starts to report correct CPU-Usage. One more difference I spot is that top uses mmap() call right after opening the /proc/stat file, while cat does not do that. I am not sure if this also could be related with my problem (because filesdes=-1 here): mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7b37649000 I am using Ubuntu 10.04.1 Desktop edition with 2.6.32-27-server image. The CPU is Intel Q6600.
Tags (comma-separated)
Save Edits
Cancel