Click to See Complete Forum and Search --> : CodeWarrior and pthreads
TheBouleOfFools
04-04-2002, 12:59 AM
Well I had recently learned about pthreads and I used them at home while using gcc and they're cool, so I figured I'd incorporate them into some of the programs we do at school. Unfortunatly, we use CodeWarrior, which apparently doesn't have pthread support or something because #include <pthread.h> returned errors (not found :( ). I tried downloading some pthread libraries but to no avail. Does anyone know how I can some type of multithreading stuff to work with CodeWarrior? I tried installing cygwin so I'd have an intelligent environment to work in but it kept crashing (stupid WinNT). Actually, I think I brought the network down from repeated attempts at trying to install cygwin. No really. I just got really frustrated so I did the cygwin install a couple times even though it was gonna fail every time. It eventually go to where non of my programs would start so I rebooted, and when I got back in I couldn't log in at all. I later heard that the next class couldn't log in either :o
Bradmont5
04-04-2002, 02:27 AM
I don't even know if windows supports pthreads...
Danger Fan
04-04-2002, 09:02 AM
Originally posted by Bradmont5:
<STRONG>I don't even know if windows supports pthreads...</STRONG>
it doesn't. windows uses something else. if I find it, I'll post it
Danger Fan
04-04-2002, 09:11 AM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/prothred_86sz.asp
here's what I found in the last 5 minutes. time to work now
TheBouleOfFools
04-04-2002, 09:47 AM
Those look alot more complicated than pthreads :( Why does Microsoft have to make everything so complicated.
Danger Fan
04-04-2002, 11:51 AM
Originally posted by TheBouleOfFools:
<STRONG>Those look alot more complicated than pthreads :( Why does Microsoft have to make everything so complicated.</STRONG>
good question...
Stuka
04-04-2002, 02:46 PM
Because the Win32 API (including the threading) is based on the Win16 API, which was based on DOS, and so you've got a looong legacy of crappy code base....or that's what I think at least...
TheBouleOfFools
04-04-2002, 03:26 PM
Gah I can't even make sense of the example they give you and the guide they made isn't really helpful :(
Energon
04-04-2002, 04:19 PM
CreateThread = pthread_create
EndThread = pthread_exit (I think)
TerminateThread = pthread_join (well, I'm not 100% sure on that one, but I think they do the same thing).
There are also some Mutex functions in the Win32 API that correspond to the pthread mutex functions. You just have to read the documentation to decipher the typedefs in Win32 (and realize that most things are a HANDLE instead of a void* or special type, and that you have to CloseHandle() them) and then it's a fairly easy port from one to the other.
EDIT - it appears something has come back to me. I now remember that it's WaitForSingleObject and WaitForMultipleObjects that you can use similar to pthread_join. It's only when the thread is deadlocked and you can't do anything to stop it that you use TerminateThread. I'm not sure if there's a pthread_cancel equivalent, but if there's one thing you can say about the Win32 API, it's that there's a function for almost every last little thing you can think of, so I'm sure it's in there somewhere.
[ 04 April 2002: Message edited by: Energon ]