Skip to contentSkip to conversation

DISCUSSION Kevin Leung 2 participants 2 messages Mar 15, 2004

lore
Share & tools
lore
#0 lore raw

Hello All,

I am very new to Linux and am working on a project. The nature of the project is to essentially record all process/thread scheduling activity for use in a later application. I wanted to know if any experts out there knew of any libraries that could essentially "monitor" or "listen" for any scheduling changes made. For instance if the kernel decides to set process A from "sleeping" to "running" and process B from "running" to "sleeping", I wanted to know if there was a function that could generate an immediate notification of this event. Priority change information is also desireable. The more aspects which trigger notificaiton, the better. As a first attempt, I tried understanding the source code of the system monitor application. I gained some insight, but still have questions. Mainly questions pertaining to how the system monitor application receives the most "up-to-the-minute" information on what process are running, what processes are sleeping etc. I got stuck in the code and decided to explore another means. Any advice or insight into the matter would be greatly appreciated. If a library isn't available, does anyone know the difficulty involved if I tried to modify the kernel to provide this information?

Please CC me the comments and responses posted to the list in response to my posting

Thank You in advance

_________________________________________________________________
Frustrated with dial-up? Lightning-fast Internet access for as low as $29.95/month. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/

#1 lore raw

Re: your mail

Quoted 10 lines · Kevin Leung

Hello All,

I am very new to Linux and am working on a project. The nature of the project is to essentially record all process/thread scheduling activity for use in a later application. I wanted to know if any experts out there knew of any libraries that could essentially "monitor" or "listen" for any scheduling changes made. For instance if the kernel decides to set process A from "sleeping" to "running" and process B from "running" to "sleeping", I wanted to know if there was a function that could generate an immediate notification of this event.

No. FYI, there are hundreds-of-thousands of such "events" per second of operation! Basically, any time some task is waiting for I/O its CPU is taken away and given to somebody else. This is what "sleeping" usually means. Once the I/O completes, the task gets the CPU again and that's what "running" means. If you were to instrument these two state-changes for all tasks, it would certainly leave only a new percent of CPU available for the tasks. This would royally screw up the meaning of anything you were trying to instrument.

Quoted 1 line

Priority change information is also desireable.

If you mean the dynamic priority that keeps changing until the task is executed, no. If you mean priority like 'nice', you can instrument the sys-call.

Quoted 1 line

The more aspects which trigger notificaiton, the better. As a first attempt,

There is a kernel logging daemon that writes 'printk' messages. This works by having a user-mode daemon open and read /proc/kmsg. You can make a similar communications interface, using the existing daemon as a template, that will instrument anything you want.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.