home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / wizards / 5240 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.8 KB

  1. Path: sparky!uunet!auspex-gw!guy
  2. From: guy@Auspex.COM (Guy Harris)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: What is text, data & bss anyway?
  5. Message-ID: <15907@auspex-gw.auspex.com>
  6. Date: 15 Dec 92 19:34:30 GMT
  7. References: <1992Dec14.234221.6644@saifr00.cfsat.honeywell.com> <1992Dec15.085938.5975@ericsson.se>
  8. Sender: news@auspex-gw.auspex.com
  9. Organization: Auspex Systems, Santa Clara
  10. Lines: 37
  11. Nntp-Posting-Host: auspex.auspex.com
  12.  
  13. >In gcc the following applies:
  14. >
  15. >/* data */ char *s =
  16. >/* text */           "abcd";
  17. >/* bss  */ int i;
  18.  
  19. What does GCC do with
  20.  
  21.     const char foo[] = "abcd";
  22.  
  23. I.e., does it put it in the text or data segments?  (Text segment, I
  24. hope.)
  25.  
  26. >copy-on-write is a cheating system where data, heap, stack or, bss
  27. >segments are marked read only on forking and copied only when one or
  28. >the other process writes to them. It is used to avoid copying data on
  29. >forking as the child process usually doesn't do much work, it basically
  30. >just exec's another program.
  31.  
  32. Actually, copy-on-write is, at least in some systems, not directly
  33. related to forking; that just happens to be one place where it buys you
  34. something.  It may also be used, for example, to:
  35.  
  36.     1) let you set a breakpoint in a process running a shared-text
  37.        program or using a shared library, without screwing over
  38.        anybody else using that program or library (the attempt to
  39.        write the breakpoint causes a copy to be made; the process
  40.        with the breakpoint uses the modified copy, and everybody
  41.        else uses the unmodified copy);
  42.  
  43.     2) allow the run-time loader to do relocation by modifying the
  44.        text of a program or shared library (SunOS 4.x, SVR4 - you
  45.        want to try to avoid having this happen, in general, as it
  46.        reduces the amount of sharing).
  47.  
  48. Also, in most systems these days, the entire segment isn't copied, just
  49. the pages that are actually written to.
  50.