aboutsummaryrefslogtreecommitdiff
path: root/testn.c
blob: 2d09d8201face413f1e08a4c1e0a8ef397ed6061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/***********************************************************************
*
*	Name:  testn.c
*
*	Purpose:  Provides statically-loaded (via linker) test processes
*                 for Round Robin Dispatcher of Module 3.
*
* 	Procedures In Module:
*                             test1 - test process
*                             test2 - test process
*                             test3 - test process
*                             test4 - test process
*                             test5 - test process
*
*       Name:       Processes test1, test2, test3, test4, and test5.
*
*	Algorithm:  Each process prints a message to the screen and gives up
*                   control to the dispatcher using sys_req.  Each process
*                   loops a certain number of times, displaying a message to
*                   the screen inside the loop.  (test1 loops 5 times, test2
*                   loops 10, test3 loops 15, test4 loops 20, and test5 loops
*                   25 times).  Each test process eventually requests
*                   termination.  If a dispatcher dispatches a test process
*                   after it requested termination, it prints a message
*                   indicating so, and the process starts over.
*
*****************************************************************************/

#include <dos.h>
#include "mpx.h"

#define op       1               /* dummy operation request code */
#define type     1               /* dummy operation type */

void test1(void)
{
     char buffer[8];
     int len;
     int i;

     while (1) {
	 	 for (i=1; i <= 5; i++) {
	       printf("\ntest1 dispatched; Value of i = %d",i);
	     	/* give up control to the dispatcher */
	       sys_req(op,type,buffer,&len);
	     }
	     sys_req(EXIT_CODE,0,buffer,&len);
	     printf ("\ntest1 dispatched after it exited!!!");
     }
}


void test2(void)
{
    char buffer[8];
    int len;
    int i;

    while (1) {
		for (i=1; i <= 10; i++) {
	    	printf("\ntest2 dispatched; Value of i = %d",i);
	    	/* give up control to the dispatcher */
	    	sys_req(op,type,buffer,&len);
	}
		sys_req(EXIT_CODE,0,buffer,&len);
		printf ("\ntest1 dispatched after it exited!!!");
    }
}

void test3(void)
{
    char buffer[8];
    int len;
    int i;
    while (1) {
		for (i=1; i <= 15; i++) {
	    	printf("\ntest3 dispatched; Value of i = %d",i);
	    	/* give up control to the dispatcher */
	    	sys_req(op,type,buffer,&len);
		}
		sys_req(EXIT_CODE,0,buffer,&len);
		printf ("\ntest3 dispatched after it exited!!!");
    }
}

void test4(void)
{
    char buffer[8];
    int len;
    int i;

    while (1) {
		for (i=1; i <= 20; i++) {
	    	printf("\ntest4 dispatched; Value of i = %d",i);
	    	/* give up control to the dispatcher */
	    	sys_req(op,type,buffer,&len);
		}
		sys_req(EXIT_CODE,0,buffer,&len);
		printf ("\ntest4 dispatched after it exited!!!");
    }
}

void test5(void)
{
    char buffer[8];
    int len;
    int i;

    while (1) {
		for (i=1; i <= 25; i++) {
	    	printf("\ntest5 dispatched; Value of i = %d",i);
	    	/* give up control to the dispatcher */
	    	sys_req(op,type,buffer,&len);
		}
		sys_req(EXIT_CODE,0,buffer,&len);
		printf ("\ntest5 dispatched after it exited!!!");
    }
}