home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / amiga / programm / 16137 < prev    next >
Encoding:
Text File  |  1992-11-20  |  5.4 KB  |  113 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!stanford.edu!rock!concert!samba!usenet
  3. From: Todd_Lewis@unc.edu (Todd M. Lewis)
  4. Subject: Re: Subtasks, IEEE library pointers - y.a.Q
  5. Message-ID: <1992Nov20.152734.17492@samba.oit.unc.edu>
  6. Sender: usenet@samba.oit.unc.edu
  7. Nntp-Posting-Host: guitar.oit.unc.edu
  8. Organization: UNC Office of Information Technology
  9. References: <1egvqcINNfos@hpsdln.sdd.hp.com>
  10. Date: Fri, 20 Nov 1992 15:27:34 GMT
  11. Lines: 100
  12.  
  13. In article <1egvqcINNfos@hpsdln.sdd.hp.com> denson@sdd.hp.com (Craig Denson)  
  14. writes:
  15. >In article <1992Nov19.150345.19491@samba.oit.unc.edu> Todd_Lewis@unc.edu (Todd  
  16. M. Lewis) writes:
  17. >
  18.   [ If I open the same library twice and the library pointers returned
  19.     by OpenLibrary() are not equal, then ... ]
  20. >>...  I've got different library
  21. >>bases and there is no reasonable way to write subtasks that handle
  22. >>that..
  23. >
  24. >  this is where i lose the thread.
  25.  
  26. OpenLibrary() is documented as returning a pointer to a Library (or NULL
  27. on failure).  What it doesn't say, but happens with some, perhaps many,
  28. libraries, is that in the process of opening, the library can inflict
  29. whatever side effects it deems fit on the opening task/process.  That
  30. in itself is not a problem as long as the effects are well-documented
  31. and are guaranteed not to change in later versions of the library.  So
  32. to be safe (and for the aesthetics of good design) every task that
  33. uses a library should explicitly open and close each library it uses.
  34. So far so good.
  35.  
  36. Your next series of questions hit practically every point I have been
  37. trying in vein to make on this issue.  Let me take them one at a time.
  38.  
  39. >  What is in these libraries that must be the same?
  40.  
  41. Libraries are supposed to be black boxes, so the answer is supposed
  42. to be "I don't know and I don't need to know."
  43.  
  44. > If it's a copy of the same code at a different
  45. > location why should you care? are the bits a different color? :-) 
  46.  
  47. I cannot know that it's the same code.  I (you) can only know the 
  48. location.  When one part of your program (the main task, say) has
  49. to reference the library through the same base variable that other
  50. parts (subtask 1-99) have to use and each one needs that variable to
  51. point at a different place, there is no practical way that I know of
  52. to handle it with the current tools available.  It isn't even pretty
  53. in assembler, much less C etc.
  54.  
  55. Note that with the new SAS C compiler you can easily create libraries
  56. which return a different base pointer each time they are opened, so
  57. the question of how subtasks handle different pointers to the same
  58. libraries is real, not just an academic question.
  59.  
  60. >  what's in the libraries that isn't relocatable?
  61.  
  62. Again, you have no way of knowing.  I didn't write these libraries,
  63. these issues apply to any library that works in anything other than
  64. the "obvious" way.  You aren't supposed to have to know.
  65.  
  66. >  or are you using library data as part of your application's data structure?  
  67. >  - that doesn't sound too good.
  68.  
  69. NAIL ON THE HEAD!  Give that man a banana.  Libraries are free to use your
  70. application's data structure (the task/process structure and who
  71. knows what else) in any way they want, and you can only hope they
  72. document what they are doing and that they don't change strategies on
  73. you in the next release (after you've got code running on customers
  74. machines that follows the rules for the current release) and that
  75. their side effects don't conflict with those of other libraries you
  76. need to use.  I agree with you 100%, "that doesn't sound too good." 
  77.  
  78. We've screwed this up once in a big way, and it would be nice to avoid
  79. the mistake in the future.  Take two of the most popular libraries on the
  80. Amiga: graphics.library and DOS library.  One did it right, the other
  81. has the problem you so succinctly described--using library data as part
  82. of [the] application's data structure.  The DOS process information
  83. should not be so tightly coupled to the task structure.
  84.  
  85. Imagine how screwed up things would be if instead the RastPort was
  86. coupled with the task struct and the process struct was stand-alone
  87. like the RastPort is now. A task could open the DOS library and "own" as
  88. many processes as it needed--you could have one "current directory"
  89. on df0: and another on "dh0:", and lots of the problems with using DOS
  90. today simply disappear. The catch is that with one RastPort so tied
  91. to the task struct you could only draw to one RastPort at a time.  Need to
  92. draw somewhere else?  "oldRast = CurrentRast(NewRast)" would solve
  93. the problem.  Ridiculous you say, but that is exactly what we do now
  94. with DOS and nobody even sees the problem.  The root of the problem isn't
  95. that DOS is badly designed, but that it is needlessly and too closely
  96. coupled to the task struct.
  97.  
  98. In the context of this discussion, the lesson above should point out
  99. that writing libraries which impose such tight coupling with their
  100. opening tasks on an ad hoc basis is open invitation to
  101. incompatibility.  My big beef is the multiple subtask problem, but
  102. that's just because I've been doing a lot with subtasks lately.  The
  103. beauty of the Amiga's shared library is that it is a black box that any
  104. program can use.  Now we have groups of libraries which, because of
  105. these side effects, cannot be used by one program at the same time.    
  106.  
  107. >craig
  108. ---
  109.      Todd M. Lewis / Todd_Lewis@unc.edu / utoddl@guitar.oit.unc.edu
  110.  Another Month Ends / All Targets Met / All Systems Working / All Customers  
  111. Satisfied / All Staff Eager and Enthusiastic / All Pigs Fed and Ready to Fly
  112.  
  113.