pthreads question

So I've got a programming assignment that just multiplies two matrices together, and stores the result in a third. Supposed to be done using threads, but I have no idea how to start. I understand what a thread is, but I guess I just don't know how to actually use threads when programming. I've hit this wall in my head where I can't even comprehend what's supposed to happen. Any tips?
Maybe have a thread that does the calculations for each column or row of the product matrix.

Edit: Links...
This has pseudo code

These have code

NOTE: I do not know if any of the code in those links will work but either way they should get you in the right direction.
Last edited on
you can use pthreads or if you have a C++11 capable compiler (clang 3.1 later, gcc 4.7.1 later, Visual Studio 2012 etc) then you can use the built in threads of C++11 std.

Here is how threads in C++11 are created

std::thread t1 (thread_function, thread_argument); 
//You can pass multiple arguments to the thread like std::thread t1 (thread_function, int_argument, vector_argumane, object_argument );

//Some code in main thread

t1.join(); //wait for the thread to complete 

You need to #include<thread>. More information here
If you need thread synchronisation (who doesn't?) then look at
ResidentBiscuit, this may be of use:
Ah thanks these links are great! I understand what the program needs to get done, I was just having trouble of actually using the threads. We covered threads in theory but not with how they work at all. Didn't know that you created a thread and passed it a function to perform. Not really sure what I was thinking for how threads worked -_-
I've used the link that Grey Wolf provided for threading before. Absolute gold.
Topic archived. No new replies allowed.