~ubuntu-branches/ubuntu/jaunty/pvm/jaunty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
static char rcsid[] =
	"$Id: pvmdunix.c,v 1.15 2001/02/07 23:15:54 pvmsrc Exp $";

/*
 *         PVM version 3.4:  Parallel Virtual Machine System
 *               University of Tennessee, Knoxville TN.
 *           Oak Ridge National Laboratory, Oak Ridge TN.
 *                   Emory University, Atlanta GA.
 *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
 *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
 *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
 *                   (C) 1997 All Rights Reserved
 *
 *                              NOTICE
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby granted
 * provided that the above copyright notice appear in all copies and
 * that both the copyright notice and this permission notice appear in
 * supporting documentation.
 *
 * Neither the Institutions (Emory University, Oak Ridge National
 * Laboratory, and University of Tennessee) nor the Authors make any
 * representations about the suitability of this software for any
 * purpose.  This software is provided ``as is'' without express or
 * implied warranty.
 *
 * PVM version 3 was funded in part by the U.S. Department of Energy,
 * the National Science Foundation and the State of Tennessee.
 */

/*
 *	pvmdunix.c
 *
 *	Support routines for pvmd in unix environment.
 *
 * $Log: pvmdunix.c,v $
 * Revision 1.15  2001/02/07 23:15:54  pvmsrc
 * 2nd Half of CYGWIN Check-ins...
 * (Spanker=kohl)
 *
 * Revision 1.14  2000/02/16 22:00:29  pvmsrc
 * Fixed up #include <sys/types.h> stuff...
 * 	- use <bsd/sys/types.h> for IMA_TITN...
 * 	- #include before any NEEDMENDIAN #includes...
 * (Spanker=kohl)
 *
 * Revision 1.13  2000/02/08 16:58:59  pvmsrc
 * Re-arranged #include of header files for CRAY J932se.
 * 	- move rpc/types.h, rpc/xdr.h before sys/time.h, sys/socket.h...
 * 	- patch submitted by "Francois Moyroud" <francois@egi.kth.se>
 * (Spanker=kohl)
 *
 * Revision 1.12  1999/07/08 19:00:11  kohl
 * Fixed "Log" keyword placement.
 * 	- indent with " * " for new CVS.
 *
 * Revision 1.11  1998/11/20  20:10:40  pvmsrc
 * Lets try this again....
 *
 * Changes so that compiles & builds on win32.  Also, single
 * source win32 & unix
 * (Spanker=sscott)
 *
 * Revision 1.10  1997/08/29  13:35:17  pvmsrc
 * OS2 Port Submitted by Bohumir Horeni, horeni@login.cz.
 * (Spanker=kohl)
 *
 * Revision 1.9  1997/07/30  19:01:23  pvmsrc
 * Markus Fixes.
 *
 * Revision 1.8  1997/06/27  19:52:15  pvmsrc
 * Integrated WIN32 changes.
 *
 * Revision 1.7  1997/06/24  20:39:21  pvmsrc
 * Eliminated unnecessary global externs.
 *
 * Revision 1.6  1997/06/16  13:40:35  pvmsrc
 * ppi_load changed to pass extra info into forkexec call to help taskers.
 *
 * Revision 1.5  1997/03/06  21:11:38  pvmsrc
 * 		formatting :-)
 *
 * Revision 1.4  1997/01/28  19:27:25  pvmsrc
 * New Copyright Notice & Authors.
 *
 * Revision 1.3  1996/10/25  13:58:04  pvmsrc
 * Replaced old #includes for protocol headers:
 * 	- <pvmsdpro.h>, "ddpro.h", "tdpro.h"
 * With #include of new combined header:
 * 	- <pvmproto.h>
 *
 * Revision 1.2  1996/10/24  21:04:52  pvmsrc
 * Moved #include of "global.h" down below other headers:
 * 	- need to have all of the structures / types declared before
 * 		the globals can be declared...
 *
 * Revision 1.1  1996/09/23  23:44:35  pvmsrc
 * Initial revision
 *
 */

#ifndef WIN32
#include <sys/param.h>
#endif

#ifdef IMA_TITN
#include <bsd/sys/types.h>
#else
#include <sys/types.h>
#endif

#ifdef NEEDMENDIAN
#include <machine/endian.h>
#endif
#ifdef NEEDENDIAN
#include <endian.h>
#endif
#ifdef NEEDSENDIAN
#include <sys/endian.h>
#endif

#include <pvm3.h>

#if defined(WIN32) || defined(CYGWIN)
#include "..\xdr\types.h"
#include "..\xdr\xdr.h"
#else
#include <rpc/types.h>
#include <rpc/xdr.h>
#endif

#ifdef WIN32
#include "pvmwin.h"
#include <time.h>
#else
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif

#ifdef	SYSVSTR
#include <string.h>
#define	CINDEX(s,c)	strchr(s,c)
#else
#include <strings.h>
#define	CINDEX(s,c)	index(s,c)
#endif
#include <errno.h>
#include <stdio.h>
#include <pvmtev.h>
#include <pvmproto.h>
#include "pvmalloc.h"
#include "host.h"
#include "pmsg.h"
#include "waitc.h"
#include "task.h"
#include "listmac.h"
#include "bfunc.h"
#include "global.h"

#if defined(IMA_CRAY) || defined(IMA_CRAY2) || defined(IMA_I860) || defined(IMA_E88K) || defined(IMA_SCO)
#ifndef	MAXPATHLEN
#define	MAXPATHLEN	CANBSIZ
#endif
#endif


/***************
 **  Globals  **
 **           **
 ***************/


/*	ppi_load()
*
*	Start a set of new tasks running on this host.
*/

int
ppi_load(wxp)
	struct waitc_spawn *wxp;
{
	int i;
	struct task *tp;
	int err = 0;

#ifdef WIN32
	/* even being left untouched the filename gets a further */
	/* extension to %SystemRoot% which causes to return PvmNoFile */
	char filename[64];
	strcpy(filename,wxp->w_argv[0]);
#endif

	for (i = 0; i < wxp->w_veclen; i++) {
		if (err) {
			wxp->w_vec[i] = err;

		} else {
#ifdef WIN32
			strcpy(wxp->w_argv[0],filename);
#endif		
			if ( err = forkexec(wxp->w_flags, wxp->w_argv[0], 
					wxp->w_argv, wxp->w_nenv, wxp->w_env, 
					(wxp->w_instance+i), wxp->w_hosttotal, wxp->w_outof, &tp)) 
		/* inst+i as each process is started inst is really an offset */
			{
				wxp->w_vec[i] = err;

			} else {
				tp->t_ptid = wxp->w_ptid;
				tp->t_outtid = wxp->w_outtid;
				tp->t_outctx = wxp->w_outctx;
				tp->t_outtag = wxp->w_outtag;
				tp->t_trctid = wxp->w_trctid;
				tp->t_trcctx = wxp->w_trcctx;
				tp->t_trctag = wxp->w_trctag;
				tp->t_sched = wxp->w_sched;
				wxp->w_vec[i] = tp->t_tid;
			}
		}
	}
	return 0;
}


int
ppi_kill(tp, signum)
	struct task *tp;
	int signum;
{
	if (tp->t_pid)
#ifndef WIN32
#ifdef IMA_OS2
		(void)os2_kill(tp->t_pid, signum);
#else
		(void)kill(tp->t_pid, signum);
#endif
#else 
		(void)kill(tp->t_pid,tp->t_handle,signum);
#endif
	else
		pvmlogprintf("ppi_kill() signal for t%x scrapped (pid = 0)\n",
				tp->t_tid);
	return 0;
}


int
ppi_config(argc, argv)
	int argc;
	char **argv;
{
	return 0;
}


int
ppi_init()
{
	return 0;
}