CPU usage..??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
clavin123
Posts: 23
Joined: Mon Mar 19, 2012 2:01 am

CPU usage..??

Post by clavin123 »

I am making a basic kernel using jamesM tutorial.
So far i have created a file system in main memroy.
Now i would like to calculate the cpu usage and the ram usage. Any idea on how to do this...??
Right now i have a flat memory model...the kernel only executes its main file and does not have multitasking as such i have not implemented paging. There is no deallocation function and the malloc function uses an int type placement address which normally contains the adrress of the end of the kernel. So i am assuming i could use this placement address for ram usage. Would i be correct in doing that..As i am assuming there is a unused stack space at the beginning portion of the memory.
I am using bochs and grub bootloader and for cpu usage calculation i have no idea. Any help on that would be appreciated.
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: CPU usage..??

Post by Rudster816 »

CPU usage isn't really trivial, so you'll have to do some reading:

http://en.wikipedia.org/wiki/Load_(computing)

but for your kernel is probably 100% until your cli hlt sequence, or just always 100% if you end with a for(;;); (which you should switch to a cli hlt to avoid loading up your physical computer's CPU with an infinite loop when running in a VM). It's a useless statistic until you have a kernel that can schedule usermode tasks and run them, it's only at that point can you really begin measuring the CPU overhead of your kernel.

Memory usage is trivial, and it's exactly what you think it is. If you need help beyond that, you'll have to get it from someone else.


I'd also strongly suggesting abandoning any attempt to actually following along with a kernel tutorial. You just end up copying the code, learning nothing, and ending up with someone else's kernel. Tutorials only work if there is only a handful of ways to do something (like setting up Wifi on X router). Tutorials aren't worthless though, because they walk you through working code, which is very scarce in the kernel world. You shouldn't need a complete working example in order to get up and running, otherwise you'll have no idea what to do when there no longer is a 'Next Page' button on the tutorial. When you make very ill informed threads like this one, you're basically asking someone to teach you something that you're trying to teach yourself by reading tutorials.
Post Reply