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 #include <dos.h>
38 #include <stdio.h>
39 #include <ws.h>
40 #include <ws_error.h>
41 #include <ws_msg.h>
42 #include <ws_dcls.h>
43 #include <ws_fgb.h>
44 #include <cat.h>
45 #include <wsmincap.h>
46
47 extern int packet_mode;
48 extern local_cat *sleepq;
49 extern local_cat l_CAT[];
50 extern char mysystem;
51
52 i_sleep (p_sleep_ptr)
53 struct sleep_struc *p_sleep_ptr;
54 {
55 int sysid;
56 int major;
57 unsigned int wtime;
58 local_cat *scat1;
59 local_cat *scat2;
60 local_cat *mycat;
61 struct null_msg sleep_msg;
62 unsigned int wstime();
63
64
65
66 if (packet_mode == 0)
67 return (WSNOTACT);
68
69
70
71 major = p_sleep_ptr -> source_major - MIN_CAPABILITY_NUMBER;
72 if ((major < 0) || (major > NUMBER_OF_CAT_ENTRIES))
73 return (WSINVNUM);
74
75 mycat = &l_CAT[major];
76 if (mycat -> mcb_ptr == NULL)
77 return (WSINVMCB);
78
79
80
81 if (mycat -> flags & SLEEPING_BIT)
82 return (WSSLPING);
83
84 mycat -> flags |= SLEEPING_BIT;
85
86
87
88 wtime = p_sleep_ptr -> time;
89 wtime += wstime();
90 mycat -> flags |= SLEEPING_BIT;
91 mycat -> sleep_time = wtime;
92
93
94
95 if (sleepq == NULL)
96 { sleepq = mycat;
97 mycat -> next_cat = NULL;
98 }
99
100
101
102 else if (sleepq -> sleep_time > wtime)
103 { mycat -> next_cat = sleepq;
104 sleepq = mycat;
105 }
106
107
108
109 else for (scat1 = sleepq, scat2 = NULL; scat1 != NULL;)
110 { if (scat1 -> sleep_time > wtime)
111 { mycat -> next_cat = scat1;
112 scat2 -> next_cat = mycat;
113 scat1 = NULL;
114 }
115
116 else if (scat1 -> next_cat == NULL)
117 { scat1 -> next_cat = mycat;
118 scat1 = NULL;
119 }
120
121 else
122 { scat2 = scat1;
123 scat1 = scat2 -> next_cat;
124 }
125 }
126
127
128
129 sleep_msg.system = WSMULTICS;
130 sleep_msg.major = WSMAJCAP;
131 sleep_msg.minor = WS_SET_SLEEP_FLAG;
132 sleep_msg.source_major = p_sleep_ptr -> source_major;
133 sleep_msg.source_system = mysystem;
134 return (send_i_mess(&sleep_msg, sizeof(struct null_msg)-1, NULL, 0));
135 }
136 ^Z