home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17518 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  6.3 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!diku!bombadil
  2. From: bombadil@diku.dk (Kristian Nielsen)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: A few Handler/FileSys Q's (Mod.Long.)
  5. Keywords: handler filesystem packets Amiga DOS AmigaDOS lock FileLock
  6. Message-ID: <1992Dec18.120551.3866@odin.diku.dk>
  7. Date: 18 Dec 92 12:05:51 GMT
  8. References: <1992Dec17.051905.1@economics.adelaide.edu.au>
  9. Sender: bombadil@embla.diku.dk
  10. Organization: Department of Computer Science, U of Copenhagen
  11. Lines: 116
  12.  
  13. djung@economics.adelaide.edu.au (David Jung) writes:
  14.  
  15. >If I then open a second shell and type 'ls diskname:' (where diskname: is the
  16. >disk I just ejected) - I get the usual "please insert volume diskname in any
  17. >drive".  This is because DOS has discovered the volume node's dol_Task is NULL.
  18.  
  19. >OK - so far so good.
  20.  
  21. >Cancel the requester.  Now - with the disk still ejected - press the space bar
  22. >in the more window until more runs out of buffered file and has to read more
  23. >from the disk.  Now I get a "Please insert volume diskname in device df0:".
  24. >(Note this also happens if the disk has been inserted into the other drive!!)
  25. >(i.e. is wants me to remove it from df1 and insert it into df0!)
  26.  
  27. >Note that it wants df0 not any drive.  I ASSUME the following has happened.
  28.  
  29. >More has asked DOS to read more of the file, and DOS has used the FileLock's
  30. >fl_Task field to decide which handler to send the packet to. (only place
  31. >it can get it from since the volume node's dol_Task is NULL).
  32.  
  33. (the address of the packet is from the file handle, to be precise,
  34. though this handle probably contains a lock to the file).
  35.  
  36. >The handler has recieved a packet containing a lock that it is no longer
  37. >managing (no matching key or whatever) - and has put up the requester asking
  38. >for the volume.  My questions are (finally)
  39.  
  40. >1) How can it do this??
  41.  
  42. >If it called AutoRequest() or ErrorReport() it would be tied up - but it
  43. >still appears to be accepting packets.  If you repeat this whole thing but
  44. >bring up two more windows, then after getting a requester from pressing space
  45. >in the first more window - if you press space in the second window a second
  46. >identical requester appears.  if my ASSUMPTION is correct - the handler has
  47. >received another packet and done the same thing.
  48.  
  49. Usually, this feature is refered to by saying that the ROM filesystems
  50. are multi-threaded. Now I don't claim to be an expert on the ROM file
  51. systems, and I've never seen the actual code, of course. But from my own
  52. experience with handlers and from various rumors I have some idea of how
  53. this is done (hopefully someone will correct me if nessesary).
  54.  
  55. One way to achive multi-threadedness in a handler is to use coroutines
  56. ('Structured Computer Organisation' by Tannenbaum describe these; I
  57. understand that they are also used in modula2). Basically, several
  58. threads of executions are managed in a single task context. For example,
  59. a filing system will communicate with trackdisk.device, timer.device,
  60. applications (receiving packets) and intuition (for requesters). All of
  61. these communications take place using exec messages. The handler has a
  62. central loop waiting for messages on any of the corresponding ports.
  63. Each time a message is received, the handler branches off to the
  64. relevant code.
  65.  
  66. Now, say the handler has to put up a requester. This is done in the
  67. usual way using EasyRequest() or whatever. The usual approach would
  68. be to have some code like
  69.  
  70.     EasyRequest(winptr, &myrequest);
  71.     WaitPort(myicdmport);
  72.  
  73. However, this would lock out *ANY* access to the file system while the
  74. requester was being displayed. To avoid this, the WaitPort() is replaced
  75. by a coroutine context switch to the coroutine doing the central handler
  76. loop. Later, when the requester is satisfied, the coroutine doing the
  77. EasyRequest() will be resumed.
  78.  
  79. The usual way to implement coroutines involve having seperate stacks for
  80. each coroutine, swapping them when nessesary. The ROM file systems may
  81. do it differently, we'd need one of the commodore gurus to give the
  82. details.
  83.  
  84. >2) Is it legal, as a filesystem, to set the FileLock's fl_Task fields to
  85. >NULL before putting them on the dol_LockList when a volume has been removed?
  86. >Or is this rubbish. (wishfully thinking DOS might put up a requester for me)
  87.  
  88. Well, the term 'legal' is not particulary well defined when the
  89. questions are about dos device handlers, since the documentation tends
  90. to be VERY sparse. Still, I don't think it could possibly be valid to
  91. zero the fl_Task field. You cannot rely on dos.library putting up
  92. requesters since the packet may be sent directly from applications (ie.
  93. ixemul.library by Marcus Wild). For this reason, lock->fl_Task MUST
  94. remain valid at all times.
  95.  
  96. >3) As a filesystem, if a volume has just been inserted into the device you're
  97. >managing, and you grab the locks from the dol_LockList, can you Forbid(), go
  98. >through and change the fl_Task field of all the locks to yourself, then Permit()
  99. >so that any further use of the active FileLocks will be directed to you?
  100.  
  101. (minor detail: in 2.0 you use LockDoslist() / UnlockDoslist() instead of
  102. Forbid() / Permit(). )
  103.  
  104. I don't think this should be done. I can hardly imagine it's 'legal',
  105. for one. Just imagine the instant disaster that would result if you
  106. somehow mixed of a volume belonging to a completely alien file system!
  107. Anyway, it shouldn't be nessesary to do this.
  108.  
  109. >4) If, again as a filesystem, I get an argument FileLock for a volume I am
  110. >no longer managing (volume was ejected from my device), can I, upon inspection
  111. >of the DosList finding a non-NULL dol_Task field, send the packet onto
  112. >the other filesystem that is managing the volume now (assuming the dol_Task
  113. >field is non-NULL because the volume has been inserted into another device).
  114. >I would have to set up the packet so it was returned either to me, or directly
  115. >to the application/DOS.
  116.  
  117. Again, the best thing to do would be to ask for the volume to be
  118. inserted in the right drive.
  119.  
  120. [Aside: This asking the user to move the disk might seem unfriendly
  121. (though it seldom occurs in practice; perhaps dos.library does some
  122. magic with ASSIGNed names?). However, compare to msdos world; I've once
  123. managed to trash a disk by swapping it while a file was open. The file
  124. system assumed that the disk had not been changed and happily overwrote
  125. the new disk with the sectors that belonged to the old one. It should be
  126. easy to imagine the resulting disaster...]
  127.  
  128.     - Kristian.
  129.