From: Yang Z. <yan...@gm...> - 2009-01-22 16:54:47
|
Mike Abbott wrote: >> I'm interested in as many details as you can spare. > > On 2002-11-26 Gene wrote this: > | I did some digging in the linuxthreads source. I think the > | culprit is in the inlined function thread_self() which is called > | by __errno_location(). That function relies on stack pointer to > | get pthread's identity. The "stack pointer" is just an address > | of a local variable: > | > | #define CURRENT_STACK_FRAME ({ char __csf; &__csf; }) > | char *sp = CURRENT_STACK_FRAME; > | > | In other words, libpthread assumes that there is only one stack > | per each pthread and thus thread id can be inferred from the > | stack pointer. If there are stack segments other than created > | by libpthread, thread_self() may return bogus thread id. > | > | The bottom line, I guess, is that current pthreads implementation > | cannot be mixed with any other thread library. > | > | --Gene > > I remember discussing other issues, in particular a collision on some > special memory location, but I don't recall the details. > > Interop between ST and pthreads comes up repeatedly though, so if you > find a fix we'd love to receive it. > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > State-threads-users mailing list > Sta...@li... > https://lists.sourceforge.net/lists/listinfo/state-threads-users Is ST really incompatible with OS threads? This simple test works, but I've also been writing a real application where I just started mixing pthreads and state-threads, and it seems there are no problems so far, but I'm afraid I'm missing something. Is there an example of something that breaks? (Also, if ST really doesn't work--how does Pth manage to coexist with pthreads?) // Demonstrates ST compatibility with OS threads. #include <iostream> #include <pthread.h> #include <st.h> #include <unistd.h> using namespace std; void *f(void *p) { cout << "hello" << endl; st_sleep(1); cout << "goodbye" << endl; return 0; } void *F(void *p) { cout << "HELLO" << endl; sleep(1); cout << "GOODBYE" << endl; return 0; } int main() { st_init(); st_thread_t t1 = st_thread_create(f, 0, 1, 0); st_thread_t t2 = st_thread_create(f, 0, 1, 0); pthread_t T; pthread_create(&T, NULL, F, 0); st_thread_join(t1, 0); st_thread_join(t2, 0); pthread_join(T, 0); return 0; } -- Yang Zhang http://www.mit.edu/~y_z/ |