Advertisement
Guest User

Untitled

a guest
Jul 10th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <inttypes.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7. #include <stdarg.h>
  8. #include <signal.h>
  9. #include <sys/wait.h>
  10. #include <locale.h>
  11. #include <err.h>
  12. #include <sched.h>
  13. #include <errno.h>
  14. #include <time.h>
  15.  
  16. #define SIZE 1024
  17. #define BASE_PATH "/parsec/parsec-3.0/pkgs/apps/"
  18. #define BIN_PATH "/inst/arm-linux.gcc/bin/"
  19.  
  20.  
  21. //execute the program
  22. int run_apps(char* executable, char* path_executable) {
  23.         pid_t child;
  24.         child = fork();
  25.         if (!child) {
  26.                 //FOLDER
  27.                 char path_of_executable[SIZE];
  28.                 printf ("%s \n",executable);
  29.                 snprintf(path_of_executable, sizeof path_of_executable, "%s%s%s", BASE_PATH,executable,BIN_PATH);
  30.                 chdir(path_of_executable);
  31.  
  32.                 char final_executable[SIZE];
  33.                 char for_execlp[SIZE];
  34.                 snprintf(final_executable, sizeof final_executable, "%s%s%s","./",executable,path_executable);
  35.                 snprintf(for_execlp, sizeof for_execlp,"%s%s","./",executable);
  36.  
  37.  
  38.                 execlp(for_execlp,for_execlp,path_executable, (char *)0);
  39.  
  40.         //      return 127;
  41.         }
  42.         sleep(1);
  43.         printf ("pid - %d\n", child);
  44.         return child;
  45. }
  46.  
  47.  
  48.  
  49.  
  50. /MAIN
  51. int main(int argc, char **argv)
  52. {
  53.  
  54.         int procid;
  55.  
  56.         char* parsec[] =
  57.         {
  58.                 [0] = "blackscholes",
  59.                 [1] = NULL,
  60.         };
  61.  
  62.         char* path[] =
  63.         {
  64.                 [0] = " 1 /parsec-3.0/pkgs/apps/blackscholes/run/in_10M.txt prices.txt",
  65.                 [1] = NULL
  66.         };
  67.  
  68.                 procid =run_apps(parsec[0],path[0]);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement