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

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