Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-11-2005, 07:47 AM   #1
Registered: Jul 2003
Location: Malaysia
Distribution: Red Hat, Slackware 9.1
Posts: 76

Rep: Reputation: 15
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.
Old 05-11-2005, 10:22 AM   #2
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38

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

        #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)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write multiple threads working simultaneously ? indian Programming 3 09-19-2011 11:41 PM
ftp client that supports multiple threads? touser Linux - Software 2 11-27-2005 09:15 PM
Xmms and Xine multiple threads!?!?? GodSendDeath Slackware 9 08-26-2004 03:10 PM
Multiple Threads excel28 Programming 5 01-06-2004 08:46 PM
how to use multiple nntp threads? bankrupt Linux - Networking 1 12-27-2003 09:49 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration