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

  1. /***************************************************************************
  2.  *                                                                         *
  3.  * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  4.  * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  5.  * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  6.  * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  7.  * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  8.  *                                                                         *
  9.  *              A compiler for distributed programming with C              *
  10.  *                                                                         *
  11.  *                          p r o d u c e r . d c                          *
  12.  *                                                                         *
  13.  *                 Version 1.0      CreationDate: 17.07.91                 *
  14.  *                                    LastUpDate: 17.07.91                 *
  15.  *                                                                         *
  16.  *    Process building a producer for 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. /* definition of the process 'producer' */
  25. process body producer(num, buffer_descr, msgnum)
  26. {
  27.     long         msg_count;    /* to count the produced messages */
  28.     struct msg_t msg;    /* to store the actual message */
  29.  
  30.     for(msg_count = 0; msg_count < msgnum; ++msg_count) {
  31.         sprintf(msg.name, "producer: %d", num);
  32.         msg.value = msg_count;
  33.         do {
  34.         } while(buffer_descr@b_write(msg) == ERROR);
  35.     }
  36.     exit(0);
  37. } /* process body producer */
  38.