Explicit multi-core C# applications
Asked Answered
T

5

5

Is there any easy way to explicitly make an already threaded application utilise a multicore environment? (if avaliable).

The first problem would be how do I determine if my runtime environment supports multi-core applications?

If I then determine that I can use multi core functionality, can I explicitly assign threads to run on different cores? If so Is the thread communication handled by the OS/Hardware or do I have to get my hands dirty?

Tanya answered 10/10, 2008 at 6:52 Comment(0)
M
11

If your application is already threaded properly, you dont have to do anything. Thread context execution and handling is done for you.

Now when it comes to threading, is your app threaded in a way to utilize the cores? do you have processor intensive tasks split into seperate threads. If not, then you will need to make changes to split up your processing tasks into more threads. You can use Environment.ProcessorCount to get the core count and make as many threads as appropriate at runtime for your tasks.

As of now, there is not really any way to make an improperly threaded app(single thread) into a threaded app taking advantage of all the processors/cores, unless you look to future technologies, such as plinq and Parallel FX

Mortgage answered 10/10, 2008 at 7:0 Comment(0)
C
3

Hi there are 2 extentions that I know about

Parallel C# Homepage

Check out Somasegars MSDN blog on MS June CTP for parallel 3.5 extenstions

MSDN

The library is made up of the following components:

  • The Task Parallel Library (TPL), which provides support for imperative data and task parallelism.
  • Parallel LINQ (PLINQ), which provides support for declarative data parallelism.
  • Coordination Data Structures (CDS), which provide support for work coordination and managing shared state.
Chihli answered 10/10, 2008 at 7:0 Comment(0)
J
1

Currently, you can set the available processors for a given process using Process.ProcessorAffinity, but assigning specific threads to specific processors is handled under the hood implicitly. This is actually a good thing most of the time, as an intelligent runtime using real-time performance and load balance information can usually do a better job than you can statically, at least for the few-core context mainstream multicore operates in.

Jacqulynjactation answered 10/10, 2008 at 7:0 Comment(0)
P
1

That's the problem. How to make a threaded application, how to convert your existing code. I want to exploit multi-core in C#. However, ParallelFX is still beta. I won't develop using a beta. And, I don't want to change all the code again (I translated my apps from VB 6). Today, I received a newsletter from Packt Publishing announcing a new book about parallel programming with C#. C# 2008 and 2005 Threaded Programming. I think it focuses in the things we are blogging about everywhere. How to think and develop a threaded application without waiting for a new miracle language. It's cool to see books entirely dedicated about the topic, because we have full of blogs about that. The link is http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book I think it deserves an apportunity. I'll let you know my feedback when I buy it.

Pegues answered 22/1, 2009 at 10:14 Comment(0)
C
0

Without getting into specifics (I'm not sure how much information is public yet), the next version of the .NET framework will be more helpful with doing this. You will likely not want or need to be thinking about managing threads by hand. I'm sure more information will be public about this after PDC (end of October).

Chancechancel answered 10/10, 2008 at 6:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.