home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / distributed-c-2.1 / part01 / examples / prod_cons / main.dc < prev    next >
Encoding:
Text File  |  1993-12-22  |  2.4 KB  |  57 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  4.  * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  5.  * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  6.  * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  7.  * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  8.  *                                                                         *
  9.  *              A compiler for distributed programming with C              *
  10.  *                                                                         *
  11.  *                            m a i n . d c                                *
  12.  *                                                                         *
  13.  *                 Version 1.0      CreationDate: 17.07.91                 *
  14.  *                                    LastUpDate: 17.07.91                 *
  15.  *                                                                         *
  16.  *The main program starting all processes of the producer/consumer example.*
  17.  *                                                                         *
  18.  *              Copyright (C) 1990,1991 by Christoph Pleier.               *
  19.  *                          All rights reserved!                           *
  20.  ***************************************************************************/
  21.  
  22. #include "config.h"
  23.  
  24. main()
  25. {
  26.     long           i,        /* loop counter */
  27.                    prod_num,    /* number of producers to create */
  28.                    cons_num,    /* number of consumers to create */
  29.                    msgnum;        /* number of message to produce */
  30.     process buffer b;        /* process descriptor of buffer */
  31.  
  32.     printf("\nProducer/Consument:\n\n");
  33.     printf("How many producer processes should be started? ");
  34.     scanf("%d", &prod_num);
  35.     printf("How many messages should each producer process produce? ");
  36.     scanf("%d", &msgnum);
  37.     printf("How many consumer processes should be started? ");
  38.     scanf("%d", &cons_num);
  39.  
  40.     printf("\ncreating buffer...");
  41.     fflush(stdout);
  42.     b = create buffer();
  43.     puts("done!");
  44.  
  45.     printf("creating consumer(s)...");
  46.     fflush(stdout);
  47.     for(i = 1; i <= cons_num; i++)
  48.         create consumer(i, b);
  49.     puts("done!");
  50.  
  51.     printf("creating producer(s)...");
  52.     fflush(stdout);
  53.     for(i = 1; i <= prod_num; i++)
  54.         create producer(i, b, msgnum);
  55.     puts("done!\n");
  56. }
  57.