Solved

Multithreading / CPU Cores in .Net

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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