home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / TNH_PC.ZIP / WHITE.NL < prev    next >
Encoding:
Text File  |  1987-01-14  |  18.0 KB  |  582 lines

  1. An Introduction to PC Diskettes
  2.  
  3.              Howard White
  4.         Boston Computer Society
  5.           IBM PC Users Group
  6.  
  7. Introduction
  8.  
  9. When you buy double-density
  10. soft-sector disks for your PC, or
  11. choose between DISKCOPY and COPY, you
  12. are making decisions affected by the
  13. relationship between DOS, your PC's
  14. Disk Operating System, and the type
  15. of disk drives installed in your
  16. computer. While it is not necessary
  17. to have a technical understanding of
  18. the way DOS maintains information on
  19. your disks, it's useful to understand
  20. the general principles so that you'll
  21. be a better informed user.
  22.  
  23. This article will introduce you to
  24. "tracks" and "sectors", explain in
  25. disk terms what a file is, describe
  26. the common DOS utilities for
  27. formatting, copying, and testing
  28. disks, and explain the concepts of
  29. density.
  30.  
  31. Looking at Diskettes
  32.  
  33. We start our exploration of diskettes
  34. by looking at one. With the permanent
  35. label in the upper left hand corner,
  36. we see:
  37.  
  38. o   The large round hole in the
  39.     center. When you close the disk
  40.     drive's "door", the drive clamps
  41.     onto the disk here. Many disks
  42.     come with "hub ring
  43.     reinforcements", thin plastic
  44.     rings like those used to
  45.     reinforce three-ring notebook
  46.     paper, intended to help the disk
  47.     withstand the mechanical forces
  48.     of sudden starts and stops.
  49.  
  50. o   On the right side just below the
  51.     center of the hub hole, is a
  52.     smaller round hole called the
  53.     "index hole". If you very
  54.     carefully turn the disk within
  55.     its protective jacket, you will
  56.     see that at one one point is a
  57.     small hole in the disk hole in
  58.     the disk itself visible.
  59.  
  60. o   Below the hub hole is a slot
  61.     shaped rather like a long
  62.     race-track, through which you can
  63.     see the disk surface itself. It
  64.     is through this slot that the
  65.     disk drive heads read and write
  66.     information to the disk surface.
  67.  
  68. o   At the right side, about one inch
  69.     from the top, is a rectangular
  70.     punch from the side of the disk
  71.     cover. This is the "write-protect
  72.     slot". It may not be present on
  73.     all disks, particularly those you
  74.     have purchased with programs on
  75.     them. If the slot is absent, or
  76.     if it is covered with tape, the
  77.     drive can read data from the disk
  78.     but not write on it.
  79.  
  80. o   Two very small oval notches at
  81.     the bottom of the disk, flanking
  82.     the head slot.  The drive uses
  83.     these notches to assist in
  84.     keeping the diskette in position.
  85.  
  86. o   As you have almost certainly been
  87.     advised, disks can be damaged or
  88.     destroyed by:
  89.  
  90.     o   Touching the recording
  91.         surface (though the head
  92.         hole) with your fingers or
  93.         anything else;
  94.     o   Writing on a disk label with
  95.         a ball-point pen or pencil.
  96.         Use a felt-tip marker;
  97.     o   Bending the disk;
  98.     o   Spilling coffee, etc. on the
  99.         disk;
  100.     o   Overheating a disk (e.g. by
  101.         leaving it in the hot sun in
  102.         your car);
  103.     o   Exposing your disk to stray
  104.         magnetic fields.
  105.  
  106. Information is read from and placed
  107. on your disk by one or two "heads"
  108. (depending on whether you have single
  109. or double-sided drives). Heads used
  110. with "hard disks",  including the
  111. "Winchester" drives available for
  112. PC's, "float" above the disk surface
  113. on a microscopic cushion of air. But
  114. the mini-floppy drive heads actually
  115. touch the disk surface. Thus both the
  116. disks themselves and the heads should
  117. be kept clean - head cleaning kits
  118. are available - so that precious
  119. information will not be scraped off
  120. the disk surface by abrasion.
  121.  
  122. Tracks and Sectors
  123.  
  124. From the point of view of DOS, data
  125. on your PC diskettes is organized in
  126. "tracks" and "sectors".
  127.  
  128. Tracks are narrow concentric circles
  129. going around the disk. Sectors are
  130. pie-shaped slices of the disk.  DOS
  131. 1.0 and DOS 1.1 read and write 40
  132. tracks (numbered 0..39) and eight
  133. sectors (numbered 1..8) on disks. If
  134. you have double-sided drives, DOS 1.1
  135. automatically formats and deals with
  136. disks containing  information on both
  137. sides of a disk. The distance between
  138. tracks - and therefore, the number of
  139. tracks on a disk - is a built-in
  140. mechanical and electronic function of
  141. the drive.
  142.  
  143. When you buy new disks, they are like
  144. blank sheets of paper, containing no
  145. information at all. Formatting the
  146. disk puts onto it the information DOS
  147. needs to maintain a directory and
  148. files. Normally, you also put onto
  149. the disk certain parts of DOS (using
  150. the /S option after the FORMAT
  151. command).
  152.  
  153. The track nearest the outside edge of
  154. a disk - track 0 - is almost entirely
  155. reserved by DOS for its purposes.
  156. Track 0, Sector 1, contains the "boot
  157. record" which the system sometimes
  158. needs to begin operation. Sectors 2
  159. and 3 contain the "file allocation
  160. table", or FAT, which is the disk
  161. "reservation clerk", keeping records
  162. of which portions of the disk have
  163. information and which have empty
  164. space. Finally, sectors 4-7 contain
  165. the directory - information about the
  166. files, a part of which you see when
  167. you type the "DIR" or "FILES"
  168. command.
  169.  
  170. In addition, assuming you have
  171. formatted the disk using the /S
  172. (system) option, two "hidden" files
  173. called IBMBIO.COM and IBMDOS.COM are
  174. placed on the disk (in different
  175. location, depending on whether you
  176. have single or double sided drives).
  177. They are called "hidden" because the
  178. normal directory command will not
  179. reveal their presence on a disk.
  180.  
  181. In computer jargon, all of this is
  182. "transparent to the user", meaning
  183. you don't have to (and generally
  184. can't) decide where information will
  185. go on your disks. But just because
  186. it's "transparent" doesn't
  187. necessarily mean you shouldn't be
  188. aware of the decisions DOS makes for
  189. you.
  190.  
  191. PC DOS 1.1 puts 512 bytes of
  192. information on each sector of a disk.
  193. As a broad generality, a byte is
  194. equal to a character, but BASIC
  195. normally saves programs in a
  196. compacted format, so you can't make
  197. an automatic judgement about the
  198. amount of disk space a BASIC program
  199. will use.
  200.  
  201. But for purposes of illustration,
  202. let's assume you have a
  203. newly-formatted disk in your drive
  204. and have created a BASIC program of
  205. 2000 characters, or 2K bytes.  You
  206. type SAVE "FILE1", and DOS begins
  207. putting your program onto disk.
  208.  
  209. On the outermost track, sectors 1..7
  210. already are taken up with system
  211. stuff, as mentioned previously, so
  212. the first available sector is track
  213. 0, sector 8. The first 512 bytes of
  214. your program go there. Then, because
  215. DOS always tries to keep things
  216. together, the remaining roughly 1500
  217. bytes go onto track 1, sectors 1, 2
  218. and 3.
  219.  
  220. Now, you write another, entirely
  221. different, 2000-byte BASIC program
  222. and SAVE  it as FILE2. Again, DOS
  223. puts it on the first available spots,
  224. so it goes to track 1, sectors 4, 5,
  225. 6 and 7.
  226.  
  227. Going back to your first program, add
  228. a few hundred characters, and SAVE it
  229. again under the same filename, FILE1.
  230. The first four sectors (even if
  231. changed) go back to the same spots as
  232. the old first four sectors. But now
  233. your second file is in the way of
  234. keeping things orderly. The next
  235. available free sector is track 1,
  236. sector 8, so that's where the rest of
  237. your revised first file goes.
  238.  
  239. Next, you decide to delete your
  240. second program, FILE2, using DELETE
  241. or ERASE commands in DOS or the KILL
  242. command in BASIC. These commands
  243. don't actually erase any information
  244. from the disk (therefore making it
  245. possible, using a utility program ,
  246. to "unerase" a program you've just
  247. accidentally wiped out). What the
  248. DELETE family of commands does is
  249. tell DOS that the sectors formerly
  250. occupied by, say, FILE2.BAS, are now
  251. available for recycling.
  252.  
  253. Now you create and save a new
  254. program, FILE.BAS, which takes up
  255. five sectors.  The first four go into
  256. the spots vacated by the now obsolete
  257. FILE2.BAS. The last one has to go
  258. into the first available spot, after
  259. the newly-added part of FILE1.BAS. We
  260. now begin to have a patchwork quilt.
  261.  
  262. We're still not in bad shape. But
  263. suppose our disk gets fuller. We're
  264. deleting old files to make room, and
  265. creating vacant areas defined solely
  266. by the needs of DOS at the time the
  267. disk was younger.  It shouldn't be
  268. hard to see that a full disk can
  269. become a real crazy quilt, with any
  270. sector of any file occupying any of
  271. the 320 (single sided) or 640 (double
  272. sided) sectors not otherwise used by
  273. DOS, system files, other user files.
  274.  
  275. Since all of this is, as we said,
  276. transparent to the user, what
  277. difference does it make? Not very
  278. much, if all you are doing with disks
  279. is storing programs. But as soon as
  280. you start using disk data in your
  281. programs, you can affect the
  282. performance of those programs,
  283. perhaps substantially, by proper disk
  284. management.
  285.  
  286. To understand why, consider what
  287. happens when you ask for disk access,
  288. either reading or writing. First, the
  289. disk is told to start rotating at 300
  290. rpm - it only spins when needed, and
  291. the red light goes on to tell you
  292. that's happening.  Next, DOS figures
  293. out which track the data is to be
  294. read from or written to. A "stepper
  295. motor" moves the heads toward or away
  296. from the center of the disk,
  297. positioning them exactly over the
  298. right track (if you have double sided
  299. drives, the top and bottom head move
  300. together). This movement of heads
  301. from track to track is the slowest
  302. operation your disk drives performs,
  303. and disk access, in general, is the
  304. slowest thing your computer does
  305. (excluding things governed by
  306. external forces like slow printers
  307. and telephone lines). Once the heads
  308. are over the right track, access to
  309. the desired sector is relatively fast
  310. - the drive "sees" the index hole
  311. open up as that one hole punched in
  312. the disk passes over the openings in
  313. the disk jacket, and then the
  314. drive/controller combination just has
  315. to wait the right amount of time
  316. before reading or writing to a
  317. sector.
  318.  
  319. The message here is that moving from
  320. one track to another is the slowest
  321. of the slow things a disk drive does.
  322. DOS tries to keep sectors of a
  323. program together, but as the
  324. patchwork quilt pattern develops, it
  325. can't help much. In an extreme case,
  326. the heads may read a sector on track
  327. 0, then pick up another from track
  328. 39, then move back to track 1 to pick
  329. up a third, then to track 39 again...
  330. and so forth. The slowest part of
  331. disk access is in control.
  332.  
  333. What can be done?  COPY.
  334.  
  335. The DOS manual lists two different
  336. ways of copying information from one
  337. disk to another: COPY and DISKCOPY.
  338.  
  339. DISKCOPY makes an exact copy of one
  340. disk to another. So if one disk is a
  341. patchwork quilt, a DISKCOPY of it
  342. will look the same. But there's an
  343. alternative:
  344.  
  345. COPY *.*
  346.  
  347. In this case, asterisks are
  348. "wildcards", meaning "whatever would
  349. legally be here". So *.* means any
  350. legal filename followed by any legal
  351. filename extension. Therefore, if you
  352. type COPY A: *.* B: , you direct DOS
  353. to copy all files on drive A to the
  354. disk on B. There are some assumptions
  355. here. First, the "target" drive - in
  356. this case, B, must have enough room
  357. for the files copied to it. Second,
  358. unlike more sophisticated schemes on
  359. larger computers, DOS presently
  360. provides no protection scheme. So if
  361. there is a FILE1.BAS on A and a
  362. FILE1.BAS on B, COPY A version. COPY
  363. *.* is best done TO a disk whose
  364. contents are expendable.
  365.  
  366. The advantage, however, is what
  367. happens on COPYing. If the target
  368. disk is clean (containing nothing but
  369. what FORMAT /S put there), COPY *.*
  370. to this disk will reorganize data.
  371. Thus if FILE1.BAS on the source drive
  372. was scattered from track 39, sector
  373. 4, to track 3, sector 2, with random
  374. stops in between, after a copy it
  375. will be placed in consecutive sector
  376. order on the new disk. The result is
  377. that the next time you try to read
  378. FILE1.BAS, the heads won't have to
  379. jump all over the place looking for
  380. pieces of the file, and should
  381. therefore be able to read it faster.
  382.  
  383. The message is: generally COPY x
  384. procedure IF the target disk, y in
  385. this case, is clean. If it is not
  386. clean, COPY will work around the
  387. files on the disk, putting the files
  388. from x in the best possible
  389. positions. DISKCOPY x: y: will make
  390. disk y an exact clone of the x,
  391. wiping out any files that may have
  392. been on y and reproducing the
  393. patchwork quilt of x.
  394.  
  395. There are utility programs in DOS to
  396. check the accuracy of copying.
  397. DISKCOMP is analogous to DISKCOPY;
  398. that is, it starts with the
  399. assumption that the compared disk is
  400. supposed to be a snapshot of the
  401. original, and reports differences.
  402. Even if each file on the second disk
  403. is an exact copy of the corresponding
  404. file on the first, DISKCOMP will
  405. report differences if they're in
  406. different sector/track positions.
  407.  
  408. On the other hand, COMP compares the
  409. accuracy of the copy of individual
  410. files. You can say COMP A:FILE1.BAS
  411. B:FILE1.BAS and get a report as to
  412. whether the two files (in this case,
  413. on different disks) are identical.
  414. But you cannot say COMP A B on B:).
  415. The reason for this, of course, is
  416. vagueness - you can't compare
  417. something-or-other here with
  418. something-or-other there and get
  419. (except by chance) any valid
  420. information.
  421.  
  422. Let us now consider some practical
  423. implications for PC owners of what
  424. has been covered in this article.
  425.  
  426. Diskette Types
  427.  
  428. There are three separate choices
  429. offered to the purchaser of 5 1/4"
  430. diskettes (aside from the questions
  431. of quality, price, etc.).
  432.  
  433. Soft-sectored or hard-sectored: For
  434. the PC, soft-sectored disks have only
  435. one index hole on the disk surface
  436. itself. Once per revolution this hole
  437. is visible through the hole in the
  438. protective jacket, and
  439. drive/controller/DOS uses this hole
  440. to establish the location of the
  441. first sector on any track.
  442. Hard-sectored disks have a hole for
  443. each sector, and thus each hole marks
  444. the beginning of a new sector. If you
  445. tried to use a hard-sectored  disk in
  446. a PC, the machine would get very
  447. confused. Sometimes hard-sectored
  448. disks are not specifically labelled
  449. as such, but specify "10 sectors" or
  450. "16 sectors". Don't buy them.
  451.  
  452. Single-sided or double-sided.  At
  453. first blush, this would seem to be an
  454. obvious choice. If you have
  455. single-sided drives, you buy
  456. single-sided disks, and if you have
  457. double-sided drives, you buy
  458. double-sided disks. Not so easy. If
  459. you have double-sided drives, you
  460. can, of course, make the extra
  461. investment in double-sided disks, but
  462. you probably don't need to. It is
  463. economically impractical for disk
  464. manufacturers to make some disks with
  465. recording surfaces on one side and
  466. other disks with recording surfaces
  467. on both sides. Today's "single-sided"
  468. diskettes look, and usually behave,
  469. exactly the same as double-sided
  470. diskettes.
  471.  
  472. The result of this is that -
  473. depending on the brand of disks you
  474. buy - you can generally successfully
  475. format and use "single-sided" disks
  476. in double-sided drives, at
  477. substantial savings in disk costs.
  478. There is no real danger in this
  479. practice. When you format a disk, one
  480. of the things DOS does is determine
  481. whether there are bad sectors (ones
  482. which can't reliably hold
  483. information). If it finds any, it
  484. tells you "xxx bytes in bad sectors"
  485. and it seals them off against any
  486. future attempts to put data there.
  487. The net result is that you have a
  488. double-sided disk with slightly less
  489. than full storage capacity at the
  490. price of a single-sided disk.
  491.  
  492. Recommendation: Unless you have money
  493. to burn, buy single-sided disks even
  494. if you have double-sided drives. If a
  495. particular brand seems to produce
  496. "bad sectors", consider switching
  497. brands.
  498.  
  499. Density (single, double, quad).
  500. "Density", in simplest terms, is a
  501. measure of the amount of information
  502. that can reliably be packed into a
  503. given area of a recording surface.
  504. The keyword here is "reliably", for
  505. as in the question of single vs
  506. double sided, the matter may be
  507. settled by how well sample disks
  508. measure up to manufacturing tests.
  509. However, the question of density also
  510. raises the question of how many
  511. tracks are written on your disks.
  512.  
  513. The drive or drives that came with
  514. your PC - whether single or double
  515. sided, are almost certainly "double
  516. density" drives, also referred to as
  517. "48TPI" (tracks per inch) drives.
  518. This means that when the disk
  519. controller tells the drive "move one
  520. track closer to the center", the
  521. drive will respond by moving the
  522. heads exactly 1/48" closer to the
  523. center. It is possible to buy "single
  524. density" and "quad density" drives
  525. which look exactly like the drives in
  526. your PC. When a single-density drive
  527. is told to move one track closer to
  528. the center, its heads move 1/24:.
  529. When a quad-density drive is given
  530. the same instruction, it moves the
  531. heads only 1/96". The result is that
  532. a quad-density drive puts two tracks
  533. in the same amount of space a
  534. double-density drive uses for one
  535. track, and so the disk holds twice as
  536. much information. There is, at least
  537. potentially, a tradeoff here. As you
  538. squeeze more and more information
  539. onto a 5 1/4" disk, you place
  540. increasing demands on the ability of
  541. the drive to locate information
  542. accurately, and on the ability of the
  543. drive to locate information with the
  544. increasing precision required.
  545.  
  546. I started this discussion by
  547. mentioning density as one of the
  548. factors involved in buying diskettes.
  549. As with single- vs. double-sided,
  550. manufacturing quality control is a
  551. major part of what distinguishes one
  552. density from another.  Generally, you
  553. will buy double-density drives for
  554. your PC.
  555.  
  556. DOS 2.0 and DOS 2.1 have the ability
  557. to increase disk capacity by 12 1/2
  558. per cent by changing the formatting
  559. scheme. Thus double-sided disks,
  560. which now hold 320K bytes, will hold
  561. 360K without any other changes in
  562. software or hardware.
  563.  
  564. This is done by increasing the number
  565. of sectors per track from 8 to 9. In
  566. turn, it can do so because PC disks
  567. are soft-sectored, their sector
  568. organization is determined by the
  569. operating system, not the number of
  570. holes punched in the disk.  In doing
  571. so, DOS 2.0 is increasing the density
  572. of disk storage, putting more
  573. information into each sector than
  574. earlier versions of DOS. (Note that
  575. it is not increasing density in the
  576. way quad-density drives do - by
  577. squeezing tracks closer together.) It
  578. takes more than a DOS change to do
  579. that; the disk drives themselves must
  580. be configured for the changed track
  581. pattern.
  582.