help regarding threads - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help regarding threads

rishabhohririshabhohri Posts: 8Member
hi...i have a problem with threads.actually wat i have been asked to do in the assignment is to make a 3x3 matrix multiplication program in c++ , and show that the every result of the resultant matrix is obtained from a thread..in actual we dont have to implement the problem using actual threads but just to give a simulation of threads...please can anyone suggest me something on how to do this assignment......??

Comments

  • LundinLundin Posts: 3,711Member
    You can't really simulate threads in a good way... you would have to run a function for each calculation, but the execution would still be linear.

    I'd suggest you get x number of 3x3 matrices from somewhere (user input, file etc), then start a calculation for each one of them, then display the result in the main thread.

  • rishabhohririshabhohri Posts: 8Member
    : You can't really simulate threads in a good way... you would have to
    : run a function for each calculation, but the execution would still
    : be linear.
    :
    : I'd suggest you get x number of 3x3 matrices from somewhere (user
    : input, file etc), then start a calculation for each one of them,
    : then display the result in the main thread.
    :
    : ok..Thanks...can u suggest me an algo if i really have to implement it with threads...

  • LundinLundin Posts: 3,711Member
    Just start the threads in a loop and pass the matrix as parameter to the thread function. You shouldn't even need to use mutices/semaphores as the main program shouldn't touch the matrix(es) once it is passed to the threads.

    As for matrix multiplication, I would have to look it up. It has been a while since I studied that. :-)
Sign In or Register to comment.