Solved

Multithreading / CPU Cores in .Net

Posted on 2008-10-30
3
348 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
ID: 22839199
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
ID: 22839330
Thx Dhaest: :)
 
0
 
LVL 1

Author Closing Comment

by:AWestEng
ID: 31511578
Thx for all the great examples :)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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:…

713 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