home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / prospero / PRM / src / testprog / tscont.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-24  |  1.5 KB  |  77 lines

  1. /*
  2.  * Copyright (c) 1992, 1993 by the University of Southern California
  3.  *
  4.  * For copying and distribution information, please see the files
  5.  * <prm-copyr.h>.
  6.  */
  7.  
  8. #include <prm-copyr.h>
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13.  
  14. #define  MAIN_PROG
  15. #include <comm.h>   /*     This file defines certain constants, and declares
  16.             some global variables used by the message passing
  17.             routines.  */
  18.  
  19.  
  20. char *progname;
  21. char pathname[80], *arch;
  22. char *tchar, *jchar;
  23.  
  24.  
  25. main(argc, argv, envp)
  26. int argc;
  27. char *argv[], *envp[];
  28. {
  29.   int ntasks, my_tid, i, j ;
  30.  
  31.   init_task(argv);    /* Initialization is required for all tasks in every
  32.              application */
  33.   
  34.   pfs_debug=0;
  35.   my_tid = gettid(); 
  36.   if (my_tid == -1) {
  37.     io_printf(" task could not get its tid!", (char *)0);
  38.     exit(1);
  39.   }
  40.   
  41.   tchar = argv[1]; jchar = argv[2];
  42.   arch = getenv("ARCH");
  43.   sprintf(pathname,"/nfs/pfs/divirs/jmsm/ardpcoll/obj/hp700/appl/ringsim",
  44.       arch);
  45.   
  46.   for (i = 0; i < 2; i++) {
  47.     for (j = 0; j < 2; j ++) 
  48.       run_compute_task(envp);
  49.   }
  50.  
  51.   io_printf ("done", (char *)0);
  52.   exit(0);
  53. }
  54.  
  55.  
  56. run_compute_task(char **ep)
  57. {
  58.   int status, pid;
  59.  
  60.   if ((pid = vfork()) == -1) {
  61.     return (ERRORCODE);    /* Could not create a child process */
  62.   }
  63.   else if (pid) {       /* PARENT PROCESS */
  64.     
  65.     wait(&status);
  66.   }
  67.   else {
  68.     if (execle(pathname, "ringsim", tchar, jchar, (char *)0, ep) == -1)
  69.       fprintf(stderr, "(%s) Could not exec child program %s: ", 
  70.           progname, pathname);
  71.     
  72.     perror("");
  73.     /* EXECV error -- return failure indicator */
  74.     _exit (ERRORCODE);
  75.   }
  76. }
  77.