Re: coexist with pthread
[email protected] Tue, 21 Mar 2006 09:23:42 +0000
| Newsgroups | gmane.comp.lib.state-threads.user |
|---|---|
| Message-ID | <032120060923.17188.441FC61E00014938000043242202888744089C0A020A09@comcast.net> |
--NextPart_Webmail_9m3u9jl4l_17188_1142933022_0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable General answer is "state-threads can't coexist with pthreads". Note that = there is no such thing as "generic pthreads". POSIX threads is just an AP= I and the implementation is platform-dependent. For example, on Linux 2.4= .* threads are kernel entities and on FreeBSD 4.* pthreads are implemente= d in user-land (libc_r threads are very similar to state-threads so there= is no reason whatsoever to combine them). So the real question is: why would you want to combine different thread m= odels in a single app? -------------- Original message --------------=20 From: "Koji Namekata" <[email protected]>=20 > Hi,=20 >=20 > Is it inherently impossible that state-threads coexist with pthread?=20 > I am trying to execute a test program shown below. Is there anyone to=20 > make a similar attempt?=20 >=20 > -----=20 > Results:=20 >=20 > Linux 2.4.* Linuxthreads: SEGV=20 > FreeBSD 4.* libc_r: Fatal error '_longjmp()ing between thread=20 > contexts is undefined by POSIX 1003.1'=20 > WinXP Cygwin: Runnable(!)=20 >=20 > Program:=20 >=20 > #include=20 > #include=20 > #include=20 >=20 > static void *p_thread(void *arg)=20 > {=20 > while (1) {=20 > printf("child pthread [%p]\n", pthread_self());=20 > sleep(5);=20 > }=20 > return NULL;=20 > }=20 >=20 > static void *s_thread(void *arg)=20 > {=20 > while (1) {=20 > printf("child sthread [%p]\n", st_thread_self());=20 > st_sleep(5);=20 > }=20 > return NULL;=20 > }=20 >=20 > int main(int argc, char *argv[])=20 > {=20 > pthread_t pth;=20 > st_thread_t sth1, sth2;=20 >=20 > pthread_create(&pth, NULL, p_thread, NULL);=20 > printf("parent pthread [%p]\n", pthread_self());=20 >=20 > st_init();=20 > sth1 =3D st_thread_create(s_thread, NULL, 0, 0);=20 > sth2 =3D st_thread_create(s_thread, NULL, 0, 0);=20 > st_sleep(100);=20 > return 0;=20 > }=20 > -----=20 >=20 > Regards,=20 >=20 > --=20 > Koji Namekata=20 >=20 >=20 > -------------------------------------------------------=20 > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang= uage=20 > that extends applications into web and mobile media. Attend the live we= bcast=20 > and join the prime developer group breaking into this new coding territ= ory!=20 > http://sel.as-us.falkag.net/sel?cmdk&kid=110944&bid$1720&dat=121642=20 > _______________________________________________=20 > State-threads-users mailing list=20 > [email protected]=20 > https://lists.sourceforge.net/lists/listinfo/state-threads-users=20 --NextPart_Webmail_9m3u9jl4l_17188_1142933022_0 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <html><body> <DIV> <P>General answer is "state-threads can't coexist with pthreads". Note th= at there is no such thing as "generic pthreads". POSIX threads is just an= API and the implementation is platform-dependent. For example, = ;on Linux 2.4.* threads are kernel entities and on FreeBSD 4.* pthreads a= re implemented in user-land (libc_r threads are very similar to state-thr= eads so there is no reason whatsoever to combine them).</P> <P>So the real question is: why would you want to combine different = thread models in a single app?</P> <P> </P></DIV> <BLOCKQUOTE style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1= 010ff 2px solid">-------------- Original message -------------- <BR>From:= "Koji Namekata" <[email protected]> <BR><BR>> Hi, <BR>> <BR= >> Is it inherently impossible that state-threads coexist with pthread= ? <BR>> I am trying to execute a test program shown below. Is there an= yone to <BR>> make a similar attempt? <BR>> <BR>> ----- <BR>>= Results: <BR>> <BR>> Linux 2.4.* Linuxthreads: SEGV <BR>> FreeB= SD 4.* libc_r: Fatal error '_longjmp()ing between thread <BR>> context= s is undefined by POSIX 1003.1' <BR>> WinXP Cygwin: Runnable(!) <BR>&g= t; <BR>> Program: <BR>> <BR>> #include <STDIO.H><BR>> #includ= e <PTHREAD.H><BR>> #include <ST.H><BR>> <BR>> static void *p_thr= ead(void *arg) <BR>> { <BR>> while (1) { <BR>> printf("child pth= read [%p]\n", pthread_self()); <BR>> sleep(5); <BR>> } <BR>> ret= urn NULL; <BR>> } <BR>> <BR>> static void *s_thread(void *arg) <= BR>> { <BR>> while (1) { <BR>> printf("child sthread [%p]\n", st= _thread_self()); <BR>> st_sleep(5); <BR>> } <BR>> return NULL; <= BR>> } <BR>> <BR>> int main(int argc, char *argv[]) <BR>> { <= BR>> pthread_t pth; <BR>> st_thread_t sth1, sth2; <BR>> <BR>>= pthread_create(&pth, NULL, p_thread, NULL); <BR>> printf("parent = pthread [%p]\n", pthread_self()); <BR>> <BR>> st_init(); <BR>> s= th1 =3D st_thread_create(s_thread, NULL, 0, 0); <BR>> sth2 =3D st_thre= ad_create(s_thread, NULL, 0, 0); <BR>> st_sleep(100); <BR>> return = 0; <BR>> } <BR>> ----- <BR>> <BR>> Regards, <BR>> <BR>>= -- <BR>> Koji Namekata <BR>> <BR>> <BR>> -------------------= ------------------------------------ <BR>> This SF.Net email is sponso= red by xPML, a groundbreaking scripting language <BR>> that extends ap= plications into web and mobile media. Attend the live webcast <BR>> an= d join the prime developer group breaking into this new coding territory!= <BR>> http://sel.as-us.falkag.net/sel?cmdk&kid=110944&bid$172= 0&dat=121642 <BR>> _______________________________________________= <BR>> State-threads-users mailing list <BR>> State-threads-users@l= ists.sourceforge.net <BR>> https://lists.sourceforge.net/lists/listinf= o/state-threads-users </BLOCKQUOTE></body></html> --NextPart_Webmail_9m3u9jl4l_17188_1142933022_0-- ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642