Process.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* This Hello World demostrate a simple multithread program */
  4. #define DO_BENCH 0
  5. #include "pal.h"
  6. #include "pal_debug.h"
  7. #include "api.h"
  8. int main (int argc, char ** argv)
  9. {
  10. int count = 0, i;
  11. #if DO_BEACH != 1
  12. pal_printf("In process: %s", argv[0]);
  13. for (i = 1 ; i < argc ; i++)
  14. pal_printf(" %s", argv[i]);
  15. pal_printf("\n");
  16. #endif
  17. if (argc == 1) {
  18. unsigned long time = DkSystemTimeQuery ();
  19. char time_arg[24];
  20. pal_snprintf(time_arg, 24, "%ld", time);
  21. const char * newargs[4] = { "Process", "0", time_arg, NULL };
  22. PAL_HANDLE proc = DkProcessCreate ("file:Process", 0, newargs);
  23. DkObjectClose(proc);
  24. } else {
  25. count = atoi (argv[1]);
  26. if (count < 3)
  27. {
  28. count++;
  29. char count_arg[8];
  30. pal_snprintf(count_arg, 8, "%d", count);
  31. const char * newargs[4] = { "Process", count_arg, argv[2], NULL };
  32. PAL_HANDLE proc = DkProcessCreate ("file:Process", 0, newargs);
  33. DkObjectClose(proc);
  34. } else {
  35. unsigned long end = DkSystemTimeQuery ();
  36. unsigned long start = atol (argv[2]);
  37. pal_printf ("wall time = %d\n", end - start);
  38. }
  39. }
  40. return 0;
  41. }