* Cpu usage in ada? @ 2002-10-29 15:51 Sim Con 2002-10-29 23:54 ` Karen ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Sim Con @ 2002-10-29 15:51 UTC (permalink / raw) Hello! I need to build a cpu usage meter in ada95 for a windows system. Any help? ^_^ Thanx in advance!! -- Posted via Mailgate.ORG Server - http://www.Mailgate.ORG ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-29 15:51 Cpu usage in ada? Sim Con @ 2002-10-29 23:54 ` Karen 2002-10-30 3:38 ` SteveD 2002-10-30 3:35 ` SteveD 2002-10-30 4:56 ` Ted Dennison 2 siblings, 1 reply; 7+ messages in thread From: Karen @ 2002-10-29 23:54 UTC (permalink / raw) "Sim Con" <sicon@hotmail.com> wrote in message news:b4a38a5f675eb2c7e9430d1b934558a4.110780@mygate.mailgate.org... > Hello! I need to build a cpu usage meter in ada95 for a windows system. > Any help? ^_^ Thanx in advance!! > > > -- > Posted via Mailgate.ORG Server - http://www.Mailgate.ORG You have to make a decision of whether you want to poll (recording which bit of code is running), instrument the entry and exit of routines, or simply absorb the remaining CPU power and to see what is left. Polling is not much good if your code is 'synchronised'. For example a program with a few short lived routines (say < 10ms) triggered on a timer will not even show up on a polling CPU measurement system (such as is available with Windows bundled), as they poll on clock tick boundaries. If the logic is stimulated randomly, then polling can work, but random means data arriving from off machine, and even then you can get beating effects. Building a simple CPU consumer, and forcing it to run low priority is easy enough. Beware, though, of multiple CPU machines - not a problem on windows 98 of course, but it can be for windows 2000 onwards. If you want to instrument (see how many times code is called), you should try some of the free stuff that comes with GNAT (gprof). Its not so great at recording anything other than the main thread, but you can frig it to work on one other thread if you work at it a bit. Good luck! ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-29 23:54 ` Karen @ 2002-10-30 3:38 ` SteveD 2002-10-30 14:24 ` Ted Dennison 0 siblings, 1 reply; 7+ messages in thread From: SteveD @ 2002-10-30 3:38 UTC (permalink / raw) And how exactly do different techniques for profiling have anything to do with monitoring CPU usage? On W2K right click on the task bar, select "Task Manager", then select the "Performance" tab. There is a graph showing CPU usage. I think the original poster was asking how he/she could make their own. SteveD "Karen" <karen.nussbaum@blueyonder.co.uk> wrote in message news:GcFv9.2151$w32.17772596@news-text.cableinet.net... > > "Sim Con" <sicon@hotmail.com> wrote in message > news:b4a38a5f675eb2c7e9430d1b934558a4.110780@mygate.mailgate.org... > > Hello! I need to build a cpu usage meter in ada95 for a windows system. > > Any help? ^_^ Thanx in advance!! > > > > > > -- > > Posted via Mailgate.ORG Server - http://www.Mailgate.ORG > > You have to make a decision of whether you want to poll (recording which bit > of code is running), instrument the entry and exit of routines, or simply > absorb the remaining CPU power and to see what is left. > > Polling is not much good if your code is 'synchronised'. For example a > program with a few short lived routines (say < 10ms) triggered on a timer > will not even show up on a polling CPU measurement system (such as is > available with Windows bundled), as they poll on clock tick boundaries. If > the logic is stimulated randomly, then polling can work, but random means > data arriving from off machine, and even then you can get beating effects. > > Building a simple CPU consumer, and forcing it to run low priority is easy > enough. Beware, though, of multiple CPU machines - not a problem on windows > 98 of course, but it can be for windows 2000 onwards. > > If you want to instrument (see how many times code is called), you should > try some of the free stuff that comes with GNAT (gprof). Its not so great > at recording anything other than the main thread, but you can frig it to > work on one other thread if you work at it a bit. > > Good luck! > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-30 3:38 ` SteveD @ 2002-10-30 14:24 ` Ted Dennison 0 siblings, 0 replies; 7+ messages in thread From: Ted Dennison @ 2002-10-30 14:24 UTC (permalink / raw) "SteveD" <nospam_steved94@attbi.com> wrote in message news:<TuIv9.4129$I_5.3704@rwcrnsc53>... > On W2K right click on the task bar, select "Task Manager", then select the > "Performance" tab. There is a graph showing CPU usage. I think the > original poster was asking how he/she could make their own. That particular app is built using "performance data" from the registry (under HKEY_PERFORMANCE_DATA). But that doesn't work on Win9x OS's (which is why they don't use the same task manager app). The SETI@Home Service has a preliminary binding to this. That's how it gets the list of running processes (so it can shut itself down when a user-designated process is runnning). Adding support for shutting down SETI during heavy CPU activity is on my todo list, but isn't in there yet. I wouldn't be shocked if some of the other windows bindings (Claw?) have support for this too. The only good way to get yourself familiar with this is to dig deeply into MSDN and read up on it. There may be books that cover it well too, but I haven't seen one. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-29 15:51 Cpu usage in ada? Sim Con 2002-10-29 23:54 ` Karen @ 2002-10-30 3:35 ` SteveD 2002-10-30 14:35 ` Ted Dennison 2002-10-30 4:56 ` Ted Dennison 2 siblings, 1 reply; 7+ messages in thread From: SteveD @ 2002-10-30 3:35 UTC (permalink / raw) "Sim Con" <sicon@hotmail.com> wrote in message news:b4a38a5f675eb2c7e9430d1b934558a4.110780@mygate.mailgate.org... > Hello! I need to build a cpu usage meter in ada95 for a windows system. > Any help? ^_^ Thanx in advance!! > This isn't really an Ada question. It is more of a Windows question. I would suggest scouring the Win32 API's to find a function that returns CPU usage information. The closest thing I found with a quick scan is "NdisGetCurrentProcessorCpuUsage". Which is part of the DDK. I hope this helps, SteveD > > -- > Posted via Mailgate.ORG Server - http://www.Mailgate.ORG ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-30 3:35 ` SteveD @ 2002-10-30 14:35 ` Ted Dennison 0 siblings, 0 replies; 7+ messages in thread From: Ted Dennison @ 2002-10-30 14:35 UTC (permalink / raw) "SteveD" <nospam_steved94@attbi.com> wrote in message news:<GrIv9.6803$iW.11642@rwcrnsc52.ops.asp.att.net>... > "Sim Con" <sicon@hotmail.com> wrote in message > news:b4a38a5f675eb2c7e9430d1b934558a4.110780@mygate.mailgate.org... > > Hello! I need to build a cpu usage meter in ada95 for a windows system. > > Any help? ^_^ Thanx in advance!! > > > > This isn't really an Ada question. It is more of a Windows question. I > would suggest scouring the Win32 API's to find a function that returns CPU > usage information. You'd think so, but that would be too easy.... In fact, the right answer depends on what Windoze OS you are using. If I remember correctly, Win9x has an API for it left over from the early non-preemptive Windows days. However, that API is not available in NT based OS's (NT, 2K, and XP). In those OS's, information like the list of running processes and CPU utilization (basicly everything you can get from perfmon) is stored in the registry, of all places. Its in a special virtual key (HKEY_PERFORMANCE_DATA) that doesn't show up in regedt32, and gets updated in realtime. Its also in a special format that has to be parsed in a special way. Isn't that special! :-) And of course this key isn't available to non NT-based OS's. So if you want to write a program that works with both, you have to essentially write your program twice, using two completely different methods and a big "if NT" statement at the top. Thankfully these days you can typically label Win9x systems "legacy" and refuse to support them, but that's a recent development. What's this I hear about Unix being fragmented? :-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Cpu usage in ada? 2002-10-29 15:51 Cpu usage in ada? Sim Con 2002-10-29 23:54 ` Karen 2002-10-30 3:35 ` SteveD @ 2002-10-30 4:56 ` Ted Dennison 2 siblings, 0 replies; 7+ messages in thread From: Ted Dennison @ 2002-10-30 4:56 UTC (permalink / raw) "Sim Con" <sicon@hotmail.com> wrote in message news:<b4a38a5f675eb2c7e9430d1b934558a4.110780@mygate.mailgate.org>... > Hello! I need to build a cpu usage meter in ada95 for a windows system. About 99% of this task is going to be OperatingSystem specific. "Windows" is not good enough, as the different versions and flavors of Windows have completely different ways of giving you this information. To recap, the problems here are: o You didn't specify which version(s) of Windows you need to use. o This isn't really a Windows newsgroup. For example, if you can confine your app to the NT family (including 2K and XP), then you probably want to poll the registry's "performance information". There's a rough Ada binding for that in the SETI@Home Service which you might be able to use, if you want to go that route. But I don't know offhand exactly which keys you need to hit. MSDN is the place to look (at least that's where I went to figure it out). ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-30 14:35 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-10-29 15:51 Cpu usage in ada? Sim Con 2002-10-29 23:54 ` Karen 2002-10-30 3:38 ` SteveD 2002-10-30 14:24 ` Ted Dennison 2002-10-30 3:35 ` SteveD 2002-10-30 14:35 ` Ted Dennison 2002-10-30 4:56 ` Ted Dennison
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox