threads/75273: FBSD 5.3 libpthread (KSE) bug

Enoch W. ixew at hotmail.com
Tue Dec 21 20:30:35 PST 2004


The following reply was made to PR threads/75273; it has been noted by GNATS.

From: "Enoch W." <ixew at hotmail.com>
To: <freebsd-gnats-submit at FreeBSD.org>, <ixew at hotmail.com>
Cc:  
Subject: Re: threads/75273: FBSD 5.3  libpthread (KSE) bug
Date: Tue, 21 Dec 2004 23:26:28 -0500

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0002_01C4E7B4.7F0A0870
 Content-Type: multipart/alternative;
 	boundary="----=_NextPart_001_0003_01C4E7B4.7F0B8F10"
 
 
 ------=_NextPart_001_0003_01C4E7B4.7F0B8F10
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 Problem demo is attached, as requested. TIA, Enoch.
 ------=_NextPart_001_0003_01C4E7B4.7F0B8F10
 Content-Type: text/html;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML><HEAD>
 <META http-equiv=3DContent-Type content=3D"text/html; =
 charset=3Diso-8859-1">
 <META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
 <STYLE></STYLE>
 </HEAD>
 <BODY bgColor=3D#ffffff>
 <DIV><FONT face=3DArial size=3D2>Problem demo is attached, as requested. =
 TIA,=20
 Enoch.</FONT></DIV></BODY></HTML>
 
 ------=_NextPart_001_0003_01C4E7B4.7F0B8F10--
 
 ------=_NextPart_000_0002_01C4E7B4.7F0A0870
 Content-Type: application/octet-stream;
 	name="demo.c"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="demo.c"
 
 #include <stdio.h>=0A=
 #include <stdlib.h>=0A=
 #include <string.h>=0A=
 #include <signal.h>=0A=
 #include <errno.h>=0A=
 #include <pthread.h>=0A=
 =0A=
 #define ASSRET(cond) do { \=0A=
   if (!(cond)) { \=0A=
     fprintf(stderr,  "ASSRET ERROR @ %d -> %s\n", __LINE__, \=0A=
 	    strerror(ret =3D=3D -1 ? errno : ret)); \=0A=
     exit(EXIT_FAILURE); \=0A=
   } \=0A=
 } while (0)=0A=
 =0A=
 int tock;=0A=
 =0A=
 void tick()=0A=
 {=0A=
   tock =3D 1;=0A=
 }=0A=
 =0A=
 void *pulse(void *arg)=0A=
 {=0A=
   int ret;=0A=
   struct itimerval it;=0A=
   sigset_t set;=0A=
 =0A=
   sigemptyset(&set);=0A=
   sigaddset(&set, SIGALRM);=0A=
   ret =3D sigprocmask(SIG_BLOCK, &set, NULL);=0A=
   ASSRET(ret =3D=3D 0);=0A=
   sigemptyset(&set);=0A=
 =0A=
   it.it_interval.tv_sec =3D 1;=0A=
   it.it_interval.tv_usec =3D 0;=0A=
   it.it_value.tv_sec =3D 1;=0A=
   it.it_value.tv_usec =3D 0;=0A=
   ret =3D setitimer(ITIMER_REAL, &it, NULL);=0A=
   ASSRET(ret =3D=3D 0);=0A=
 =0A=
   while (1) {=0A=
     while (!tock)=0A=
       sigsuspend(&set);=0A=
     tock =3D 0;=0A=
     putchar('*');=0A=
     fflush(stdout);=0A=
   }=0A=
 }=0A=
 =0A=
 int main()=0A=
 {=0A=
   int ret;=0A=
   pthread_attr_t attr;=0A=
   pthread_t thread;=0A=
 =0A=
   ret =3D pthread_attr_init(&attr);=0A=
   ASSRET(ret =3D=3D 0);=0A=
   ret =3D pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);=0A=
   ASSRET(ret =3D=3D 0);=0A=
 =0A=
   signal(SIGALRM, tick);=0A=
 =0A=
   ret =3D pthread_create(&thread, NULL, pulse, NULL);=0A=
   ASSRET(ret =3D=3D 0);=0A=
 =0A=
   printf("Press Enter to cancel the pulse() thread\n");=0A=
   while (getchar() !=3D '\n');=0A=
 =0A=
   ret =3D pthread_cancel(thread);=0A=
   ASSRET(ret =3D=3D 0);=0A=
   ret =3D pthread_join(thread, NULL);=0A=
   ASSRET(ret =3D=3D 0);=0A=
 =0A=
   printf("Press Enter to end\n");=0A=
   while (getchar() !=3D '\n');=0A=
   return 0;=0A=
 }=0A=
 
 ------=_NextPart_000_0002_01C4E7B4.7F0A0870
 Content-Type: application/octet-stream;
 	name="demo.mk"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="demo.mk"
 
 demo: demo.c=0A=
 	$(CC) -Wall -g -odemo -pthread demo.c=0A=
 
 ------=_NextPart_000_0002_01C4E7B4.7F0A0870--


More information about the freebsd-threads mailing list