Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.