Solved

Multithreading / CPU Cores in .Net

Posted on 2008-10-30
3
344 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

16 Experts available now in Live!

Get 1:1 Help Now