Process manager monitor capability
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. The "top" command was brought to my attention and I began observing the behavior of the function and noticed that the process information is updated every 5 seconds. The only problem I have with that is -this is most likely from inexperience-wouldn't 5 seconds be too crude of an interval to observe the process scheduling behavior of the kernel in great detail? The only direction I have so far toward solving my problem is to use the libgtop libraries and poll the kernel scheduling portion of the code with a very small interval of time. Any advice or insight into the matter would be greatly appreciated.
Thank You in advance