home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / apollo / 3972 < prev    next >
Encoding:
Text File  |  1992-11-16  |  2.2 KB  |  66 lines

  1. Newsgroups: comp.sys.apollo
  2. Path: sparky!uunet!spool.mu.edu!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!apollo.hp.com!netnews
  3. From: ced@APOLLO.HP.COM (Carl Davidson)
  4. Subject: Re: Making /lib/xmlib1.1 a global library in SR10.4
  5. Sender: usenet@apollo.hp.com (Usenet News)
  6. Message-ID: <BxtEAK.Hn1@apollo.hp.com>
  7. Date: Mon, 16 Nov 1992 15:13:32 GMT
  8. References: <1992Nov7.033430.26974@nrtpa038.bnr.ca> <1992Nov13.215059.1429@hpcvusn.cv.hp.com> <BxoDqw.ss@apollo.hp.com>
  9. Nntp-Posting-Host: watson.ch.apollo.hp.com
  10. Organization: Hewlett-Packard Company, Chelmsford, MA
  11. Lines: 53
  12.  
  13. In article <BxoDqw.ss@apollo.hp.com>, ganek@apollo.hp.com (Dan Ganek) writes:
  14. |> 
  15. |> Tom, the main routine of a global library is executed for EVERY process that
  16. |> is started whether it uses it or not. For that reason, global libs should NOT
  17. |> have a main() unless it is absolutely necessary.
  18. |> 
  19. |> (At least that's what I rememebr from the good old days)
  20. |> 
  21. |> /dan
  22.  
  23. [ sound of dust being shaken off Aegis programming skills deleted... ]
  24.  
  25. If you need to do any library initialization, a main() routine 
  26. (more appropriately called an "init" routine) is indispensible. 
  27. There are two things to note:
  28.  
  29.     1. Use rws_$alloc_heap_pool() to allocate any storage needed for
  30.        data which must be globally accessible. For the pool to allocate
  31.        from, use rws_$global_pool. This way the data will be correctly
  32.        mapped in all processes.
  33.  
  34.     2. The library's init routine needs to do the following:
  35.  
  36.        void foo_init(status_$t *status,
  37.                      boolean    global_init)
  38.  
  39.        {
  40.             if (!global_init) {
  41.                 status->all = status_$ok;
  42.                 return;
  43.             }
  44.  
  45.             /*
  46.              * put your library initialization here...
  47.              */
  48.  
  49.             if (initted OK) {
  50.                 status->all = status_$ok;
  51.             } else {
  52.                 status->all = error code;
  53.             }
  54.        }
  55.  
  56.        This way, the initialization code will only get executed
  57.        once, at boot time.
  58.  
  59. Have fun.
  60.  
  61. -- 
  62. Carl Davidson  (508) 436-4361  |
  63. Chelmsford System Software Lab | Microkernels: Where less is more.
  64. The Hewlett-Packard Company    | 
  65. DOMAIN: ced@apollo.hp.com      |
  66.