Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 22nd, 2007, 4:33 AM   #1
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
No thread.h file?

I was just about to start getting into threading, but when I try to, the compiler doesn't recognize things like THREADID and thread_create. So I figured I had to include a thread header file, but I don't have one that is related to threads. Should I have a thread.h file (or similar), or should my compiler be recognizing the thread things without it?
Writlaus is offline   Reply With Quote
Old Jul 22nd, 2007, 9:43 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Neither.

Anything to do with threading (eg creating threads, executing functions in them, synchronisation between threads) is firmly outside the scope of standard C or C++. Both the C and C++ standards implicitly assume there is only one thread of execution in a program, which means there is no need for any support of multi-threading. There is some discussion in progress about changing that in a future version of those standards.

thread_create() is a POSIX function (i.e. it is described in one of the POSIX [Portable Operating System Interface] family of standards). There is no requirement that a C or C++ compiler will recognise POSIX functions, no requirement that there will be a thread related header file, and no requirement that the library bundled with a compiler will include implementations of POSIX functions.

If you want to use threads, you will need to read the documentation that comes with your compiler and its library. If you're lucky, they will support POSIX functions. If they don't support POSIX functions, they might support some other set of functions that can be used to implement threaded applications. If there is no threading support at all (which is the case for compilers targeting old systems, as threading typically relies on some form of support from an operating system) then you are probably out of luck.
grumpy is offline   Reply With Quote
Old Jul 23rd, 2007, 2:55 AM   #3
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
excellent tutorial on POSIX threads

http://www.llnl.gov/computing/tutorials/pthreads/
rwm is offline   Reply With Quote
Old Jul 23rd, 2007, 6:41 AM   #4
Random-Spirit
Unverified User
 
Join Date: Jul 2007
Location: England
Posts: 22
Rep Power: 0 Random-Spirit is an unknown quantity at this point
If you are on windows there are also the Win32 thread functions, CreateThread, TherminateThread etc. If you use Win32 threads it will not be easy to port your code to a non Win32 platform, so if portability is important or you are not using windows then POSIX threads are the way to go. On MSDN there is plenty of documentation on how to use Win32 threads properly. windows.h includes the prototypes for the Win32 thread functions.
Random-Spirit is offline   Reply With Quote
Old Jul 23rd, 2007, 5:41 PM   #5
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
pthreads sounds like what I want to use, but I don't have pthreads.h either... Can I get that somewhere?
Writlaus is offline   Reply With Quote
Old Jul 23rd, 2007, 6:59 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Writ, you got tons of good responses. Did you bother to Google "pthreads"?? I did, so I'm going to have to guess, "No". Part of being a decent programmer is learning to change your own underwear.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 24th, 2007, 12:28 AM   #7
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
Woah, hold on there. Yes, I did google pthreads, DaWei. Well, more specifically, I googled "pthreads download" (without the quotes). The links that looked promising didn't get me what I was looking for. I found one that I think would have worked, but it was a tar.gz, and to be honest I've never understood what I'm supposed to have to access those types of files. So, after a few dead-ends, I figured I'd just ask if someone knew of a link, since I already had the thread started--I wasn't trying to get people to look for me. I know I ask a lot of questions on here, but I always google first.
Writlaus is offline   Reply With Quote
Old Jul 24th, 2007, 12:51 AM   #8
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
I found a link with the file available. Thanks a ton for the link to the tutorial, it looks like it will be great to start out with.
Writlaus is offline   Reply With Quote
Old Aug 2nd, 2007, 1:11 AM   #9
ShawnStovall
Call me Chuck
 
ShawnStovall's Avatar
 
Join Date: Aug 2007
Location: USA, MI
Posts: 37
Rep Power: 0 ShawnStovall is on a distinguished road
Send a message via AIM to ShawnStovall
Quote:
Originally Posted by Writlaus View Post
Woah, hold on there. Yes, I did google pthreads, DaWei. Well, more specifically, I googled "pthreads download" (without the quotes). The links that looked promising didn't get me what I was looking for. I found one that I think would have worked, but it was a tar.gz, and to be honest I've never understood what I'm supposed to have to access those types of files. So, after a few dead-ends, I figured I'd just ask if someone knew of a link, since I already had the thread started--I wasn't trying to get people to look for me. I know I ask a lot of questions on here, but I always google first.
It is a compressed file type(right?) and I found that I can get access to it by using a decompression program(I personally use 7-Zip). By decompressing it you get a .tar file and you can also use a decompression program to get into that also.
ShawnStovall is offline   Reply With Quote
Old Aug 2nd, 2007, 11:23 AM   #10
peace_of_mind
Professional Programmer
 
peace_of_mind's Avatar
 
Join Date: Sep 2004
Location: Hell if I know most of the time
Posts: 439
Rep Power: 5 peace_of_mind is on a distinguished road
Send a message via MSN to peace_of_mind Send a message via Yahoo to peace_of_mind
He stated he found a link. There's no need to dredge up week old threads to offer a solution to a problem he's already solved.
__________________
Amateurs built the ark
Professionals built the Titanic

peace_of_mind is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem processing file into a char array csrocker101 C++ 1 May 8th, 2007 11:50 PM
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 8:55 AM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 9:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM
Structure char field to a disk file ehab_aziz2001 C++ 0 Feb 10th, 2005 2:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC