virusx wrote:
hi,
What are the best ways of debugging and benchmarking an OS.
For debugging, We can use simple screen printing. Something more useful and advanced.
For benchmarking, we can use two time() functions to get the total time taken by a syscall (say). Some thing more ???
Can we use existing debuggers to debug an os. I tried gdb but segmentation fault. Of course, it tries to run the executable which contains ring 0 operations .
thanks
For noninterruptible system calls there's a simple way to determine how much time they take, and how often they're called. Create an array of those functions, and upon entering the function, you increase the call count by one, and substract the current RDTSC from the time-taken value. Upon exit, you add the current RDTSC to the time-taken value.
After a while, the time taken divided by the call count is going to stabilize, and tells you how long it takes on average. The call count indicates how often it's called in the time stretch you've viewed.
For functions that can block, you could store the current-func-number somewhere, and then when the block-thread funciton is called, you add the current, when it's resumed you substract the current... etc
Note that this is a monolithic technique and very probably isn't translatable to microkernels. Still, for monolithic ones it gives a nice approximation of the call duration and where most of the time is spent.
Using this info you can then draw a graph displaying the amount of time taken in some function in total, and see which functions take most time. Optimize either the function itself or the amount of calls to the function (in functions calling this one). This way, reduce all things that take a significant amount of time. There you go, major speedup.