home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- * *
- * @@@@ @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@ @ @ @@@@@ @@@@@ @@@@ @@@ *
- * @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ *
- * @ @ @ @@@@@ @ @@@@@ @ @@@@@ @ @ @ @@@@@ @ @ @ *
- * @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ *
- * @@@@ @@@ @@@@@ @ @ @ @@@ @@@@ @@@@@ @ @@@@@ @@@@ @@@ *
- * *
- * A compiler for distributed programming with C *
- * *
- * h e l l o . d c *
- * *
- * Version 1.0 CreationDate: 01.09.93 *
- * LastUpDate: 01.09.93 *
- * *
- * A simple example: the Distributed C version of Kernighan and Ritchie's *
- * example "Hello world". *
- * *
- ***************************************************************************/
-
- #include <stdio.h>
-
- #define UNLIMITED 1
- #define MAXPROCNUM 50
-
- /* specification of the process Print_Greetings with the transaction Say_Hello */
- process spec Print_Greetings(int process_number)
- {
- trans void Say_Hello();
- }
-
- /* definition of the process Print_Greetings with the transaction Say_Hello */
- process body Print_Greetings(process_number)
- {
- while(UNLIMITED) {
- select {
- accept Say_Hello() {
- printf("Hello world! I am process %d.\n", process_number);
- fflush(stdout);
- }; /* a semicolon is required here! */
- or terminate
- }
- }
- }
-
- /* definition of the main process */
- main()
- {
- int number_of_processes, i;
- process Print_Greetings descr[MAXPROCNUM];
-
- printf("How many processes do you want to create? ");
- scanf("%d", &number_of_processes);
- /* create number_of_processes processes */
- for(i=1; i<=number_of_processes; i++)
- descr[i] = create Print_Greetings( i );
- /* order each process to display the greetings */
- for(i=1; i<=number_of_processes; i++)
- descr[i]@Say_Hello();
- exit(0);
- }
-
-