home *** CD-ROM | disk | FTP | other *** search
File List | 1992-07-02 | 10.8 KB | 217 lines |
- iC-386 COMPILER CMAIN 09/05/90 12:10:36 PAGE 1
-
-
- iRMX III iC-386 COMPILER V4.3, COMPILATION OF MODULE CMAIN
- OBJECT MODULE PLACED IN cmain.obj
- COMPILER INVOKED BY: :lang:ic386 cmain.c compact object(cmain.obj) print(cmain.lst) ram optimize(0) dn(0) debug define(r
- -mx3) searchinclude(/lib/ic386/)
-
- line level incl
-
- 1 /*********************************************************/
- 2 /* */
- 3 /* CSAMP Sample Program */
- 4 /* */
- 5 /*********************************************************/
- 6
- 7 #include <stdarg.h>
- 31 #include <stdlib.h>
- 158 #include <stdio.h>
- 417 #include <string.h>
- 521 #include <ctype.h>
- 586 #include <rmxc.h>
- 2636 #include "cutils.h"
- 2639
- 2640 #define UINT_8 unsigned char
- 2641 #define UINT_16 unsigned short
- 2642 #define UINT_32 unsigned long
- 2643 #define FALSE 0
- 2644 #define TRUE 1
- 2645
- 2646 #define COUNT_PRIORITY 200 /* Priority of count task */
- 2647 #define PROCESS_PRIORITY 200 /* Priority of process task */
- 2648 #define BUFF_LEN 125 /* Length of buffer in MSG_STRUC */
- 2649 #define DATA_MBOX 0x20 /* Code for creation of data mbx.*/
- 2650 #define MAX_COUNT 0xffff /* UI16_MAX */
- 2651
- 2652 UINT_32 module_data; /* Used in the create task system call */
- 2653 /* Identifies the data segment */
- 2654
- 2655 typedef struct {
- 2656 short count;
- 2657 unsigned char fillchar;
- 2658 unsigned char buffer[BUFF_LEN];
- 2659 } MSG_STRUC;
- 2660
- 2661 TOKEN count_token; /* Token for count task */
- 2662 TOKEN process_token; /* Token for process task */
- 2663 int counter; /* count_task's counter */
- 2664
- 2665 void far main()
- 2666 {
- 2667 1 WORD exception; /* Status code returned from system calls */
- 2668 1
- 2669 1 TOKEN main_mbox; /* Token for main task's mailbox */
- 2670 1 TOKEN proc_mbox; /* Token for process task's mailbox */
- 2671 1 UINT_16 msg_length; /* Actual length of received message.*/
- 2672 1 MSG_STRUC msg; /* Message to be sent/received */
- 2673 1 UINT_16 msg_count;
- 2674 1 UINT_16 i;
- 2675 1
- iC-386 COMPILER CMAIN 09/05/90 12:10:36 PAGE 2
-
-
- 2676 1 extern void far count_task ();
- 2677 1 extern void far process_task ();
- 2678 1
- 2679 1 printf("Soft-Scope III 'C' Sample Session\r\n");
- 2680 1
- 2681 1 /*
- 2682 1 * Create the mailbox for main task
- 2683 1 */
- 2684 1 main_mbox = rqcreatemailbox (DATA_MBOX, &exception);
- 2685 1 /*
- 2686 1 * Catalog the mailbox token in the object directory
- 2687 1 */
- 2688 1 rqcatalogobject (0, main_mbox, (BYTE*)"\010Main Box", &exception);
- 2689 1
- 2690 1 /*
- 2691 1 * Create the process mailbox
- 2692 1 */
- 2693 1 proc_mbox = rqcreatemailbox (DATA_MBOX, &exception);
- 2694 1 /*
- 2695 1 * Catalog the mailbox token in the object directory
- 2696 1 */
- 2697 1 rqcatalogobject (0, proc_mbox, (BYTE*)"\013Process Box", &exception);
- 2698 1
- 2699 1 /*
- 2700 1 * Create tasks...
- 2701 1 */
- 2702 1 count_token = rqcreatetask (
- 2703 1 COUNT_PRIORITY, /* priority. */
- 2704 1 (void (far *)(void))&count_task, /* start address. */
- 2705 1 (selector)&module_data, /* data segment. */
- 2706 1 0, /* stack pointer. */
- 2707 1 4096, /* stack size. */
- 2708 1 0, /* flags (no NPX). */
- 2709 1 &exception); /* exception ptr. */
- 2710 1
- 2711 1 process_token = rqcreatetask (
- 2712 1 PROCESS_PRIORITY, /* priority. */
- 2713 1 (void (far *)(void))&process_task, /* start address. */
- 2714 1 (selector)&module_data, /* data segment. */
- 2715 1 0, /* stack pointer. */
- 2716 1 4096, /* stack size. */
- 2717 1 0, /* flags (no NPX). */
- 2718 1 &exception); /* exception ptr. */
- 2719 1
- 2720 1 msg_count = 0;
- 2721 1 while(1) {
- 2722 2 msg.fillchar = '*';
- 2723 2 if (msg_count >= MAX_COUNT)
- 2724 2 msg_count = 0;
- 2725 2 else
- 2726 2 msg.count = msg_count++;
- 2727 2 memset (msg.buffer, 0, sizeof (msg.buffer));
- 2728 2 /*
- 2729 2 * Send data to process task to fill msg.buffer with fillchar
- 2730 2 */
- 2731 2 rqsenddata (main_mbox,
- 2732 2 (BYTE *)&msg,
- iC-386 COMPILER CMAIN 09/05/90 12:10:36 PAGE 3
-
-
- 2733 2 sizeof (msg),
- 2734 2 &exception);
- 2735 2 /*
- 2736 2 * Receive data back from process task
- 2737 2 */
- 2738 2 msg_length = rqreceivedata (proc_mbox,
- 2739 2 (BYTE *)&msg,
- 2740 2 0xffff,
- 2741 2 &exception);
- 2742 2 }
- 2743 1 }
- 2744
- 2745
- 2746
- 2747 void far process_task ()
- 2748 {
- 2749 1 WORD exception; /* Status code returned from system calls */
- 2750 1 TOKEN main_mbox; /* Token for the read meter task's mailbox. */
- 2751 1 TOKEN proc_mbox; /* Token for update database task's mailbox. */
- 2752 1 UINT_16 msg_length; /* Actual length of received message. */
- 2753 1 MSG_STRUC msg; /* Message to be processed. */
- 2754 1 unsigned char pattern;
- 2755 1 UINT_8 i;
- 2756 1
- 2757 1 /*
- 2758 1 * Lookup the process task mailbox token from the object
- 2759 1 * directory.
- 2760 1 */
- 2761 1 proc_mbox = rqlookupobject (0, (BYTE*) "\013Process Box", 0xffff, &exception);
- 2762 1
- 2763 1 /*
- 2764 1 * Lookup the main task mailbox token from the object
- 2765 1 * directory.
- 2766 1 */
- 2767 1 main_mbox = rqlookupobject (0, (BYTE*) "\010Main Box", 0xffff, &exception);
- 2768 1
- 2769 1 /*
- 2770 1 * Loop forever responding to requests.
- 2771 1 */
- 2772 1 while (1) {
- 2773 2
- 2774 2 /*
- 2775 2 * Receive the next request
- 2776 2 */
- 2777 2 msg_length = rqreceivedata (main_mbox,
- 2778 2 (BYTE *)&msg,
- 2779 2 0xffff,
- 2780 2 &exception);
- 2781 2
- 2782 2 /*
- 2783 2 * Take action on the received message (fill msg.buffer)
- 2784 2 */
- 2785 2 for (i = 0; i < BUFF_LEN; i++) {
- 2786 3 msg.buffer[i] = msg.fillchar;
- 2787 3 }
- 2788 2
- 2789 2 delay (1000); /* Sleep for about 1 sec. so others can run. */
- iC-386 COMPILER CMAIN 09/05/90 12:10:36 PAGE 4
-
-
- 2790 2 /*
- 2791 2 * Send response
- 2792 2 */
- 2793 2 rqsenddata (proc_mbox,
- 2794 2 (BYTE *)&msg,
- 2795 2 sizeof (msg),
- 2796 2 &exception);
- 2797 2 }
- 2798 1 }
- 2799
- 2800 void far count_task ()
- 2801 {
- 2802 1 WORD exception; /* Status code returned from system calls */
- 2803 1
- 2804 1 counter = 0;
- 2805 1
- 2806 1 while (1) {
- 2807 2 counter++;
- 2808 2 delay (1000);
- 2809 2 c_data ();
- 2810 2 }
- 2811 1 }
-
-
-
- MODULE INFORMATION:
-
- CODE AREA SIZE = 00000300H 768D
- CONSTANT AREA SIZE = 00000052H 82D
- DATA AREA SIZE = 0000000CH 12D
- MAXIMUM STACK SIZE = 000000BCH 188D
-
- iC-386 COMPILATION COMPLETE. 0 REMARKS, 0 WARNINGS, 0 ERRORS
-