home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / programm / 3320 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.6 KB  |  73 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!haven.umd.edu!ames!agate!linus!linus.mitre.org!crawford
  3. From: crawford@boole.mitre.org (Randy Crawford)
  4. Subject: Re: reentrant code
  5. Message-ID: <1992Dec14.160110.26338@linus.mitre.org>
  6. Originator: crawford@boole.mitre.org
  7. Sender: crawford@boole (Randy Crawford)
  8. Nntp-Posting-Host: boole.mitre.org
  9. Organization: The MITRE Corporation, McLean, VA
  10. References: <GARY.92Dec9104702@kuwait.gdfwc3> <1992Dec10.045716.12505@linus.mitre.org> <dak.724201089@messua> <1992Dec13.051634.14815@linus.mitre.org> <1992Dec13.221314.26971@nntpd.lkg.dec.com>
  11. Date: Mon, 14 Dec 1992 16:01:10 GMT
  12. Lines: 59
  13.  
  14.  
  15. In article <1992Dec13.221314.26971@nntpd.lkg.dec.com>, mjg@ktbush.ogo.dec.com (Michael J. Grier) writes:
  16. > In article <1992Dec13.051634.14815@linus.mitre.org>, crawford@boole.mitre.org (Randy Crawford) writes:
  17. > |>
  18. > |>>The problems of reentrancy are a bit different from concurrency. 
  19. > |>
  20. > |>True, but reentrancy is irrelevant unless concurrency in some form (like
  21. > |>context switching) is involved.
  22. > |>
  23. >    Untrue.  Consider a module which implements an abstraction of a queue
  24. > or other searching structure, which provides a service for iteration on the
  25. > data structure.  If you specify the service such that the caller provides
  26. > a function to execute for each element in the structure, there is again
  27. > a need for reentrancy controls of some fashion.
  28.  
  29. Only if one part of the search cannot continue to completion before another
  30. part begins (or resumes).  This is still concurrency (or concurrent sub-
  31. tasks) no matter how you look at it.  When you have communicating concurrent
  32. threads/processes/tasks/contexts/callbacks, you have concurrency.
  33.  
  34. >    The reentrancy controls may be as simple as documenting, "Do not attempt
  35. > to modify the data structure from the callback function.  If you do, the
  36. > world may come crashing down about your ears."
  37. >    On the other hand, you might try to do something more intelligent and/or
  38. > pro-active in the area, either setting a "busy" flag for the data structure,
  39. > and/or making a copy of the data before beginning the iteration process.
  40. > This takes time and memory.  [I prefer to provide both sorts of interfaces -
  41. > ones which are faster but have more operational constraints, and safer ones
  42. > which cost more.]
  43.  
  44. Busy flags are unnecessary unless you have multiple concurrent (sub)tasks.
  45. Why have a busy flag unless at least two entities need to know whether a
  46. common resource is available?  This necessarily implies some form of resource 
  47. sharing and therefore, concurrency.  Resource sharing isn't a problem if only
  48. one agent at a time requests them.
  49.  
  50. When you reduce the dining philosopher problem to one live philosopher and
  51. two dead ones, you no longer have any problem sharing resources -- and no
  52. more concurrency.
  53.  
  54. >    My point is that reentrancy isn't a Boolean valued quality of a particular
  55. > service/procedure/function.  You may be reentrant from a signal point of
  56. > view, but not from a multi-threaded point of view.  My first example does not
  57. > use concurrency according to any definition with which I am familliar.
  58.  
  59. A `signal-reentrant' point of view is no different from a `multi-threaded' point 
  60. of view in terms of resource use -- both are composed of multiple executing 
  61. contexts which must share common resources, possibly at the same time.  In those 
  62. terms, both are undoubtedly forms of concurrency.
  63. -- 
  64.  
  65. | Randy Crawford        crawford@mitre.org        The MITRE Corporation
  66. |                                                 7525 Colshire Dr., MS Z421
  67. | N=1 -> P=NP           703 883-7940              McLean, VA  22102
  68.