954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

hoe to use pthread in c

hi all,

i need to know how to create a thread using pthread_create()?

i have never used pthread in c. am i supposed to used function pointer? how to pass arguments in thread function?

i need to know everything about pthread_create().

and yes i am using turbo c++ compiler and including the header file pthread.h , but i am getting error and it is not getting included.

please help. i need to finish my assignment on multithreading.

Drew.

drewangel
Newbie Poster
8 posts since Feb 2010
Reputation Points: 5
Solved Threads: 0
 

Your compiler does not support threads. You will have to use a modern compiler such as Code::Blocks or VC++ 2008 Express, both are free for the downloading.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

thanks for your reply.

but i want to know the synatx for pthreads. are we supposed to use pointer to functions in that?

drewangel
Newbie Poster
8 posts since Feb 2010
Reputation Points: 5
Solved Threads: 0
 

It is more than just to get the pthread_create() syntax right. How about taking some time and going through pthread tutorial(s)

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

thanks. i really need to go through some tutorial. can you suggest me a good book on pthreads for c?

drewangel
Newbie Poster
8 posts since Feb 2010
Reputation Points: 5
Solved Threads: 0
 

Check out this tutorial.

I have no idea about any books on the subject.

However, several books have been listed in the reference section of the given tutorial

thomas_naveen
Junior Poster
168 posts since Jan 2010
Reputation Points: 136
Solved Threads: 36
 

drewangel : i am using turbo c++ compiler and including the header file pthread.h , but i am getting error and it is not getting included

AncientDragon : Your compiler does not support threads. You will have to use a modern compiler '

drewangel : thanks for your reply. but i want to know the synatx for pthreads. are we supposed to use pointer to functions in that?


my goodness. Reading comprehension, much?

Turbo C does not support multithreading. you will not get a POSIX thread library to work. What part of this are you not able to understand?

.

jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
 

But can we add thread.h header file and library to our compiler like Turbo C++ or dev C++ instead using of advance one??

manjeet593
Newbie Poster
4 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Dev-C++ probably because that is a 32-bit compiler, Turbo C++ no because its only a 16-bit compiler and therefore can not access any of MS-Windows operating system.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I want to make a hoe joke so very badly...

So... nobody brought this up, but libPThread is PRIMARILY a Linux library being "POSIX Threads."
There is a Windows implementation available and can be installed as part of MinGW using it's Get command (i.e. mingw-get, the command line apt-get substitute).

References:
http://en.wikipedia.org/wiki/POSIX_Threads
http://sourceware.org/pthreads-win32/
http://mingw.org

DeanMSands3
Junior Poster
185 posts since Jan 2012
Reputation Points: 37
Solved Threads: 26
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You