Solved

Multithreading / CPU Cores in .Net

Posted on 2008-10-30
3
343 Views
Last Modified: 2012-05-05
Hi!

I'm working on a application/applications that consists of several processes and I wonder  how it works with the processes and the CPU cores, can I point a process to a specific core or is the OS that handles all that?

Why I ask is because  some of the processes (exe files) handles heavy math calculations and I like these processes not to work on the same core as the other processes.

I'm don't know how this  process/multithreading works when it comes to how these resources  are handled by the CPU cores, so I need some help to explain this.

Thx guys
0
Comment
Question by:AWestEng
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
Comment Utility
You can take a look at System.Thread.ProcessorAffinity
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity.aspx


ProcessorAffinity has its value documented in MSDN - look at the remarks section. It's a simple bitmask. http://msdn2.microsoft.com/en-us/library/system.diagnostics.processthread.processoraffinity.aspx

IdealProcessor is also documented in MSDN - again look at the remarks section. It appears to be a simple counter (i.e. 1 is processor 1, 2 is processor 2 etc). http://msdn2.microsoft.com/en-us/library/system.diagnostics.processthread.idealprocessor.aspx

An interesting blog about this subject (with examples)
Spike Your CPUs Processor in .Net
http://www.omegacoder.com/?p=94
Determining the number of processors:
 

\\\

Imports System

..

..

..

.... = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS")

///
 

..NET 2.0: 'Environment.ProcessorCount'.

Open in new window

0
 
LVL 1

Author Comment

by:AWestEng
Comment Utility
Thx Dhaest: :)
 
0
 
LVL 1

Author Closing Comment

by:AWestEng
Comment Utility
Thx for all the great examples :)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now