From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27343 invoked by alias); 24 Jan 2002 13:44:24 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 27287 invoked from network); 24 Jan 2002 13:44:14 -0000 Received: from unknown (HELO diogenis.ceid.upatras.gr) (150.140.141.181) by sources.redhat.com with SMTP; 24 Jan 2002 13:44:14 -0000 Received: (qmail 20924 invoked from network); 24 Jan 2002 13:42:37 -0000 Received: from daidalos.hpclab.ceid.upatras.gr (150.140.142.162) by diogenis.ceid.upatras.gr with SMTP; 24 Jan 2002 13:42:37 -0000 Received: (qmail 7959 invoked from network); 24 Jan 2002 13:50:49 -0000 Received: from alkaios.hpclab.ceid.upatras.gr (HELO alkaios) (150.140.142.218) by daidalos.hpclab.ceid.upatras.gr with SMTP; 24 Jan 2002 13:50:49 -0000 Message-ID: <004c01c1a4dc$db910800$0300a8c0@hpclab.ceid.upatras.gr> From: "Panagiotis E. Hadjidoukas" To: References: <41256B4A.00367DAB.00@fer_notes_www.ferrero.de> <3C4FF91E.E4FD0685@ise.canberra.edu.au> Subject: Re: Win32 Signals Date: Thu, 24 Jan 2002 05:44:00 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0049_01C1A4ED.9F045430" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-SW-Source: 2002/txt/msg00004.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0049_01C1A4ED.9F045430 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 7287 Hi all, For Unix-like and user-defined signals (like SIGUSR1)=20 on native Windows NT/2000, have you ever considered=20 the idea described in this article? Windows Developer's Journal August 2001, Volume 12, Number 08 "A Device Driver for W2K Signals" http://www.wdj.com/articles/2001/0108/0108toc.htm?topic=3Darticles Panagiotis ------------------------------------ Panagiotis E. Hadjidoukas Ph.D Student High Performance Information Systems Laboratory Computer Enginnering & Informatics Department University of Patras, Greece Contact e-mail: peh@hpclab.ceid.upatras.gr work: +30 61993805 fax: +30 61997706 http://www.hpclab.ceid.upatras.gr ----- Original Message -----=20 From: "Ross Johnson" To: Cc: Sent: Thursday, January 24, 2002 2:07 PM Subject: Re: It doesn't work: using pthread_win32 library installation with= MSVC++6 Hi Oliver, The problem is that pthreads-win32 doesn't provide POSIX signals, only those parts of the POSIX standard that relate closely to threads (excepting those which can't be implementated on Win32 - yet). If you need Signals then you should look at the CygWin project, which aims to provide a much more complete Unix/POSIX API on Win32. I'm not sure how complete the threads support is, but they have been doing a lot of work on it over the last 12 months. http://sources.redhat.com/cygwin http://cygwin.com/licensing.html Another possibility is the UWin project from AT&T. http://www.research.att.com/sw/tools/uwin/ Hope this helps. Ross oliver.kramer@ferrero.de wrote: >=20 > I read all the readable files. I followed all the instructions given in a= ny > files. Even I recompile the sources but all i get is: >=20 > c:\programme\microsoft visual studio\vc98\include\rpcasync.h(45) : warning > C4115: '_RPC_ASYNC_STATE' : Benannte Typdefinition in runden Klammern > d:\threads\examples\signals\stat_sigwait.c(33) : error C2065: 'sigset_t' : > nichtdeklarierter Bezeichner > d:\threads\examples\signals\stat_sigwait.c(33) : error C2146: Syntaxfehle= r : > Fehlendes ';' vor Bezeichner 'sigs_to_catch' > d:\threads\examples\signals\stat_sigwait.c(33) : error C2065: 'sigs_to_ca= tch' : > nichtdeklarierter Bezeichner > d:\threads\examples\signals\stat_sigwait.c(47) : warning C4013: 'sigempty= set' > undefiniert; Annahme: extern mit Rueckgabetyp int > d:\threads\examples\signals\stat_sigwait.c(48) : warning C4013: 'sigaddse= t' > undefiniert; Annahme: extern mit Rueckgabetyp int > d:\threads\examples\signals\stat_sigwait.c(48) : error C2065: 'SIGUSR1' : > nichtdeklarierter Bezeichner > d:\threads\examples\signals\stat_sigwait.c(51) : warning C4013: 'sigwait' > undefiniert; Annahme: extern mit Rueckgabetyp int > d:\threads\examples\signals\stat_sigwait.c(77) : warning C4013: 'sleep' > undefiniert; Annahme: extern mit Rueckgabetyp int > d:\threads\examples\signals\stat_sigwait.c(97) : error C2146: Syntaxfehle= r : > Fehlendes ';' vor Bezeichner 'sigs_to_block' > d:\threads\examples\signals\stat_sigwait.c(97) : error C2065: 'sigs_to_bl= ock' : > nichtdeklarierter Bezeichner > d:\threads\examples\signals\stat_sigwait.c(98) : error C2143: Syntaxfehle= r : > Fehlendes ';' vor 'type' > d:\threads\examples\signals\stat_sigwait.c(110) : warning C4013: > 'pthread_sigmask' undefiniert; Annahme: extern mit Rueckgabetyp int > Fehler beim Ausf=FChren von cl.exe. >=20 > SIGNAL.exe - 7 Fehler, 6 Warnung(en) >=20 > After reading all the relevant postings in the whole usenet .... - please= help! > What's going wrong? Urgent! >=20 > Oliver >=20 > I tried to compile an example from "Pthread programming" (O'Reilly) =3D> > stat_sig_wait.c: >=20 > /******************************************************** > * An example source module to accompany... > * > * "Using POSIX Threads: Programming with Pthreads" > * by Brad nichols, Dick Buttlar, Jackie Farrell > * O'Reilly & Associates, Inc. > * > ******************************************************** > * stat_sigwait.c > * > * Simple example of pthreads and signals. > */ >=20 > #include > #include > // #include > #include >=20 > #include > #include > #include >=20 > #include >=20 > #define MAX_NUM_THREADS 10 >=20 > pthread_mutex_t stats_lock =3D PTHREAD_MUTEX_INITIALIZER; > int mean, samples, total; >=20 > void *report_stats(void *p) > { > int caught; > sigset_t sigs_to_catch; >=20 > /* Identify our thread */ > printf("\nreport_stats() started.\n"); >=20 > /* > * We inherited a thread sigmask with all the signals > * blocked. So, we can wait on whatever signals we're > * interested in and (as long as no other thread waits > * for them) we'll be sure return from sigwait() to > * handle it. > */ >=20 > /* set this thread's signal mask to block out SIGUSR1 */ > sigemptyset(&sigs_to_catch); > sigaddset(&sigs_to_catch, SIGUSR1); >=20 > for (;;) { > sigwait(&sigs_to_catch, &caught); >=20 > pthread_mutex_lock(&stats_lock); > mean =3D total/samples; > printf("\nreport_stats(): mean =3D %d, samples =3D %d\n", mean, samp= les); > pthread_mutex_unlock(&stats_lock); > } > return NULL; > } > /* > * worker_thread -- > * > * Don't read too much into what this thread does. It's > * a very simpleminded example. The only interesting thing > * it does is write to the global statistics data-- which > * means the thread processing the signal has to protect > * against simultaneous access. > */ > void *worker_thread(void *p) > { > int item; > time_t now; > int *amtp=3D(int *)p; >=20 > for (;;) { >=20 > sleep((*amtp)*9); >=20 > now =3D time(NULL); >=20 > pthread_mutex_lock(&stats_lock); > total+=3D((int)now)%60; /* probably not the safest thing to do but > it's just an example */ > samples++; > pthread_mutex_unlock(&stats_lock); > } > /* Won't get here. */ > return NULL; > } >=20 > extern int > main(void) > { > int i; > pthread_t threads[MAX_NUM_THREADS]; > int num_threads =3D 0; > sigset_t sigs_to_block; > struct sigaction action; >=20 > /* Identify our thread */ > printf("main() running in thread 0x%x\n", pthread_self()); >=20 > /* > * Set this thread's signal mask to block SIGUSR1 > * Other thread's will inherit the mask > */ > sigemptyset(&sigs_to_block); > sigaddset(&sigs_to_block, SIGUSR1); > pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL); >=20 > /* spawn statistics reporting thread */ > pthread_create(&threads[num_threads++], > NULL, > report_stats, > NULL); >=20 > /* spawn the threads */ > for (i=3Dnum_threads; i pthread_create(&threads[num_threads++], > NULL, > worker_thread, > &i); > } >=20 > printf("main()\t\t\t\t%d threads created\n",num_threads); >=20 > /* wait until all threads have finished */ > for (i =3D 0; i < num_threads; i++) { > pthread_join(threads[i], NULL); > printf("main()\t\tjoined to thread %d \n", i); > } >=20 > printf("main()\t\tall %d threads have finished. \n", num_threads); >=20 > return 0; > } ------=_NextPart_000_0049_01C1A4ED.9F045430 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 11739
Hi all,
 
For Unix-like and user-defined signals (li= ke=20 SIGUSR1)
on native Windows NT/2000, have you ever c= onsidered=20
the idea described in this article?=
 
Windows Developer's Journal
August 2001, Volume 12, Number 08
"A Device Driver for W2K Signals"
http://www.wdj.com/articles/2001/0108/0108toc.htm?topic=3Darticles
=
Panagiotis
 
------------------------------------
Panagiotis E. Hadjidoukas
P= h.D=20 Student
High Performance Information Systems Laboratory
Computer=20 Enginnering & Informatics Department
University of Patras,=20 Greece

Contact
e-mail: peh@hpclab.ceid.upatras.grwork:  =20 +30 61993805
fax:    +30 61997706
http://www.hpclab.ceid.upatras.g= r

 

----- Original Message -----
From: "Ross Johnson"=20 <rpj@ise.canberra.edu.au>
To: <oliver.kramer@ferrero.de>
= Cc:=20 <pthreads-win32@sources.redhat.com>
Sent: Thursday, January 24, 20= 02=20 2:07 PM
Subject: Re: It doesn't work: using pthread_win32 library=20 installation withMSVC++6


Hi Oliver,

The problem is that=20 pthreads-win32 doesn't provide POSIX signals,
only those parts of the PO= SIX=20 standard that relate closely to threads
(excepting those which can't be= =20 implementated on Win32 - yet).

If you need Signals then you should l= ook=20 at the CygWin project, which
aims to provide a much more complete Unix/P= OSIX=20 API on Win32. I'm not
sure how complete the threads support is, but they= have=20 been doing a
lot of work on it over the last 12=20 months.

http://sources.redhat.com/cygwin
http://cygwin.com/licens= ing.html

Another=20 possibility is the UWin project from=20 AT&T.

http://www.research.att.com/sw/tools/uwin/

Hope thi= s=20 helps.
Ross

oliver.kramer@ferrero.de wrote:
>
> I re= ad=20 all the readable files. I followed all the instructions given in any
>= ;=20 files. Even I recompile the sources but all i get is:
>
>=20 c:\programme\microsoft visual studio\vc98\include\rpcasync.h(45) :=20 warning
> C4115: '_RPC_ASYNC_STATE' : Benannte Typdefinition in runde= n=20 Klammern
> d:\threads\examples\signals\stat_sigwait.c(33) : error C20= 65:=20 'sigset_t' :
> nichtdeklarierter Bezeichner
>=20 d:\threads\examples\signals\stat_sigwait.c(33) : error C2146: Syntaxfehler= =20 :
> Fehlendes ';' vor Bezeichner 'sigs_to_catch'
>=20 d:\threads\examples\signals\stat_sigwait.c(33) : error C2065: 'sigs_to_catc= h'=20 :
> nichtdeklarierter Bezeichner
>=20 d:\threads\examples\signals\stat_sigwait.c(47) : warning C4013:=20 'sigemptyset'
> undefiniert; Annahme: extern mit Rueckgabetyp int
= >=20 d:\threads\examples\signals\stat_sigwait.c(48) : warning C4013:=20 'sigaddset'
> undefiniert; Annahme: extern mit Rueckgabetyp int
&g= t;=20 d:\threads\examples\signals\stat_sigwait.c(48) : error C2065: 'SIGUSR1'=20 :
> nichtdeklarierter Bezeichner
>=20 d:\threads\examples\signals\stat_sigwait.c(51) : warning C4013:=20 'sigwait'
> undefiniert; Annahme: extern mit Rueckgabetyp int
>= =20 d:\threads\examples\signals\stat_sigwait.c(77) : warning C4013: 'sleep'
= >=20 undefiniert; Annahme: extern mit Rueckgabetyp int
>=20 d:\threads\examples\signals\stat_sigwait.c(97) : error C2146: Syntaxfehler= =20 :
> Fehlendes ';' vor Bezeichner 'sigs_to_block'
>=20 d:\threads\examples\signals\stat_sigwait.c(97) : error C2065: 'sigs_to_bloc= k'=20 :
> nichtdeklarierter Bezeichner
>=20 d:\threads\examples\signals\stat_sigwait.c(98) : error C2143: Syntaxfehler= =20 :
> Fehlendes ';' vor 'type'
>=20 d:\threads\examples\signals\stat_sigwait.c(110) : warning C4013:
>=20 'pthread_sigmask' undefiniert; Annahme: extern mit Rueckgabetyp int
>= =20 Fehler beim Ausf=FChren von cl.exe.
>
> SIGNAL.exe - 7 Fehler,= 6=20 Warnung(en)
>
> After reading all the relevant postings in the= =20 whole usenet .... - please help!
> What's going wrong? Urgent!
>= ;=20
> Oliver
>
> I tried to compile an example from "Pthrea= d=20 programming" (O'Reilly) =3D>
> stat_sig_wait.c:
>
>=20 /********************************************************
>  * A= n=20 example source module to accompany...
>  *
>  * "Usin= g=20 POSIX Threads: Programming with Pthreads"
> =20 *     by Brad nichols, Dick Buttlar, Jackie=20 Farrell
>  *     O'Reilly & Associates,= =20 Inc.
>  *
> =20 ********************************************************
>  *=20 stat_sigwait.c
>  *
>  * Simple example of pthreads a= nd=20 signals.
>  */
>
> #include <stdlib.h>
>= ;=20 #include <stdio.h>
> // #include <unistd.h>
> #incl= ude=20 <io.h>
>
> #include <signal.h>
> #include=20 <time.h>
> #include <sys/types.h>
>
> #inclu= de=20 <pthread.h>
>
> #define MAX_NUM_THREADS  10
>= =20
> pthread_mutex_t stats_lock =3D PTHREAD_MUTEX_INITIALIZER;
> = int=20 mean, samples, total;
>
> void *report_stats(void *p)
>= =20 {
>   int caught;
>   sigset_t =20 sigs_to_catch;
>
>   /* Identify our thread=20 */
>   printf("\nreport_stats() started.\n");
>=20
>   /*
>    * We inherited a thread=20 sigmask with all the signals
>    * blocked.  So,= we=20 can wait on whatever signals we're
>    * interested i= n and=20 (as long as no other thread waits
>    * for them) we'= ll be=20 sure return from sigwait() to
>    * handle=20 it.
>    */
>
>   /* set this=20 thread's signal mask to block out SIGUSR1 */
>  =20 sigemptyset(&sigs_to_catch);
>  =20 sigaddset(&sigs_to_catch, SIGUSR1);
>
>   for (;= ;)=20 {
>      sigwait(&sigs_to_catch,=20 &caught);
>
>     =20 pthread_mutex_lock(&stats_lock);
>      = mean=20 =3D total/samples;
>      printf("\nreport_s= tats():=20 mean =3D %d, samples =3D %d\n", mean,=20 samples);
>     =20 pthread_mutex_unlock(&stats_lock);
>   }
> &= nbsp;=20 return NULL;
> }
> /*
>  * worker_thread --
>&= nbsp;=20 *
>  * Don't read too much into what this thread does. =20 It's
>  * a very simpleminded example.  The only interestin= g=20 thing
>  * it does is write to the global statistics data--=20 which
>  * means the thread processing the signal has to=20 protect
>  * against simultaneous access.
>  */
&g= t;=20 void *worker_thread(void *p)
> {
> int item;
> time_t=20 now;
> int *amtp=3D(int *)p;
>
>   for (;;) {<= BR>>=20
>     sleep((*amtp)*9);
>=20
>     now =3D time(NULL);
>=20
>    =20 pthread_mutex_lock(&stats_lock);
>    =20 total+=3D((int)now)%60; /* probably not the safest thing to do=20 but
>          &nbs= p;       =20 it's just an example */
>    =20 samples++;
>    =20 pthread_mutex_unlock(&stats_lock);
>   }
> &= nbsp;=20 /* Won't get here.  */
>   return NULL;
> }
&= gt;=20
> extern int
> main(void)
> {
>  =20 int       i;
>   pthread_t=20 threads[MAX_NUM_THREADS];
>  =20 int       num_threads =3D 0;
> &nb= sp;=20 sigset_t  sigs_to_block;
>   struct   = =20 sigaction action;
>
>   /* Identify our thread=20 */
>   printf("main() running in thread 0x%x\n",=20 pthread_self());
>
>   /*
>    = * Set=20 this thread's signal mask to block SIGUSR1
>    * Othe= r=20 thread's will inherit the mask
>    */
> &n= bsp;=20 sigemptyset(&sigs_to_block);
>  =20 sigaddset(&sigs_to_block, SIGUSR1);
>  =20 pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL);
>=20
>   /* spawn statistics reporting thread */
> &= nbsp;=20 pthread_create(&threads[num_threads++],
>    =           =20 NULL,
>          &n= bsp;=20 report_stats,
>         =   =20 NULL);
>
>   /* spawn the threads */
> &n= bsp;=20 for (i=3Dnum_threads; i<MAX_NUM_THREADS; i++) {
>   = ; =20 pthread_create(&threads[num_threads++],
>    =          =20 NULL,
>          &n= bsp;        =20 worker_thread,
>         = ;    =20 &i);
>   }
>
>  =20 printf("main()\t\t\t\t%d threads created\n",num_threads);
>=20
>   /* wait until all threads have finished=20 */
>   for (i =3D 0; i < num_threads; i++)=20 {
>     pthread_join(threads[i],=20 NULL);
>     printf("main()\t\tjoined to thread %= d=20 \n", i);
>   }
>
>  =20 printf("main()\t\tall %d threads have finished. \n", num_threads);
>= =20
>   return 0;
> }
------=_NextPart_000_0049_01C1A4ED.9F045430--