0

I am trying to make a program that can determine how many cores it is using. I think the best way to do this is by checking each core and seeing how much the program is using. I know some programs do a good job with this and will use all cores 100% but some programs are designed for 2 or 4 cores and only use that.

ProcessorAffinity in System.Diagnostics can be changed by the user. I am looking for a way for my program to see 98% usage from chrome on two cores and spit out an int of 2. (I know Chrome doesn't work like that)

Thanks, Josh

  • Your main question is to determine how many core your program is using. You coded it so you know how much. – Franck Jul 03 '18 at 12:30
  • It is to determine how many other programs use. – Joshua Coady Jul 03 '18 at 12:31
  • You can check the processor affinity of each application but that doesn't tell you how much processor they use really. You can have a software programmed as a single process and with all processor affinity. – Franck Jul 03 '18 at 12:36
  • Forgot to add that the single process application setup with all processor affinity may work on all 8 cores but only on 1 at a time. You really really need to read about [context switching](https://en.wikipedia.org/wiki/Context_switch) as you will learn that what you are asking for is really strange as a requirement. I have the feeling that you may have an [XY Problem](https://mywiki.wooledge.org/XyProblem). – Franck Jul 03 '18 at 12:46
  • This requires a concurrency analyzer to do correctly. Building your own is like building a submarine in your basement. Not like it can't be done but its going to be hard to get it up the stairs and if you do then it isn't very likely to stay afloat for long. Use an existing one, like [this one](https://msdn.microsoft.com/en-us/library/dd537632.aspx). – Hans Passant Jul 03 '18 at 12:57
  • Refer this https://stackoverflow.com/questions/5537286/how-to-get-cpu-usage-for-more-than-2-cores and this https://stackoverflow.com/questions/18945029/monitor-a-processs-usage-of-each-cpu-core – Hitesh Anshani Jul 03 '18 at 13:49

0 Answers0