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

« back to all changes in this revision

Viewing changes to src/task.c

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2005-10-06 15:25:03 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051006152503-nty60w30a9dja62m
Tags: 3.4.5-5
Use --remove-all on pvm-rsh alternative in prerm instead of --remove.
(Closes: #328366)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
static char rcsid[] =
3
 
        "$Id: task.c,v 1.19 1999/07/08 19:00:15 kohl Exp $";
 
3
        "$Id: task.c,v 1.25 2002/04/16 15:04:50 pvmsrc Exp $";
4
4
 
5
5
/*
6
6
 *         PVM version 3.4:  Parallel Virtual Machine System
36
36
 *      Task descriptors.
37
37
 *
38
38
 * $Log: task.c,v $
 
39
 * Revision 1.25  2002/04/16 15:04:50  pvmsrc
 
40
 * Fixed bug in task_cleanup():
 
41
 *      - & vs && in scheduler notification code...  :-Q
 
42
 *      - bug report submitted by Yan Xiao <yxiao@BlackstoneComputing.com>.
 
43
 * (Spanker=kohl)
 
44
 *
 
45
 * Revision 1.24  2002/02/21 23:18:07  pvmsrc
 
46
 * Added new (not to be documented!) PVM_MAX_TASKS env var support.
 
47
 *      - for Mahir Lokvancic <mahir@math.ufl.edu>.
 
48
 *      - forcefully limits the number of tasks that can attach to a
 
49
 *              pvmd, required on Solaris in rare circumstances when hard
 
50
 *              FD_SETSIZE limit is reached, and all hell breaks loose...
 
51
 *      - check pvm_max_ntasks global when allocating new tasks
 
52
 *              (0 = no limit)
 
53
 *      - in task_new() call, if limit reached return NULL ptr,
 
54
 *              indicating PvmOutOfRes...
 
55
 *      - keep track of private "ntasks" counter in task_new()/task_free(),
 
56
 *              only increment for non-zero tids (avoid counting temp task
 
57
 *              structs...).
 
58
 * (Spanker=kohl)
 
59
 *
 
60
 * Revision 1.23  2001/02/07 23:15:54  pvmsrc
 
61
 * 2nd Half of CYGWIN Check-ins...
 
62
 * (Spanker=kohl)
 
63
 *
 
64
 * Revision 1.22  2000/09/01 14:39:22  pvmsrc
 
65
 * Plugged memory (waitc) leak in task_cleanup():
 
66
 *      - better get rid of any notify wait contexts, if the task is
 
67
 *              dead we probably don't care any more...
 
68
 *      - added wait_delete() for WT_HOSTA, WT_TASKX, WT_ROUTEA, WT_ROUTED.
 
69
 *      - I hope this doesn't break any shit...  :-o
 
70
 * (Spanker=kohl)
 
71
 *
 
72
 * Revision 1.21  2000/02/17 23:12:19  pvmsrc
 
73
 * *** Changes for new BEOLIN port ***
 
74
 *      - MPP-like, similar to SP2, etc.
 
75
 *      - submitted by Paul Springer <pls@smokeymt.jpl.nasa.gov>.
 
76
 *      - format-checked & cleaned up by Jeembo...  :-)
 
77
 * (Spanker=kohl)
 
78
 *
 
79
 * Revision 1.20  2000/02/16 22:00:30  pvmsrc
 
80
 * Fixed up #include <sys/types.h> stuff...
 
81
 *      - use <bsd/sys/types.h> for IMA_TITN...
 
82
 *      - #include before any NEEDMENDIAN #includes...
 
83
 * (Spanker=kohl)
 
84
 *
39
85
 * Revision 1.19  1999/07/08 19:00:15  kohl
40
86
 * Fixed "Log" keyword placement.
41
87
 *      - indent with " * " for new CVS.
163
209
 *
164
210
 */
165
211
 
 
212
#ifdef IMA_TITN
 
213
#include <bsd/sys/types.h>
 
214
#else
 
215
#include <sys/types.h>
 
216
#endif
 
217
 
166
218
#ifdef NEEDMENDIAN
167
219
#include <machine/endian.h>
168
220
#endif
174
226
#endif
175
227
 
176
228
#include <pvm3.h>
177
 
#ifdef WIN32
178
 
#include "pvmwin.h"
179
 
#include <time.h>
180
 
#ifndef _XDR_HEADERS
181
 
#define _XDR_HEADERS
 
229
 
 
230
#if defined(WIN32) || defined(CYGWIN)
182
231
#include "..\xdr\types.h"
183
232
#include "..\xdr\xdr.h"
184
 
#endif
185
233
#else
186
234
#include <rpc/types.h>
187
235
#include <rpc/xdr.h>
 
236
#endif
 
237
 
 
238
#ifdef WIN32
 
239
#include "pvmwin.h"
 
240
#include <time.h>
 
241
#else
188
242
#include <sys/time.h>
189
243
#include <sys/socket.h>
190
244
#include <netinet/in.h>
191
245
#endif
192
246
 
193
 
#include <sys/types.h>
194
 
 
195
247
#ifdef  SYSVSTR
196
248
#include <string.h>
197
249
#else
227
279
extern int taskertid;                           /* from pvmd.c */
228
280
extern struct Pvmtracer pvmtracer;      /* from pvmd.c */
229
281
extern int tidlmask;                            /* from pvmd.c */
 
282
extern int pvm_max_ntasks;                      /* from pvmd.c */
230
283
 
231
284
struct task *locltasks = 0;                     /* all task structs sorted by tid */
232
285
 
240
293
 
241
294
static struct ccon *cconlist = 0;
242
295
 
 
296
static int ntasks = 0;  /* tot # of tasks registered w/this pvmd */
 
297
 
243
298
 
244
299
/*****************
245
300
 **  Interface  **
387
442
{
388
443
        struct task *tp, *tp2;
389
444
 
 
445
        if (tid) {
 
446
                ntasks++;
 
447
                if (pvmdebmask & PDMTASK) {
 
448
                        pvmlogprintf("task_new(%d) ntasks=%d pvm_max_ntasks=%d\n",
 
449
                                tid, ntasks, pvm_max_ntasks );
 
450
                }
 
451
                if (pvm_max_ntasks && ntasks > pvm_max_ntasks) {
 
452
                        pvmlogprintf("task_new() too many tasks?\n");
 
453
                        ntasks--;  /* this one didn't make it... :-) */
 
454
                        return( (struct task *) NULL );
 
455
                }
 
456
        }
 
457
 
390
458
        if (!(tp = TALLOC(1, struct task, "task"))) {
391
459
                pvmlogprintf("task_new() can't get memory\n");
392
460
                pvmbailout(0);
432
500
#ifdef SHMEM
433
501
        /* XXX this is inside out - mpp_free should call task_free.
434
502
           XXX but for now task_free is what's called.
435
 
           XXX this will change in the portable processor interface cleanup. */
 
503
           XXX this will change in the portable processor interface
 
504
           XXX cleanup. */
436
505
        mpp_free(tp->t_tid);
437
506
#endif
 
507
#ifdef IMA_BEOLIN
 
508
        mpp_free(tp);
 
509
#endif
438
510
        if (tp->t_plink && tp->t_prlink) {
439
511
                LISTDELETE(tp, t_plink, t_prlink);
440
512
        }
500
572
                }
501
573
                PVM_FREE(tp->t_ccs);
502
574
        }
 
575
 
 
576
        if (tp->t_tid) {
 
577
                ntasks--;
 
578
                if (pvmdebmask & PDMTASK) {
 
579
                        pvmlogprintf("task_free(%d) ntasks=%d\n",
 
580
                                        tp->t_tid, ntasks );
 
581
                }
 
582
        }
 
583
 
503
584
        PVM_FREE(tp);
504
585
}
505
586
 
673
754
                                switch (wp->wa_kind) {
674
755
 
675
756
                                case WT_HOSTF:
 
757
                                case WT_HOSTA:
 
758
                                case WT_TASKX:
 
759
                                case WT_ROUTEA:
 
760
                                case WT_ROUTED:
676
761
                                case WT_TASKSTART:
677
762
                                        wp2 = wp;                               /* some kinds we can toss now */
678
763
                                        wp = wp->wa_rlink;
688
773
 
689
774
                /* notify the scheduler */
690
775
 
691
 
                if ((tp->t_sched)&(tp->t_schedlmsg!=SM_TASKX)) {
 
776
                if ((tp->t_sched)&&(tp->t_schedlmsg!=SM_TASKX)) {
692
777
                        mp = mesg_new(0);
693
778
                        mp->m_dst = tp->t_sched;
694
779
                        mp->m_tag = SM_TASKX;