home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 11.ddi / SSCOPE.LIF / CMAIN.LST < prev    next >
Encoding:
File List  |  1992-07-02  |  10.8 KB  |  217 lines

  1. iC-386  COMPILER   CMAIN                                                                     09/05/90 12:10:36  PAGE   1
  2.  
  3.  
  4. iRMX III iC-386 COMPILER V4.3, COMPILATION OF MODULE CMAIN
  5. OBJECT MODULE PLACED IN cmain.obj
  6. COMPILER INVOKED BY: :lang:ic386 cmain.c compact object(cmain.obj) print(cmain.lst) ram optimize(0) dn(0) debug define(r
  7.                 -mx3) searchinclude(/lib/ic386/) 
  8.  
  9.  line level  incl 
  10.  
  11.     1             /*********************************************************/
  12.     2             /*                                                       */
  13.     3             /*                   CSAMP Sample Program                */
  14.     4             /*                                                       */
  15.     5             /*********************************************************/ 
  16.     6                              
  17.     7             #include <stdarg.h>
  18.    31             #include <stdlib.h>
  19.   158             #include <stdio.h>
  20.   417             #include <string.h>
  21.   521             #include <ctype.h>
  22.   586             #include <rmxc.h>
  23.  2636             #include "cutils.h"
  24.  2639             
  25.  2640             #define UINT_8      unsigned char
  26.  2641             #define UINT_16     unsigned short
  27.  2642             #define UINT_32     unsigned long
  28.  2643             #define FALSE       0
  29.  2644             #define TRUE        1
  30.  2645             
  31.  2646             #define     COUNT_PRIORITY      200     /* Priority of count task        */
  32.  2647             #define     PROCESS_PRIORITY    200     /* Priority of process task      */
  33.  2648             #define     BUFF_LEN            125     /* Length of buffer in MSG_STRUC */
  34.  2649             #define     DATA_MBOX           0x20    /* Code for creation of data mbx.*/
  35.  2650             #define     MAX_COUNT           0xffff  /* UI16_MAX                      */
  36.  2651             
  37.  2652             UINT_32     module_data;          /* Used in the create task system call */
  38.  2653                                               /* Identifies the data segment         */
  39.  2654             
  40.  2655             typedef struct {
  41.  2656                 short           count;
  42.  2657                 unsigned char   fillchar;
  43.  2658                 unsigned char   buffer[BUFF_LEN];
  44.  2659             } MSG_STRUC;
  45.  2660             
  46.  2661             TOKEN           count_token;        /* Token for count task              */
  47.  2662             TOKEN           process_token;      /* Token for process task            */
  48.  2663             int             counter;            /* count_task's counter              */
  49.  2664             
  50.  2665             void far main()
  51.  2666             {
  52.  2667     1           WORD            exception;  /* Status code returned from system calls    */
  53.  2668     1                   
  54.  2669     1           TOKEN           main_mbox;          /* Token for main task's mailbox     */
  55.  2670     1           TOKEN           proc_mbox;          /* Token for process task's mailbox  */
  56.  2671     1           UINT_16         msg_length;         /* Actual length of received message.*/
  57.  2672     1           MSG_STRUC       msg;                /* Message to be sent/received       */
  58.  2673     1           UINT_16         msg_count;
  59.  2674     1           UINT_16         i;
  60.  2675     1       
  61. iC-386  COMPILER   CMAIN                                                                     09/05/90 12:10:36  PAGE   2
  62.  
  63.  
  64.  2676     1           extern void far count_task ();
  65.  2677     1           extern void far process_task ();
  66.  2678     1           
  67.  2679     1           printf("Soft-Scope III 'C' Sample Session\r\n");
  68.  2680     1       
  69.  2681     1           /*
  70.  2682     1            *  Create the mailbox for main task
  71.  2683     1            */
  72.  2684     1           main_mbox = rqcreatemailbox (DATA_MBOX, &exception);
  73.  2685     1           /*
  74.  2686     1            *  Catalog the mailbox token in the object directory
  75.  2687     1            */
  76.  2688     1           rqcatalogobject (0, main_mbox, (BYTE*)"\010Main Box", &exception);
  77.  2689     1       
  78.  2690     1           /*
  79.  2691     1            *  Create the process mailbox 
  80.  2692     1            */
  81.  2693     1           proc_mbox = rqcreatemailbox (DATA_MBOX, &exception);
  82.  2694     1           /*
  83.  2695     1            *  Catalog the mailbox token in the object directory
  84.  2696     1            */
  85.  2697     1           rqcatalogobject (0, proc_mbox, (BYTE*)"\013Process Box", &exception);
  86.  2698     1       
  87.  2699     1           /*
  88.  2700     1            *  Create tasks...
  89.  2701     1            */
  90.  2702     1           count_token = rqcreatetask (
  91.  2703     1                       COUNT_PRIORITY,                     /* priority.         */
  92.  2704     1                       (void (far *)(void))&count_task,    /* start address.    */
  93.  2705     1                       (selector)&module_data,             /* data segment.     */
  94.  2706     1                       0,                                  /* stack pointer.    */
  95.  2707     1                       4096,                               /* stack size.       */
  96.  2708     1                       0,                                  /* flags (no NPX).   */
  97.  2709     1                       &exception);                        /* exception ptr.    */
  98.  2710     1       
  99.  2711     1           process_token = rqcreatetask (
  100.  2712     1                       PROCESS_PRIORITY,                   /* priority.         */
  101.  2713     1                       (void (far *)(void))&process_task,  /* start address.    */
  102.  2714     1                       (selector)&module_data,             /* data segment.     */
  103.  2715     1                       0,                                  /* stack pointer.    */
  104.  2716     1                       4096,                               /* stack size.       */
  105.  2717     1                       0,                                  /* flags (no NPX).   */
  106.  2718     1                       &exception);                        /* exception ptr.    */
  107.  2719     1       
  108.  2720     1           msg_count = 0;
  109.  2721     1           while(1)  {
  110.  2722     2               msg.fillchar = '*';
  111.  2723     2               if (msg_count >= MAX_COUNT)
  112.  2724     2                   msg_count = 0;
  113.  2725     2               else
  114.  2726     2                   msg.count = msg_count++;
  115.  2727     2               memset (msg.buffer, 0, sizeof (msg.buffer));
  116.  2728     2               /*
  117.  2729     2                *  Send data to process task to fill msg.buffer with fillchar
  118.  2730     2                */
  119.  2731     2               rqsenddata (main_mbox, 
  120.  2732     2                           (BYTE *)&msg, 
  121. iC-386  COMPILER   CMAIN                                                                     09/05/90 12:10:36  PAGE   3
  122.  
  123.  
  124.  2733     2                           sizeof (msg), 
  125.  2734     2                           &exception);    
  126.  2735     2               /*
  127.  2736     2                *  Receive data back from process task 
  128.  2737     2                */
  129.  2738     2               msg_length = rqreceivedata (proc_mbox,
  130.  2739     2                                            (BYTE *)&msg,
  131.  2740     2                                            0xffff,
  132.  2741     2                                            &exception);
  133.  2742     2           }
  134.  2743     1       }
  135.  2744             
  136.  2745             
  137.  2746             
  138.  2747             void far process_task ()
  139.  2748             {
  140.  2749     1           WORD            exception;  /* Status code returned from system calls    */
  141.  2750     1           TOKEN           main_mbox;  /* Token for the read meter task's mailbox.  */
  142.  2751     1           TOKEN           proc_mbox;  /* Token for update database task's mailbox. */
  143.  2752     1           UINT_16         msg_length; /* Actual length of received message.        */
  144.  2753     1           MSG_STRUC       msg;        /* Message to be processed.                  */
  145.  2754     1           unsigned char   pattern;
  146.  2755     1           UINT_8          i;
  147.  2756     1           
  148.  2757     1           /*
  149.  2758     1            *  Lookup the process task mailbox token from the object
  150.  2759     1            *  directory.
  151.  2760     1            */
  152.  2761     1           proc_mbox = rqlookupobject (0, (BYTE*) "\013Process Box", 0xffff, &exception);
  153.  2762     1       
  154.  2763     1           /*
  155.  2764     1            *  Lookup the main task mailbox token from the object
  156.  2765     1            *  directory.
  157.  2766     1            */
  158.  2767     1           main_mbox = rqlookupobject (0, (BYTE*) "\010Main Box", 0xffff, &exception);
  159.  2768     1       
  160.  2769     1           /*
  161.  2770     1            *  Loop forever responding to requests.
  162.  2771     1            */ 
  163.  2772     1           while (1)  {    
  164.  2773     2               
  165.  2774     2               /*
  166.  2775     2                *  Receive the next request 
  167.  2776     2                */
  168.  2777     2               msg_length = rqreceivedata (main_mbox,
  169.  2778     2                                            (BYTE *)&msg,
  170.  2779     2                                            0xffff,
  171.  2780     2                                            &exception);
  172.  2781     2       
  173.  2782     2               /*
  174.  2783     2                *  Take action on the received message (fill msg.buffer)
  175.  2784     2                */
  176.  2785     2               for (i = 0; i < BUFF_LEN; i++)  {
  177.  2786     3                   msg.buffer[i] = msg.fillchar;
  178.  2787     3               }
  179.  2788     2       
  180.  2789     2               delay (1000);       /*  Sleep for about 1 sec. so others can run.    */
  181. iC-386  COMPILER   CMAIN                                                                     09/05/90 12:10:36  PAGE   4
  182.  
  183.  
  184.  2790     2               /*
  185.  2791     2                *  Send response
  186.  2792     2                */
  187.  2793     2               rqsenddata (proc_mbox, 
  188.  2794     2                           (BYTE *)&msg, 
  189.  2795     2                           sizeof (msg), 
  190.  2796     2                           &exception);    
  191.  2797     2           }
  192.  2798     1       }
  193.  2799             
  194.  2800             void far count_task ()
  195.  2801             {
  196.  2802     1           WORD            exception;  /* Status code returned from system calls    */
  197.  2803     1       
  198.  2804     1           counter = 0;
  199.  2805     1       
  200.  2806     1           while (1)  {
  201.  2807     2               counter++;
  202.  2808     2               delay (1000);
  203.  2809     2               c_data ();
  204.  2810     2           }
  205.  2811     1       }
  206.  
  207.  
  208.  
  209. MODULE INFORMATION:
  210.  
  211.      CODE AREA SIZE               = 00000300H         768D
  212.      CONSTANT AREA SIZE           = 00000052H          82D
  213.      DATA AREA SIZE               = 0000000CH          12D
  214.      MAXIMUM STACK SIZE           = 000000BCH         188D
  215.  
  216. iC-386 COMPILATION COMPLETE.      0 REMARKS,     0 WARNINGS,     0 ERRORS
  217.