Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 23, 2004 win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
used dmc to build win32-pthread (http://sources.redhat.com/pthreads-win32/). it compiles and links wihtout problems, however, I get runtime error for a very simple program. I want to use win32-pthread because it is very similar to pthread on unix and my code becomes a LOT more portable (see below). I have a feeling I compiled | linked the pthread library incorrectly that is why I am getting the error. Unfortunately I can not make a smaller test case because it includes the entire pthread library that I built (from the link above). /* This is the error that I got in a popup window. */ unknown has generated errors and will be closed by Windows You will need to restart the program An error log is being created /* hello.c * dmc -I.;c:dminclude -WA -v2 hello.c pthread.lib */ #ifdef(_WIN32) #include "pthread.h" #else /* POSIX-like */ #include <pthread.h> #endif #include <stdio.h> #define NUM_THREADS 5 void *sayhello(void *threadid) { printf("\n%d: Hello World!\n", threadid); pthread_exit(NULL); return; } int main(int argc, char *argv[]) { pthread_t threads[NUM_THREADS]; int rc, t; for(t=0;t<NUM_THREADS;t++){ printf("Creating thread %d\n", t); rc = pthread_create(&threads[t], NULL, sayhello, (void *)t); if (rc){ printf("ERROR; return code from pthread_create() is %d\n", rc); /* exit(-1); */ } } pthread_exit(NULL); } Anuj Goyal |
June 23, 2004 Re: win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anuj Goyal | On which line in the sample app does you application cause the error?
Arjan
Anuj Goyal wrote:
> used dmc to build win32-pthread (http://sources.redhat.com/pthreads-win32/). it
> compiles and links wihtout problems, however, I get runtime error for a very
> simple program. I want to use win32-pthread because it is very similar to
> pthread on unix and my code becomes a LOT more portable (see below). I have a
> feeling I compiled | linked the pthread library incorrectly that is why I am
> getting the error. Unfortunately I can not make a smaller test case because it
> includes the entire pthread library that I built (from the link above).
>
>
> /* This is the error that I got in a popup window. */
>
> unknown has generated errors and will be closed by Windows
> You will need to restart the program
>
> An error log is being created
>
>
>
>
>
> /* hello.c
> * dmc -I.;c:dminclude -WA -v2 hello.c pthread.lib
> */
> #ifdef(_WIN32)
> #include "pthread.h"
> #else /* POSIX-like */
> #include <pthread.h>
> #endif
>
> #include <stdio.h>
>
> #define NUM_THREADS 5
>
> void *sayhello(void *threadid)
> {
> printf("\n%d: Hello World!\n", threadid);
> pthread_exit(NULL);
> return;
> }
>
> int main(int argc, char *argv[])
> {
> pthread_t threads[NUM_THREADS];
> int rc, t;
> for(t=0;t<NUM_THREADS;t++){
> printf("Creating thread %d\n", t);
> rc = pthread_create(&threads[t], NULL, sayhello, (void *)t);
> if (rc){
> printf("ERROR; return code from pthread_create() is %d\n", rc);
> /* exit(-1); */
> }
> }
> pthread_exit(NULL);
>
> }
>
> Anuj Goyal
|
June 23, 2004 Re: win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arjan Knepper | on this line: rc = pthread_create(&threads[t], NULL, sayhello, (void *)t); feel free to contact me off list, I can show you how I compiled the pthread lib/dll. I did the compile,link in one swooop ...did the download from here ftp://sources.redhat.com/pub/pthreads-win32 and get this file ftp://sources.redhat.com/pub/pthreads-win32/pthreads-2004-06-22.exe after unzip, goto the pthreads dir: dmc -I.;c:\dm\include -D_MT -DHAVE_CONFIG_H -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl rem _MT is needed to pick up _beginthread() in c:\dm\include\process.h rem i dunno why wsock32.lib is needed! I read your page: http://www.arjanknepper.com/Programming/C++/C++.html does everything on this page still hold true? MS has a reasonably standards compliant compiler VS.NET 2005 (still slower than digital mars) but I think they are giving away their compiler for free these days (at least VS.NET 2003 is free off the web) I really like dmc, but I wish there were more examples of how to use it. In article <cbbahi$23un$1@digitaldaemon.com>, Arjan Knepper says... > >On which line in the sample app does you application cause the error? > >Arjan > >Anuj Goyal wrote: > >> used dmc to build win32-pthread (http://sources.redhat.com/pthreads-win32/). it compiles and links wihtout problems, however, I get runtime error for a very simple program. I want to use win32-pthread because it is very similar to pthread on unix and my code becomes a LOT more portable (see below). I have a feeling I compiled | linked the pthread library incorrectly that is why I am getting the error. Unfortunately I can not make a smaller test case because it includes the entire pthread library that I built (from the link above). >> >> >> /* This is the error that I got in a popup window. */ >> >> unknown has generated errors and will be closed by Windows You will need to restart the program >> >> An error log is being created >> >> >> >> >> >> /* hello.c >> * dmc -I.;c:dminclude -WA -v2 hello.c pthread.lib >> */ >> #ifdef(_WIN32) >> #include "pthread.h" >> #else /* POSIX-like */ >> #include <pthread.h> >> #endif >> >> #include <stdio.h> >> >> #define NUM_THREADS 5 >> >> void *sayhello(void *threadid) >> { >> printf("\n%d: Hello World!\n", threadid); >> pthread_exit(NULL); >> return; >> } >> >> int main(int argc, char *argv[]) >> { >> pthread_t threads[NUM_THREADS]; >> int rc, t; >> for(t=0;t<NUM_THREADS;t++){ >> printf("Creating thread %d\n", t); >> rc = pthread_create(&threads[t], NULL, sayhello, (void *)t); >> if (rc){ >> printf("ERROR; return code from pthread_create() is %d\n", rc); >> /* exit(-1); */ >> } >> } >> pthread_exit(NULL); >> >> } >> >> Anuj Goyal |
June 24, 2004 Re: win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anuj Goyal | Anuj Goyal wrote: > on this line: > > rc = pthread_create(&threads[t], NULL, sayhello, (void *)t); I quickly glanced over the extracted tree and red a few docs. Are you aware of the fact you have to choose between the several "Exception Handling" methodes? - MS Structured Exception Handling - c++ Exception Handling - c setjmp/longjmp Did you also looked through the config.h file and verified the #defines are also appropriate for DMC? > I read your page: > http://www.arjanknepper.com/Programming/C++/C++.html > > does everything on this page still hold true? No it doesn't the page is a little outdated and it is originally written by my brother Jan. > I really like dmc, but I wish there were more examples of how to use it. What kind of examples are you looking for? |
June 25, 2004 Re: win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arjan Knepper | yup, I choose c setjmp/longjmp and also modified config.h I can post my changes if you are interested, just a few lines. In article <cbe3lc$bml$1@digitaldaemon.com>, Arjan Knepper says... > >Anuj Goyal wrote: >> on this line: >> >> rc = pthread_create(&threads[t], NULL, sayhello, (void *)t); > >I quickly glanced over the extracted tree and red a few docs. >Are you aware of the fact you have to choose between the several >"Exception Handling" methodes? >- MS Structured Exception Handling >- c++ Exception Handling >- c setjmp/longjmp > >Did you also looked through the config.h file and verified the #defines are also appropriate for DMC? > >> I read your page: http://www.arjanknepper.com/Programming/C++/C++.html >> >> does everything on this page still hold true? > >No it doesn't the page is a little outdated and it is originally written by my brother Jan. > >> I really like dmc, but I wish there were more examples of how to use it. > >What kind of examples are you looking for? > |
June 25, 2004 Re: win32 pthread using dmc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anuj Goyal | Anuj Goyal schrieb: > used dmc to build win32-pthread (http://sources.redhat.com/pthreads-win32/). it > compiles and links wihtout problems, however, I get runtime error for a very > simple program. I want to use win32-pthread because it is very similar to > pthread on unix and my code becomes a LOT more portable (see below). I have a > feeling I compiled | linked the pthread library incorrectly that is why I am > getting the error. Unfortunately I can not make a smaller test case because it > includes the entire pthread library that I built (from the link above). [..] > pthread_t threads[NUM_THREADS]; [..] Maybe a problem with the structure alignment. Many library make files specify the structure alignment on the compilers command line instead of using "#pragma pack(..)" in the header files. Had this kind of problems very often with Borland C++ Builder 4 ... especially because the structure alignment in the project files for console and GUI applications are different! Currently, I use GCC only and I'm glad to see that it hasn't a compiler switch for that stuff ... Regards, Mark |
June 26, 2004 Re: win32 pthread using dmc - pthread_dmc.zip | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mark Junker Attachments: | These are the changes I made to config.h (for win32-pthread), I added these lines before the last "#endif" #ifdef __DMC__ /*#define HAVE_SIGSET_T // DMC seems to define sigset_t for M_XENIX and M_UNIX only */ #define HAVE_SIGNAL_H #define HAVE_C_INLINE /*#define HAVE_MODE_T // DMC seems to define mode_t for M_XENIX and M_UNIX only */ #endif //__DMC__ There are some other minor changes as well. I have attached them. (mostly adding or checking for __DMC__) |
June 26, 2004 Re: win32 pthread using dmc - pthread_dmc.zip | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anuj Goyal | Anuj Goyal schrieb:
> These are the changes I made to config.h (for win32-pthread), I added these
> lines before the last "#endif"
Uhm, what I meant was: Was dmc called with an argument like -a1, -a2,
-a4, or -a8.
I currently don't know what the default structure alignment for dmc is,
but it's probably different from what is specified in the arguments.
Regards,
Mark Junker
|
June 26, 2004 Re: win32 pthread using dmc - pthread_dmc.zip | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mark Junker | hmm you're right, I tried compiling with -a8 and still got the same error message after trying it out on my small "hello.exe" (after the relink of course)
structs in the pthread-win32 code.
implement.h (15)
C:\workdmc\pthread>grep "^struct" imp*.h
struct pthread_t_
struct pthread_attr_t_
struct sem_t_
struct pthread_mutex_t_
struct pthread_mutexattr_t_
struct pthread_spinlock_t_
struct pthread_barrier_t_
struct pthread_barrierattr_t_
struct pthread_key_t_
struct ThreadParms
struct pthread_cond_t_
struct pthread_condattr_t_
struct pthread_rwlock_t_
struct pthread_rwlockattr_t_
struct ThreadKeyAssoc
pthread.h (3)
C:\workdmc\pthread>grep "^struct" p*.h
struct timespec {
struct pthread_once_t_
struct ptw32_cleanup_t
sched.h (1) struct sched_param
C:\workdmc\pthread>grep "^struct" sc*.h
struct sched_param {
>Uhm, what I meant was: Was dmc called with an argument like -a1, -a2, -a4, or -a8.
>
>I currently don't know what the default structure alignment for dmc is, but it's probably different from what is specified in the arguments. Mark Junker
|
Copyright © 1999-2021 by the D Language Foundation