Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com List-Subscribe: List-Archive: List-Post: List-Help: , Delivered-To: mailing list cygwin-apps AT sources DOT redhat DOT com Message-ID: <05ec01c0ae25$41f98b30$0200a8c0@lifelesswks> From: "Robert Collins" To: Cc: "Corinna Vinschen" References: <044501c0adda$0e19c6e0$0200a8c0 AT lifelesswks> <20010316094740 DOT F19468 AT cygbert DOT vinschen DOT de> <04ae01c0adfa$1101be10$0200a8c0 AT lifelesswks> <3AB218BC DOT 90356B48 AT yahoo DOT com> Subject: Re: pthread_cond* Date: Sat, 17 Mar 2001 01:27:35 +1100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_05E7_01C0AE81.7236EBB0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-OriginalArrivalTime: 16 Mar 2001 14:21:50.0565 (UTC) FILETIME=[71154950:01C0AE24] This is a multi-part message in MIME format. ------=_NextPart_000_05E7_01C0AE81.7236EBB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit ----- Original Message ----- From: "Earnie Boyd" > Robert Collins wrote: > > > > its /usr, and they are going into /usr/i686-pc-cygwin/include. How do > > you cygwin maintainers get the snapshots to install into /usr/include ? > > Or is it safest to just copy pthreads.h (the only one I've changed to > > date) to /usr/include? > > > > Chris has a script. I never install directly into /usr. I ``make > install prefix=`pwd`/nstl'' and then move the contents, and create a > tarball to install. Remember, you can't replace the cygwin1.dll when > you're executing a Cygwin application. Thanks. > > Earnie. > > P.S.: This thread is on the wrong list. You should move it to > cygwin-developers AT cygwin DOT com. The cygwin-apps list is to discuss > changes to applications that use the Cygwin runtime. The > cygwin-developers is to be used for discussing the development of the > cygwin runtime itself. > Yes, But. A) The list is approval-only, and B) I've finished the work (Patch send to cygwin-patches just now.) So I'm happy to move this thread to cygwin-developers, but please don't subscribe me - just CC me (unless I become a regular cygwin contributor, I simply don't need any additional mail in my mailbox). I thought this list would be a little more receptive and tolerant of slightly off-topic posts than the main cygwin list (where this would be 100% noise). For those who are interested the patch has this ChangeLog Changelog: Saturday Mar 17 01:19 2001 Robert Collins rbtcollins AT hotmail DOT com * cygwin/cygwin.din: Export the new functions * cygwin/pthread.cc: Wrapper functions that call __pthread_cond* functions * cygwin/thread.cc: Implement the pthread_cond* functions * cygwin/thread.h: Add new class entries and prototypes for __pthread_cond* functions * cygwin/include/pthread.h: user land header prototypes for pthread_cond* functions and related defines The attached c file is the core test rig I used. It doesn't test _everything. Also, I'm not fluent with shared memory implications, so I'm not sure what, if any effect the condattr pshared stuff will have. Likewise for forking of applications - do all the threads get forked too? And their cond variables? Is that automagically taken care of, or should I code something in? Rob ------=_NextPart_000_05E7_01C0AE81.7236EBB0 Content-Type: application/octet-stream; name="pt.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pt.c" #include =0A= =0A= #if 0=0A= #ifndef PTHREAD_CANCEL_ASYNCHRONOUS=0A= #error undefined PTHREAD_CANCEL_ASYNCHRONOUS=0A= #endif=0A= #ifndef PTHREAD_CANCEL_ENABLE=0A= #error undefined PTHREAD_CANCEL_ENABLE=0A= #endif=0A= #ifndef PTHREAD_CANCEL_DEFERRED=0A= #error undefined PTHREAD_CANCEL_DEFERRED=0A= #endif=0A= #ifndef PTHREAD_CANCEL_DISABLE=0A= #error undefined PTHREAD_CANCEL_DISABLE=0A= #endif=0A= #ifndef PTHREAD_CANCELED=0A= #error undefined PTHREAD_CANCELED=0A= #endif=0A= #endif=0A= #if HARD_CODE=0A= #ifndef PTHREAD_COND_INITIALIZER=0A= #error undefined PTHREAD_COND_INITIALIZER=0A= #endif=0A= #endif=0A= #if 0=0A= #ifndef PTHREAD_CREATE_DETACHED=0A= #error undefined PTHREAD_CREATE_DETACHED=0A= #endif=0A= #ifndef PTHREAD_CREATE_JOINABLE=0A= #error undefined PTHREAD_CREATE_JOINABLE=0A= #endif=0A= #ifndef PTHREAD_EXPLICIT_SCHED=0A= #error undefined PTHREAD_EXPLICIT_SCHED=0A= #endif=0A= #ifndef PTHREAD_INHERIT_SCHED=0A= #error undefined PTHREAD_INHERIT_SCHED=0A= #endif=0A= #ifndef PTHREAD_MUTEX_DEFAULT=0A= #error undefined PTHREAD_MUTEX_DEFAULT=0A= #endif=0A= #ifndef PTHREAD_MUTEX_ERRORCHECK=0A= #error undefined PTHREAD_MUTEX_ERRORCHECK=0A= #endif=0A= #ifndef PTHREAD_MUTEX_NORMAL=0A= #error undefined PTHREAD_MUTEX_NORMAL=0A= #endif=0A= #ifndef PTHREAD_MUTEX_INITIALIZER=0A= #error undefined PTHREAD_MUTEX_INITIALIZER=0A= #endif=0A= #ifndef PTHREAD_MUTEX_RECURSIVE=0A= #error undefined PTHREAD_MUTEX_RECURSIVE=0A= #endif=0A= #ifndef PTHREAD_ONCE_INIT=0A= #error undefined PTHREAD_ONCE_INIT=0A= #endif=0A= #ifndef PTHREAD_PRIO_INHERIT=0A= #error undefined PTHREAD_PRIO_INHERIT=0A= #endif=0A= #ifndef PTHREAD_PRIO_NONE=0A= #error undefined PTHREAD_PRIO_NONE=0A= #endif=0A= #ifndef PTHREAD_PRIO_PROTECT=0A= #error undefined PTHREAD_PRIO_PROTECT=0A= #endif=0A= #endif=0A= #ifndef PTHREAD_PROCESS_SHARED=0A= #error undefined PTHREAD_PROCESS_SHARED=0A= #endif=0A= #ifndef PTHREAD_PROCESS_PRIVATE=0A= #error undefined PTHREAD_PROCESS_PRIVATE=0A= #endif=0A= #if 0=0A= #ifndef PTHREAD_RWLOCK_INITIALIZER=0A= #error undefined PTHREAD_RWLOCK_INITIALIZER=0A= #endif=0A= #ifndef PTHREAD_SCOPE_PROCESS=0A= #error undefined PTHREAD_SCOPE_PROCESS=0A= #endif=0A= #ifndef PTHREAD_SCOPE_SYSTEM=0A= #error undefined PTHREAD_SCOPE_SYSTEM=0A= #endif=0A= =0A= #endif=0A= =0A= typedef struct datastruct {=0A= pthread_cond_t cond;=0A= pthread_mutex_t mutex;=0A= int testvalue;=0A= } datastruct_t;=0A= =0A= static int trv=3D1;=0A= =0A= void *threadfunc(void *argument) {=0A= datastruct_t *mydata=3Dargument;=0A= /* get the mutex */=0A= if (pthread_mutex_lock(&mydata->mutex))=0A= return &trv;=0A= /* loop on the value */=0A= while (mydata->testvalue>0) {=0A= /* set the variable value */=0A= if (mydata->testvalue>0)=0A= mydata->testvalue--;=0A= /* tell any waiting threads */=0A= if (pthread_cond_signal(&mydata->cond))=0A= return &trv;=0A= /* release the mutex so the waiting (and now signaled thread) can = get the lock */=0A= if (pthread_mutex_unlock(&mydata->mutex))=0A= return &trv;=0A= sleep(1);=0A= /* get the mutex again so we can update the value */=0A= if (pthread_mutex_lock(&mydata->mutex))=0A= return &trv;=0A= }=0A= /* we have the mutex here */=0A= if (pthread_mutex_unlock(&mydata->mutex))=0A= return &trv;=0A= =0A= trv=3D0;=0A= return &trv;=0A= }=0A= =0A= main(void) {=0A= datastruct_t data;=0A= pthread_condattr_t condattr;=0A= pthread_t thread;=0A= int rv,pshared;=0A= =0A= rv =3D pthread_condattr_init(&condattr);=0A= printf("condattr init %d\n",rv);=0A= rv =3D pthread_condattr_getpshared(&condattr, &pshared);=0A= printf("condattr getpshared %d, pshared %d\n",rv,pshared);=0A= rv =3D pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED);=0A= printf("condattr setpshared %d\n");=0A= rv =3D pthread_condattr_getpshared(&condattr, &pshared);=0A= printf("condattr getpshared %d, pshared %d\n",rv,pshared);=0A= =0A= rv =3D pthread_cond_init(&data.cond, &condattr);=0A= printf("cond init %d\n",rv);=0A= =0A= rv =3D pthread_mutex_init(&data.mutex, NULL);=0A= printf("mutex init %d\n",rv);=0A= =0A= data.testvalue=3D50;=0A= =0A= rv =3D pthread_create(&thread, NULL, threadfunc, &data);=0A= printf("create thread %d\n",rv);=0A= =0A= =0A= /* get the mutex */=0A= printf("locking mutex\n");=0A= rv =3D pthread_mutex_lock(&data.mutex);=0A= printf("lock mutex %d\n",rv);=0A= =0A= while (data.testvalue > 0) {=0A= printf("waiting on the condition\n");=0A= rv =3D pthread_cond_wait(&data.cond, &data.mutex);=0A= printf("cond wait %d\n",rv);=0A= printf("testvalue %d--\n",data.testvalue--);=0A= }=0A= =0A= rv =3D pthread_mutex_unlock(&data.mutex);=0A= printf("mutex unlock %d\n",rv);=0A= =0A= //rv =3D 0;=0A= //while (!rv) {=0A= ///* this is bad programming! busy loop until the thread cannot be found = */=0A= //rv =3D pthread_cancel(&thread);=0A= //}=0A= //printf("thread has exited\n");=0A= =0A= rv =3D pthread_mutex_destroy(&data.mutex);=0A= printf("mutex destroy %d\n",rv);=0A= =0A= rv =3D pthread_cond_destroy(&data.cond);=0A= printf("cond destroy %d\n",rv);=0A= #if HARD_CODE=0A= rv =3D pthread_cond_destroy(&cond2);=0A= printf("cond2(default init) destroy %d\n",rv);=0A= #endif=0A= =0A= rv =3D pthread_condattr_destroy(&condattr);=0A= printf("condattr destroy %d\n",rv);=0A= =0A= =0A= =0A= return 0;=0A= }=0A= ------=_NextPart_000_05E7_01C0AE81.7236EBB0--