Commit 72d9029e authored by slevy's avatar slevy
Browse files

Add "echo" data+control command.

Try to add pthread-based USE_IEEEIO.  Don't know if this works yet,
but it compiles.
parent 15bf7e38
......@@ -12,6 +12,11 @@ static char copyright[] = "Copyright (c) 2002 NCSA, University of Illinois Urban
/*
* $Log$
* Revision 1.96 2003/10/25 00:42:52 slevy
* Add "echo" data+control command.
* Try to add pthread-based USE_IEEEIO. Don't know if this works yet,
* but it compiles.
*
* Revision 1.95 2003/09/30 08:44:37 slevy
* Make waveobj accept objects made of line segments.
*
......@@ -397,6 +402,14 @@ static char copyright[] = "Copyright (c) 2002 NCSA, University of Illinois Urban
# ifndef WORDS_BIGENDIAN
# include "config.h" /* for WORDS_BIGENDIAN */
# endif
# if USE_IEEEIO
# include <sys/prctl.h>
# ifndef PR_SADDR /* if SGI, use sproc() for bg processing */
# define USE_PTHREAD 1 /* linux or other UNIX; use pthreads for bg */
# include <pthread.h>
# endif /* end non-SGI */
# endif /* end USE_IEEEIO */
#else /*WIN32*/
# include "winjunk.h"
# define WORDS_BIGENDIAN 0
......@@ -916,16 +929,25 @@ void specks_datawait(struct stuff *st) {
#ifdef USE_IEEEIO
void specks_ieee_server( void *vst ) {
#if USE_PTHREAD
pthread_t ieeethread;
#endif
void *specks_ieee_server( void *vst ) {
struct stuff *st = (struct stuff *)vst;
struct specklist *sl;
#ifdef PR_SET_PDEATHSIG /* linux variant of prctl */
prctl(PR_SET_PDEATHSIG, SIGTERM);
#else
prctl(PR_TERMCHILD); /* Die when parent dies */
#endif
/* Await a request */
for(;;) {
time_t then;
while(st->fetching <= 0)
sginap(5);
usleep(5*10000);
then = time(NULL);
sl = specks_ieee_read_timestep( st, st->subsample,
st->fetchdata, st->fetchtime );
......@@ -939,6 +961,8 @@ void specks_ieee_server( void *vst ) {
}
st->fetching = 0;
}
/* but if we ever did return, ... */
return NULL;
}
#endif /*USE_IEEEIO*/
......@@ -1033,9 +1057,19 @@ void specks_set_timestep( struct stuff *st )
st->fetching = 1;
if(st->fetchpid <= 0) {
#if USE_PTHREAD
st->fetchpid = pthread_create( &ieeethread, NULL, specks_ieee_server, st );
if(st->fetchpid < 0)
perror("ieee pthread_create");
#else /* sgi -- has sproc() */
st->fetchpid = sproc( specks_ieee_server, PR_SADDR|PR_SFDS, st );
if(st->fetchpid < 0)
perror("sproc");
#endif
}
}
}
......@@ -4303,6 +4337,9 @@ void specks_read( struct stuff **stp, char *fname )
if(v != 0)
st->spacescale = speckscale = v;
} else if(!strcmp(argv[0], "echo")) {
msg( "%s", rejoinargs(1, argc, argv) );
} else if(!strcmp(argv[0], "tfm") && argc>1) {
int inv = 0;
int mul = 0;
......@@ -5228,6 +5265,9 @@ specks_parse_args( struct stuff **stp, int argc, char *argv[] )
st->useme = argc>1 ? getbool(argv[1], st->useme) : (argv[0][1]=='n');
msg(st->useme ? "enabled" : "disabled");
} else if(!strcmp(argv[0], "echo")) {
msg( "%s", rejoinargs(1, argc, argv) );
} else if(!strcmp(argv[0], "add")) {
int k, io[2];
FILE *tf;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment