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&nbsp;the implementation is platform-dependent. For example,&nbsp=
;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&nbsp;would you want to combine different =
thread models in&nbsp;a single app?</P>
<P>&nbsp;</P></DIV>
<BLOCKQUOTE style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1=
010ff 2px solid">-------------- Original message -------------- <BR>From:=
 "Koji Namekata" &lt;[email protected]&gt; <BR><BR>&gt; Hi, <BR>&gt; <BR=
>&gt; Is it inherently impossible that state-threads coexist with pthread=
? <BR>&gt; I am trying to execute a test program shown below. Is there an=
yone to <BR>&gt; make a similar attempt? <BR>&gt; <BR>&gt; ----- <BR>&gt;=
 Results: <BR>&gt; <BR>&gt; Linux 2.4.* Linuxthreads: SEGV <BR>&gt; FreeB=
SD 4.* libc_r: Fatal error '_longjmp()ing between thread <BR>&gt; context=
s is undefined by POSIX 1003.1' <BR>&gt; WinXP Cygwin: Runnable(!) <BR>&g=
t; <BR>&gt; Program: <BR>&gt; <BR>&gt; #include <STDIO.H><BR>&gt; #includ=
e <PTHREAD.H><BR>&gt; #include <ST.H><BR>&gt; <BR>&gt; static void *p_thr=
ead(void *arg) <BR>&gt; { <BR>&gt; while (1) { <BR>&gt; printf("child pth=
read [%p]\n", pthread_self()); <BR>&gt; sleep(5); <BR>&gt; } <BR>&gt; ret=
urn NULL; <BR>&gt; } <BR>&gt; <BR>&gt; static void *s_thread(void *arg) <=
BR>&gt; { <BR>&gt; while (1) { <BR>&gt; printf("child sthread [%p]\n", st=
_thread_self()); <BR>&gt; st_sleep(5); <BR>&gt; } <BR>&gt; return NULL; <=
BR>&gt; } <BR>&gt; <BR>&gt; int main(int argc, char *argv[]) <BR>&gt; { <=
BR>&gt; pthread_t pth; <BR>&gt; st_thread_t sth1, sth2; <BR>&gt; <BR>&gt;=
 pthread_create(&amp;pth, NULL, p_thread, NULL); <BR>&gt; printf("parent =
pthread [%p]\n", pthread_self()); <BR>&gt; <BR>&gt; st_init(); <BR>&gt; s=
th1 =3D st_thread_create(s_thread, NULL, 0, 0); <BR>&gt; sth2 =3D st_thre=
ad_create(s_thread, NULL, 0, 0); <BR>&gt; st_sleep(100); <BR>&gt; return =
0; <BR>&gt; } <BR>&gt; ----- <BR>&gt; <BR>&gt; Regards, <BR>&gt; <BR>&gt;=
 -- <BR>&gt; Koji Namekata <BR>&gt; <BR>&gt; <BR>&gt; -------------------=
------------------------------------ <BR>&gt; This SF.Net email is sponso=
red by xPML, a groundbreaking scripting language <BR>&gt; that extends ap=
plications into web and mobile media. Attend the live webcast <BR>&gt; an=
d join the prime developer group breaking into this new coding territory!=
 <BR>&gt; http://sel.as-us.falkag.net/sel?cmdk&amp;kid=110944&amp;bid$172=
0&amp;dat=121642 <BR>&gt; _______________________________________________=
 <BR>&gt; State-threads-users mailing list <BR>&gt; State-threads-users@l=
ists.sourceforge.net <BR>&gt; 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