home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / multitask / test.c < prev   
Encoding:
C/C++ Source or Header  |  1996-12-24  |  817 b   |  49 lines

  1. /* Example program that uses the functions define in process.c */
  2.  
  3. #include "process.h"
  4.  
  5. long process1(void)
  6. {
  7.    long out;
  8.    char buff[1];
  9.    char *a;
  10.    
  11.    /* Cause an enforcer hit */
  12.    a = NULL;
  13.    *a = 0;
  14.  
  15.    out = Open("CON:10/120/520/80/New Process 1", MODE_OLDFILE);
  16.    if (out == NULL) return -1;
  17.  
  18.    Write(out, "Hit Return to Close Window\n", 27);
  19.    Read(out, buff, 1);
  20.  
  21.    Close(out);
  22.    return 1;
  23. }
  24.  
  25.  
  26. main(argc, argv)
  27. int argc;
  28. char *argv[];
  29. {
  30.    struct ProcMsg *start_msg1;
  31.    long ret;
  32.    
  33.    /* Start process 1 */
  34.    start_msg1 = start_process(process1, 0, 4000);
  35.    if (start_msg1 == NULL)
  36.    {
  37.       printf("Can't start process 1\n");
  38.       exit(1);
  39.    }
  40.    
  41.    /* Wait for processes to finish */
  42.    ret = wait_process(start_msg1);
  43.    printf("Return from process 1 is %d\n",ret);
  44.  
  45.    exit(0);
  46. }
  47.  
  48.  
  49.