Here is some beowulf clusters stuff. In here you can find out some about MPI (message passing interface, i think) which is one api you can use to make a paralell program.
The usual way of doing this is to use threads. Several threads of execution can be going at a time in a single program.
Look at the threads library for your compiler and operating system for info on how to use threads.
How to actually write the program is another matter, and depends on what exactly you want it to do. It may not even be a good idea to use multi-threading for certain applications; good multi-threaded programs run faster than single-threaded ones, but bad multi-threaded programs are slower than single-threded ones.
This is, of course, oriented towards using multiple processors in different machines -- I dont know if any of it applies to multiple processors in one machine, but its a start either way.
Thanks for you guys suggestion...but what I'd like to do is how to, for example, I have program which handle two big process...one is calculate...and one is write ..how can I specifically assign the calculation to one cpu and writing to another cpu...
You can't (under any OS I know of) "assign" a thread or process to a certain CPU. All you can do is say to the OS, "Do these two things at the same time if at all possible."
Here's a simple Unix example of what you might want:
[tt]#include <unistd.h>
int main()
{
if ( fork() )
calculator();
else
writer();
return 0;
}
[/tt]
That doesn't use threads, it actually creates two running processes. The fork makes a copy the process and returns 0 in the child process and non-zero (the child's id) to the parent process. So in this case, the parent does the stuff under if, and the child does the stuff under else.
Of course, if your processes need to communicate (like yours seem to), this introduces the problem of interprocess communication... pipes, message queues, semaphores, and all kinds of messy stuff you don't have with threads.
That's why you should look at your documentation and see what kind of thread support you have. Chances are you have POSIX's pthreads. When you find out what you have access to, ask for help here on using the particular thread library you have.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.