multi core multi threading

Started by
26 comments, last by wodinoneeye 15 years, 11 months ago
How would I go about creating another thread, and, if available, running that thread on another core?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Advertisement
http://msdn.microsoft.com

If you come into the forums with a very stuck up attitude, you will find that you will not get much help.

Both Google and MSDN provide very simplified, broken down, and easy to understand and re-use demonstrations of multithreading; if you are unwilling to do the research required to learn from these very usefull resources, you probably should not be in the industry.
Actually that's not stuck up at all; i'm merely saying I would like someone to walk me through it as opposed to having someone refer me to a website that I could have gone to on my own. It's a waste of a post and it only means you don't know how to do it either. If you do, SHOW me, don't refer me somewhere else and send me on a continued wild goose chase.

I repeat.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
So, what you are saying is you want someone to take time out of their day to show you how to do something when you are apprently willing to put zero effort in yourself to find out how to do it?

News flash; programming is about problem solving. If you aren't willing to do some leg work yourself then you might as well give up now.
ok, now we're on post number 5 and still no solution, amazing

If we're going to get into the logic on people "taking time out of there day" then why is there a forum?!?! Apparently people have NO time at all and have none to spare to help out so why spend it on a forum??

If people have the answer and are willing to share, the great, wonderful, splendid! However, if people are just going to take their time to tell me to search a site which i ALREADY did and found no answer to, then that's just a waste of MY time to read and a waste of their time posting something I already tried.

I thought this was a forum for people to help out? Not one to talk about off topic things like who's wasting who's time asking for help or referring to google, interesting there's enough time in the day for that!
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Yes, this forum is for helpping people however there is such a thing as 'give and take'; all that is asked is that you show what you've done to solve the problem on your own.

Coming in and saying 'show me how to do this' without any evidence of having used your own brain isn't what this is all about.

Anyway, despite your attitude I'll answer the 2nd half of your question as I'm here; threads are automatically scheulded to run on a free core or CPU when it is their turn. How this is done varies from OS to OS.

MSDN holds everything else you need to know about threads on windows.
Quote:Original post by BloodLust666
Actually that's not stuck up at all

True. Stuck up probably isn't the right word (for your post as it is now. I assume you've edited it). It is however, extremely lazy.

Is your time more valuable than ours? Should we spend 5 minutes of our time just to save you the same amount? Why, exactly?

Quote:i'm merely saying I would like someone to walk me through it as opposed to having someone refer me to a website that I could have gone to on my own.

We would all like a lot of things. Personally, I'd quite like someone to give me fifty thousand dollars, for example.

But if you could have looked it up on your own, why didn't you?

Quote:
It's a waste of a post and it only means you don't know how to do it either. If you do, SHOW me, don't refer me somewhere else and send me on a continued wild goose chase.

No, a waste of a post would be where you don't learn anything. The responses you've got above should have taught you much more than you'd have gotten if someone had just done your research for you. And how can it be a "continued wild goose chase"?
- "Continued" implies that you've already been searching for it, doesn't it? That doesn't seem to be the case. Nothing you've said in your posts so far indicate that you've tried to find the information yourself.
- "Wild goose chase" implies that it'd be a waste of time, that you'd never find what you needed. I don't see why that would be the case.


If you have searched for this information, and have been unable to find what you needed, then say so. And if that is the case, I'm sure a lots of people here would be happy to provide you with links to the necessary pages on MSDN (assuming you're working on Windows)

And finally, I suppose it can't hurt to help you out a bit.
You didn't say so, but I assume you're programming in C or C++, and I assume you're working on a Windows platform.
If so, you need to type the following into [Google]:
"windows create thread"

Click on the very first result.
Read that page.
You'll note the following:
1: It describes a function called CreateThread. Hmm, I wonder what that does.
2: Under "Example code", it contains a link named "Creating Threads". That might just have some of what you need.
3: It explains that under some circumstances, you should call a different function instead.

Now, once you've done the above, feel free to ask here if there's something you need clarified. There are plenty of people here who are happy to help beginners out. But it requires the beginner in question to do *some* of the work themselves.
Well first of all.. There are hundreds of different ways to accomplish what you are asking for. Depending on platforms, programming languages, libraries and methods within those libraries.

And secondly... The forums are not here to spoonfeed people. If you need help understanding something that's fine, but outright REFUSING to attempt to solve the problem yourself is just beyond ignorant.
____________________________Bjarni Arnasonbjarni.us
You know, this forum has really gone down hill. People used to be able to come here, ask questions without being harassed with how they ask it, what information they put in it dealing with what they've found before. It was: ask a question, attempt to get a solution, try it out, repeat (something like that). now it's: refer to google (which yes i HAVE already done!), talk about the theory of asking questions and break down my post into how you interpret it. it's bullshit.

I'm not going to even respond to any more crap about the way I asked my question, I'm here for a solution, not a debate about posting in forums!

Thank you phantom for being the only one here to actually give some positive information to get to a solution!

I understand how multi-threading works and concurrency and whatnot. My question is pertaining specifically to _beginthread(). I'm not sure if that, if available, puts the newly created thread on a different core OR if there's another function to do that. (EVERYONE WATCH MY NEXT SENTANCE!!) I've googled around for it and tried MSDN, but no where does it talk about specific code to put in it to that, it just goes into theory of multi-core processing.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Since you didn't say anything, I'm assuming this is for Windows and in C (or C++).

CreateThread and SetThreadAffinityMask.

CreateThread has an example on how to use it. SetThreadAffinityMask is fairly obvious.

Parallel processing is not such a simple topic that it can be well covered in a single post. Expecting people to recreate what has been covered in necessary detail in books is fairly unreasonable. If you cannot figure out how to use it on your own from the references and examples provided in the API, it's highly recommended you read a book on it. It's not something you're likely to get a good understanding of from an online tutorial (or forum post). Actually, even if you do figure out how to use it from the references, I'd still recommend reading a book. There are concerns to parallel code that are not immediately obvious just from looking at an API reference.

Wikipedia has a general introduction to the variety of issues that will come about in parallel coding. You should be able to get a reasonable idea of what to research from there based on your project's goals.

This topic is closed to new replies.

Advertisement