home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 098 / undoc.dqc / undoc.doc
Encoding:
Text File  |  1983-12-25  |  10.9 KB  |  271 lines

  1.      D O S   A N D    M S D O S    P R O B L E M S
  2.  
  3.     This is a list of PCDOS and MSDOS peculiarities,
  4. etc. You will have to guess from the text what the
  5. particular questions were, but you systems programmers will
  6. find it worth your while to rummage through it all.
  7.  
  8. ........................................
  9.  
  10. There is a problem of compatibility between MS-DOS and IBM
  11. PC-DOS having to do with FCB Open and Create which has
  12. finally been tracked.
  13.  
  14. The IBM 1.0, 1.1, and 2.0 documentation of OPEN (call 0FH)
  15. contains the following statement.
  16.  
  17.         "The current block field (FCB bytes C-D) is
  18.          set to zero [when an FCB is opened]."
  19.  
  20. This statement is NOT true of MS-DOS 1.25 or MS-DOS 2.00.
  21. The difference is intentional, and the reason is CP/M 1.4
  22. compatibility. Zeroing that field is not CP/M compatible.
  23. Some CP/M programs will not run when machine translated if
  24. that field is zeroed. The reason it is zeroed in the IBM
  25. versions is that IBM specifically requested that it be
  26. zeroed. 
  27.  
  28. This is the reason for the complaints from some vendors
  29. about the fact that IBM MultiPlan will not run under MS-DOS.
  30. It is probably the reason that some other IBM programs don't
  31. run under MS-DOS.
  32.  
  33.  
  34. PROGRAMMERS NOTE:
  35.         Do what all MS/PC-DOS  Systems programs do: Set
  36. every single FCB field you want to use regardless of what        
  37. the documentation says is initialized.
  38.  
  39. ........................................
  40.  
  41.     a)  It seems there is a maximum of 19 handles, no matter
  42. what the files parameter is set to.  Is this really the
  43. case?  What does one gain by setting files to less than 19? 
  44. Is memory for handles allocated dynamically?
  45.  
  46.     There is a maximum of 20 handles per process no
  47. matter what the files parameter is set to. There has to be a
  48. table in your process header for your handles, there is a
  49. limited amount of space down there. 40 bytes or so are taken
  50. up by each system FCB, setting files to less than 20 saves a
  51. little bit of memory. Memory for handles is not allocated
  52. dynamically, in general an attempt to do so would fail
  53. anyway. Recall that .COM files and most .EXE files are given
  54. the biggest piece of memory possible when they are EXECed
  55. because the DOS cannot make assumptions about how much
  56. memory these programs really use. This means they typically
  57. get ALL of the free memory, that means there is no free
  58. memory to allocate dynamically. You will find that almost
  59. all operating systems (CP/M is about the only exception)
  60. have a limit on the number of open files. MS-DOS has a limit
  61. of 20. CP/M has no such limits because it requires the user
  62. to keep FCBs in his own address space, managing FCBs is a
  63. pain. You get simplicity and you give up very little. What
  64. program needs more than 20 open files? If you can think of
  65. one, it is probably a poorly written program in that it
  66. probably only needs a few open files at a time and doesn't
  67. bother to close files after it's done with them.
  68.  
  69.     b)  Execing a program eats 5 (I think) handles per try. 
  70. Is this the passing of parent's environment that is
  71. mentioned (very briefly) in the documentatio n?  What are
  72. these handles?  They don't seem to be allocated with system
  73. calls,  either.  Is that true? 
  74.  
  75.    std-in, std-out, std-err, std-aux, std-prn. I suppose you
  76. would like your program to be able to use the 1-12 system
  77. calls? That means there have to be 5, the first three are
  78. standard UNIX style fair and are required for the software
  79. tools approach to programming. Std-aux and Std-prn are
  80. required for system calls 3,4, and 5. Just because you are
  81. handed these default handles doesn't mean you can't close
  82. them.
  83.  
  84. ........................................
  85.  
  86.  
  87.     "...  1) what exactly is meant by the dos being in an    
  88. unstable state.  (This is what the documentation says    
  89. happens if one returns to a user program directly from    
  90. an int 24 handler.)..." 
  91.  
  92. It means that the DOS has the notion of an error being in
  93. effect. All printer echoing is turned off, and some other
  94. stuff doesn't work. Also, there are dirty buffers that are
  95. not correctly flushed out.  Thus the disks may not be
  96. consistent.
  97.  
  98.     "...  2) my experimentation shows that an abort from    
  99. a hard error handler causes an int 22 without the value    
  100. for int 22 being sucked out of the program header.  every    
  101. other way out of a program uses the terminate address in the
  102. header.  is this difference intentional?  Why? DOes one
  103. expect the value at int 22 to be different from the value in
  104. the header ever?..."
  105.  
  106. False.  No INT 22h is ever issued.  The header is only used
  107. to save the previous process' vectors.  The address
  108. contained in INT 22 is saved in a temp spot, the contents of
  109. INTs 22-24 are restored from the header, and then an
  110. indirect jump is taken through the temp location.  Certain
  111. programs (such as COMMAND) may want to intercept themselves
  112. from terminating.
  113.  
  114. Consider this case:  You create a file on a write-protected
  115. drive.  The system will read in a directory sector and
  116. modify it.  It will then attempt to write it out, causing a
  117. write-protect error.  If you catch the INT 24 and do not
  118. return, the dirty buffer still exists. To clear out the
  119. dirty buffer, you MUST return from the INT 24 saying to
  120. abort the process.  You can then catch the terminate and
  121. restore your stack (you will be running on your parent's
  122. stack). 
  123.  
  124. ........................................
  125.  
  126.  
  127.     "...  1) Why does PCDOS exec function 3 (overlay) demand
  128. that there be some free memory that it can allocate...."
  129.  
  130. It doesn't. IBM specifically requested that the Exec code be
  131. overlayable in the MSDOS.  As a result, it lives in the
  132. transient piece of COMMAND.COM and gets loaded when needed: 
  133. thus the requidement for enough free space to laod the Exec
  134. loader (about 1.5K).
  135.  
  136. Under other MSDOS's there is no such problem as the Exec
  137. system call lives in system space.  A general rule of thumb
  138. is: if you are not going to use some space, free it.  You
  139. can do this either via SetBlock system call, or by twiddling
  140. the EXE file header. You should avoid .COM format files.
  141.  
  142.  
  143.     "...  what happens if I try to overlay an .EXE file with
  144. the high/low switch set to load the thing for high
  145. memory..." 
  146.  
  147. Nothing.  The HIGH/LOW switch is only for process creation,
  148. not for overlays.
  149.  
  150.     "...  Are all these answeres the same for MSDOS?..."
  151.  
  152. Yes.
  153.  
  154. ........................................
  155.  
  156.     "... zeroing of the current record field ..."
  157.  
  158. That incompatability existed between 1.1 PC-DOS and 1.25
  159. MSDOS.  2.0 versions of both function identically (like 1.1
  160. PC-DOS).
  161.  
  162. ........................................
  163.  
  164.  
  165. The Shell command on PC-DOS 2.0 works just fine.
  166.  
  167.     CONFIG.SYS
  168.         shell = b:\command.com b:\ /P
  169.  
  170. Putting a disk with command.com in drive B: when the system
  171. boots causes COMMAND to be read from drive B: and the
  172. COMSPEC in  the environment is "B:\COMMAND.COM". If you are
  173. having trouble it's because you are doing something wrong.
  174. Recall that your given COMSPEC is checked, if you give it a
  175. bad one it will try to go back to the default which is the
  176. root directory on the default drive. Recall also that this
  177. is an undocumented 2.0 feature so even if it doesn't work
  178. nobody is going to be all that hot to do something about it.
  179.  
  180. ........................................
  181.  
  182.  My error on the shell stuff, IBM hid it real well. The
  183. "b:\" is also documented on page 10-9 (the [d:][path] part).
  184. They did an equally poor job here.
  185.  
  186. The /P and the path spec have absolutely nothing to do with
  187. the SHELL command, they are arguments to command. Expecting
  188. SHELL to know stuff particular to command is not reasonable
  189. because you are not restricted to running command as your
  190. top level shell. You can run DEBUG as your top level shell
  191. by saying
  192.  
  193.         SHELL = debug.com
  194.  
  195. But watch out!! debug is not designed to run as a top level
  196. shell. if you ever say "q" to this debug the system will
  197. crash. Command on the other hand is smart enough to run as a
  198. top level shell. If you give the /P switch to it Command
  199. does some special things to insure that typing EXIT to it
  200. will not cause the system to crash as with debug. There is
  201. absolutely no way for command to assume the /P switch
  202. because he must run as a top level shell, and as a utility.
  203. The smart user has to tell him what to do. Similarly the
  204. "b:\" tells command where to look for himself. For instance:
  205.  
  206.         SHELL = A:\BIN\COMMAND.COM D:\COMMAND\BIN /P
  207.  
  208. The "A:\BIN\COMMAND.COM" tells SYSINIT where to load the
  209. initial command.com, the "D:\COMMAND\BIN" tells command
  210. where to look for himself when he needs to locate his
  211. transient. As you can see they are not restricted to being
  212. the same things. I suggest you foreward any complaints about
  213. the manual to 
  214.  
  215. ........................................
  216.  
  217.  The volume ID attribute is very special, and is treated
  218. differently from all the other attributes. It is very
  219. "sticky", in order to find one you must look for it and it
  220. alone. And when you do look for it, you find only it and
  221. nothing else.
  222.  
  223. The volume ID is constrained to be in the ROOT directory,
  224. and there can be only one file in the ROOT with the
  225. attribute. The FCB flavor calls have special code to enforce
  226. these rules.
  227.  
  228. The new calls were supposed to enforce the same rules, but
  229. they are not working correctly, and unexpected results are
  230. possible. You should use the old FCB calls to diddle with
  231. volume ID for the moment.
  232.  
  233. ........................................
  234.  
  235. Thanks for the info.  The causes of your problems are:
  236.  
  237. (a) ^Z on output to a device in cooked mode will terminate    
  238. the output.  This is for CPM-compatability:  you don't want
  239. stuff after the ^Z output to your printer for example. 
  240.  
  241.     As a result COMMAND.COM issues a write to stdout and    
  242. then checks to see if the number written is equal to the    
  243. number requested.  If they are not the same, then a
  244. redirection error is assumed.  ECHO ^Z is supposed to    
  245. output a single character.  It outputs NO characters and    
  246. thus the strange message.
  247.  
  248.     Programs that use old function calls, get redirected,    
  249. and then read more than is expected will behave    
  250. bizarrely: how do you indicate EOF on a read-byte-from-    
  251. console system call?  I believe that it returns ^Z. Most of
  252. these programs were never expecting to get redirected and
  253. thus, the failure to handle the boundary conditions
  254. properly. 
  255.  
  256. (b) The main crock about CP/M is that the extention on a    
  257. file name determined the type of the file.  This is    
  258. bogus: a file should be distinguished by its contents,    
  259. not by its name.  When you are loading a file with the    
  260. name *.EXE, it does NOT assume that it is an EXE format    
  261. file.  It looks at the first two bytes for a signature    
  262. telling it that it is an EXE file.  If it has the proper    
  263. signature, then the load proceeds. otherwise, it    
  264. presumes the file to be a COM-format file.
  265.  
  266.     If the file has the EXE signature, then the internal    
  267. consistency IS checked.
  268.  
  269.     Pre-2.0 versions of MSDOS did not check the signature    
  270. byte for EXE files.
  271.