LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Multiple threads vs Multiple processes (https://www.linuxquestions.org/questions/programming-9/multiple-threads-vs-multiple-processes-322342/)

deveraux83 05-11-2005 07:47 AM

Multiple threads vs Multiple processes
 
I recently covered multi-threading in my Information Engineering course and I was wondering something.

fork() as I know it, creates a new process and hence isn't really "multithreading". And according to my lecturer, swapping processes within the CPU takes much longer than swapping threads. So, what function do you call to create a new thread for the same process?

Also, with regards to a Beowulf cluster. Since only specific clustering software can run on a beowulf cluster, does it require special programming? Or will a multi-threaded program work? I'm asking this because I am planning to build a Beowulf cluster in the future and would like to "future-proof" my current programs.

Thank you for your time.

rstewart 05-11-2005 10:22 AM

Hi,

You can use the pthreads library. The function to create a new thread is:

Code:

        #include <pthread.h>

        int  pthread_create(pthread_t * thread, pthread_attr_t * attr, void * (*start_routine)(void *), void * arg);

Do a google search on pthreads and find a nice site that explains all of the functions in order to read about everything that the library provides. (Or you can man pthread_create and follow all of the "see also" references)


All times are GMT -5. The time now is 05:51 PM.