1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Bull Inc., 1987                *
  4    *                                                         *
  5    * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6    *                                                         *
  7    *********************************************************** */
  8 
  9 /* HISTORY COMMENTS:
 10   1) change(86-09-02,Flegel), approve(87-07-13,MCR7580),
 11      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 12      Created from extract of rcvdata.c
 13   2) change(86-11-11,Flegel), approve(87-07-13,MCR7580),
 14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 15      Call to external_mowse before wsexecap.
 16                                                    END HISTORY COMMENTS */
 17 
 18 /* : PROCEDURE FUNCTION (wakeup):
 19 
 20 Detect whether or not an application is to be awoken because its sleep time has
 21 expired.  If so, a message is generated to the sleeping application.
 22 */
 23 
 24 /* : NOTES:
 25 
 26 This procedure must ONLY be called if it is safe to execute a capability.
 27 */
 28 
 29 #include <stdio.h>
 30 #include <dos.h>
 31 #include <ws.h>
 32 #include <alloc.h>
 33 #include <ws_mcb.h>
 34 #include <cat.h>
 35 #include <ws_fgb.h>
 36 #include <ws_msg.h>
 37 #include <wsmincap.h>
 38 
 39 extern local_cat *sleepq;
 40 extern local_cat l_CAT[];
 41 extern char mysystem;
 42 extern struct allocstr *lcaptr;
 43 
 44 wakeup ()
 45 {
 46 struct null_msg  exerep;      /* Remote message indicating sleep awakeninig */
 47 struct input_msg *msg_ptr;    /* pointer to input message header structure  */
 48 struct fgbstr    *bufp;       /* allocation buffer */
 49 local_cat        *catp;       /* pointer to CAT entry */
 50 char             *p1;         /* Temporary pointers */
 51 int              i;
 52 char             major;       /* Major cap of awakening application */
 53 
 54 /* EXTERNAL CALLS */
 55 unsigned int wstime();
 56 char  *wsalloc();
 57 
 58 
 59 /* MAIN */
 60 
 61 /* : While there are still things to check in the sleep queue */
 62 
 63    catp = sleepq;
 64    while (catp != NULL)
 65 
 66 /* : - if timer not expired then return */
 67 
 68    {  if (catp -> sleep_time > wstime())
 69          return (0);
 70 
 71 /* : -- calculate the major number from the relative offset of the
 72         current one to the start of the table */
 73 
 74       major = (char)((((int)catp - (int)l_CAT) / sizeof (local_cat)) + MIN_CAPABILITY_NUMBER);
 75 
 76 /* : - Allocate message space, if cant then return */
 77 
 78       bufp = (struct fgbstr *) wsalloc (lcaptr,sizeof(struct fgbstr)+sizeof(struct input_msg)-1);
 79       if (bufp == NULL)
 80          return (0);
 81 
 82 /* : - notify remote system that wakeup has occurred */
 83 
 84       exerep.system = WSMULTICS;
 85       exerep.major = WSMAJCAP;
 86       exerep.source_major = major;
 87       exerep.source_system = mysystem;
 88       exerep.minor = WS_RESET_SLEEP_FLAG;
 89       send_i_mess(&exerep, sizeof(struct null_msg) - 1, NULL, 0);
 90 
 91 /* : - create message to wakeup application */
 92 
 93       bufp -> fgb_length = sizeof (struct input_msg);
 94       bufp -> fgb_next = NULL;
 95 
 96       msg_ptr = (struct input_msg *) &bufp -> fgb_char[0];
 97       msg_ptr -> system = mysystem;
 98       msg_ptr -> major = major;
 99       msg_ptr -> minor = WAKE_UP;
100       msg_ptr -> source_system = mysystem;
101       msg_ptr -> source_major = WSMAJCAP;
102 
103 /* : - Adjust the queue for sleeping capabilities */
104 
105       catp -> flags &= ~SLEEPING_BIT;
106       catp -> sleep_time = 0;
107       sleepq = catp -> next_cat;
108       catp -> next_cat = NULL;
109 
110 /* : - Send the message to the application */
111 
112       external_mowse (catp, msg_ptr, sizeof(struct input_msg)-1);
113       wsfree (lcaptr, bufp);
114 
115 /* : - get next CAT entry from sleepq */
116 
117       catp = sleepq;
118    }
119    return (0);
120 }
121 ^Z