C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help regarding threads Posted by rishabhohri on 14 Dec 2008 at 1:24 AM
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......??
Report
Re: help regarding threads Posted by Lundin on 14 Dec 2008 at 10:06 AM
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.

Report
Re: help regarding threads Posted by rishabhohri on 15 Dec 2008 at 12:30 AM
: 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...

Report
Re: help regarding threads Posted by Lundin on 15 Dec 2008 at 5:29 AM
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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.