[comp.sys.atari.st] Why does GEMDOS call Mediach

jack@mcvax.UUCP (04/22/87)

While testing my remote disk driver (soon to be posted), I noticed
that GEMDOS makes a *huge* number of calls to the Mediach() routine.

For instance, when doing a 'show info' on a (remote) hard disk, it
would do the calls rwabs, mediach, rwabs, mediach, mediach, mediach,
rwabs, 10(!) times mediach, etc etc.

It calls mediach at least once between reads, but often more. I saw it
being called *forty-seven* times in a row once.
Is there any reason for this behaviour? Is there anything I can
do against it? Should mediach() perform more functions than the bios
guide says (return 0/1/2 for not/maybe/definitely changed)?

Not that mediach() is usually a cheap call: just check a bit in the
hardware somewhere.
For a remote disk, however, it is quite expensive, since a packet has
to be sent back and forth.
-- 
	Jack Jansen, jack@cwi.nl (or jack@mcvax.uucp)
	The shell is my oyster.

dyer@atari.UUCP (Landon Dyer) (04/23/87)

in article <7359@boring.mcvax.cwi.nl>, jack@mcvax.cwi.nl (Jack Jansen) says:
> While testing my remote disk driver (soon to be posted), I noticed
> that GEMDOS makes a *huge* number of calls to the Mediach() routine.
> 
> For instance, when doing a 'show info' on a (remote) hard disk, it
> would do the calls rwabs, mediach, rwabs, mediach, mediach, mediach,
> rwabs, 10(!) times mediach, etc etc.
> 
> It calls mediach at least once between reads, but often more. I saw it
> being called *forty-seven* times in a row once.
> Is there any reason for this behaviour? Is there anything I can
> do against it? Should mediach() perform more functions than the bios
> guide says (return 0/1/2 for not/maybe/definitely changed)?
> 
> Not that mediach() is usually a cheap call: just check a bit in the
> hardware somewhere.
> For a remote disk, however, it is quite expensive, since a packet has
> to be sent back and forth.

You should try to make Mediach() as cheap as possible, since it
may be called often.  GEMDOS is rather too paranoid about media
changes.  When doing partial-sector reads and writes (including
directory searches and FAT operations) it calls Mediach() on a
hit in the sector cache, evidently to "validate" the cached sector.

Mediach() on floppies does not simply "check a bit somewhere".  It
hits the disk (to check the serial number) only as a last resort,
since ANY disk I/O --- floppy OR hard disk --- is expensive.  I
suggest you send a packet only as a last resort.

-- 
-Landon Dyer, Atari Corp.	    {sun,lll-lcc,imagen}!atari!dyer

The views expressed here do not not		
necessarily reflect those of Atari Corp.	Segments are for worms.

fischer-michael@YALE.ARPA (Michael Fischer) (05/06/87)

Landon Dyer writes:
> Mediach() on floppies does not simply "check a bit somewhere".  It
> hits the disk (to check the serial number) only as a last resort,
> since ANY disk I/O --- floppy OR hard disk --- is expensive.  I
> suggest you send a packet only as a last resort.

Unless there have been substantial changes to the Bios since the
developer's kit was produced, this is not strictly accurate.
Mediach() NEVER hits the disk, it only computes and returns a mode:
0-safe, 1-unsure, 2-changed.  Rwabs() calls Mediach() and hits the
disk if 1 is returned, changing the mode to 0 or 2 depending on
whether the serial numbers match.  If mode=2, Rwabs does not perform
the I/O but instead returns the media change error (-14).  Getbpb()
resets the mode back to 0.  Mediach() changes the mode from 0 to
1 if a short time (1-2 seconds) has elapsed with no disk I/O and
the write protect bit has been seen on during that time.  The write
protect bit goes on whenever a disk is removed from the drive or
the disk is write protected.

--Mike Fischer <fischer@yale.arpa>
-------

dyer@atari.UUCP (Landon Dyer) (05/07/87)

fischer-michael@YALE.ARPA (Michael Fischer) says:
> Unless there have been substantial changes to the Bios since the
> developer's kit was produced, this is not strictly accurate.
> Mediach() NEVER hits the disk, it only computes and returns a mode:
> 0-safe, 1-unsure, 2-changed.  Rwabs() calls Mediach() and hits the
> disk if 1 is returned, changing the mode to 0 or 2 depending on
> whether the serial numbers match.  If mode=2, Rwabs does not perform
> the I/O but instead returns the media change error (-14).  Getbpb()
> resets the mode back to 0.  Mediach() changes the mode from 0 to
> 1 if a short time (1-2 seconds) has elapsed with no disk I/O and
> the write protect bit has been seen on during that time.  The write
> protect bit goes on whenever a disk is removed from the drive or
> the disk is write protected.

Thank you -- I stand corrected.  Mediach() does NOT hit the
disk.  It is a "cheap" call.  [That'll teach me to answer
questions w/o looking at the source!]

-- 
-Landon Dyer, Atari Corp.	    {sun,lll-lcc,imagen}!atari!dyer
The views expressed here do not necessarily reflect those of	     SEGMENTS
Atari, any of the AI software running on my computers, or my	      ARE FOR
non-existant mother-in-law.					        WORMS