[comp.sys.atari.st] A simple disk cache

braner@batcomputer.tn.cornell.edu (braner) (01/02/87)

[]

	WARNING:	USE AT YOU OWN RISK!
	~~~~~~~		~~~~~~~~~~~~~~~~~~~
	This program seems to work, but if it ends up trashing your
	disk don't blame me!  Treat it for now as EXPERIMENTAL.

Here is a simple disk-cache program.  It is rather conservative: it only
caches the FAT and the root directory for drives A and B.  It also uses
the RAM cache for disk-reads only, all writes are done immediately.
Using it you will still need a RAM disk, but you gain 3 ways:

(1)	Floppy-disk operations are slightly faster, especially when dealing
	with many small files.  For example, copying 11 files scattered over
	a floppy (about 100K bytes) took 29 seconds, but only 21 with this
	program installed - a 28% cut in the time, although still 4 times
	the theoretical minimum time...

(2)	Some nuisance disk-turning is avoided.  For example, pressing <ESC>
	when a floppy's desktop window is open does not turn the disk.  But
	closing the window and reopening still does cause disk-turning, even
	when the disk was NOT removed, due to the way TOS works and the
	conservative nature of this program: it assumes the disk was removed
	if the boot sector is accessed at all.  Similarly, closing a folder's
	window still turns the disk to reopen the underlying (root directory)
	window.  There is room for improvement...  Things are brighter from
	inside micro-C-Shell:  No matter how many times you type "ls a:\"
	and/or "cd a:\", interspersed with RAM-disk operations, the disk
	does not turn (unless it's been removed).

(3)	Most important:  The FAT and the root directory are accessed very
	often, and most disk-failures are in these sectors.  Using this
	program will avoid a lot of those accesses, and should lengthen
	the life of your floppies.

To use SCACHE ('S' for simple) run it from the desktop or from the AUTO
folder.  Due to the way TOS senses disk-removal, the diskette write-protect
tab has to be closed (not protected) for the cache to yield any gains.
Following is the binary (uuencoded), the source (mostly in AL) will be
e-mailed upon request.

I hope this will encourage somebody to write a REAL disk cache!

Happy New Year!!

- Moshe Braner

~~~~~~~~~~~~~~~~~~~~~~ cut here ~~~~~~~~~~~~~~~~~~~~~~~~~
begin 644 SCACHE.PRG
M8!H```B*````,@``!T@``````````````````$[Y````#$[Y```(%"I/*FT`
M!"`M``S0K0`4T*T`'-"\```A`"(`THW"O/____XN02\`+PU"9S\\`$I.0=_\
M````#"!M`!@B;0`8T^T`'"`M`!13@&\&$R!1R/_\(&T`$"`M`!Q3@$(84<C_
M_"AM`!#9[0`<*4W__"IM``A.K0`&(&S__$AH`(!.N@'B6(\O+/_V/RS_^DZZ
M`89<CS\\``!.N@(@/SP`03\\``).05B/3G4@"`@```!F&B`)"````&82,#P`
M'R+8(M@BV"+84<C_]DYU,#P!_Q+84<C__$YU0T%#2``````^+P`.OGP``FT&
M('K_\$[0)G@$?C\'3I-4CT?Z`.(\+P`,9P1*@&<0($M*1V<$T/P`#$*80IA"
MF`1&``9KS#HO``K:1@Q%``MNP$I'9PC:?``,W'P`#$IO``1F)$'Z`+@P!N%`
MXT#0P")O``9*,V``9PYA`/]64D:\16WP0H!.=3X%GD8P+P`*/T<`"I!'T6\`
M##`&0C,``%)`L$5F]D'Z`%H@GTAZ``9@`/]@+SH`3$J`9D0\+P`,!$8`!CHO
M``K:1CXO``YG"-I\``S<?``,1_H`+"!O``9#^@`\,`;A0.-`TL!)\V``"-0`
M`&$`_MQ21KQ%;>Y"@$YU`````````````````````````````````````")\
M```$=B!1("C_^`R`0T%#2&<*0?K^U"%1__PBB$YU3E;__$AZ_]H_/``F3KH#
M@%R/2&P``#\\``E.N@..7(]"KO_\8```!E*N__P,K@``PU#__&T`__)"9R\\
M```T`#\\`#%.N@-D4(].7DYU3G5.5@``/RX`"$ZZ`LI4CPQN@P``"&X&,#P`
M`&`>/RX`"#\\`#Y.N@,T6(\Y0/GT9P8P//__8`0P/```3EY.=4Y6```_+@`(
M/SP`3$ZZ`PY8CTY>3G5.5O_^+PM![/I")DA@%C`K``K`?``#9P@O"TZZ`"I8
MC];\`!0@"T'L^D(B"-*\```%M+"!;=@_+@`(3KK_KE2/)E].7DYU3E8``"\+
M)FX`""\+3KH`1%B/2D!G!C`\__]@,#`K``K`?``09PHO*P`&3KH!^%B/0FL`
M"C\K``Q.NO\L5(]*0&<&,#S__V`$,#P``"9?3EY.=4Y6``!(YP$0)FX`"#`K
M``K`?``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X`"B1+0>P`+BU(__8,;H,```AF%C\N``XO"TZZ_S1<CSUN``[__F```4P,
M;H+_``AF%C\N``XO"TZZ_V!<CSUN``[__F```2X,;H+^``AF%C\N``XO"TZZ
M_W!<CSUN``[__F```1`M2__Z0F[__C\N``A.NOYV5(]*0&8``*9@``"4$!)(
M@+!\``IF``"&(`J0KO_ZL'P``&]`(`J0KO_Z2,`M0/_R+R[_^B\N__(_+@`(
M/SP`0$ZZ_GS>_``,.4#Y]$C`L*[_\F<(,#S__V```*@P+/GTT6[__B\N__8O
M/`````(_+@`(/SP`0$ZZ_D;>_``,.4#Y]`Q```)G!C`\__]@=%)N__Y2BB`*
M+4#_^F`"4HH@"I"+L&X`#F4`_V1@$"`+-BX`#L:\``#__]"#)$`@"I"N__I(
MP"U`__(O+O_Z+R[_\C\N``@_/`!`3KK]Y-[\``PY0/GT2,"PKO_R9P8P//__
M8!`P+/GTT6[__D)L^?0P+O_^3-\,`$Y>3G5#[/I"(OP`````,OP``"+\````
M`#+\``DR_(,`(OP`````,OP``"+\`````#+\```B_``````R_`$",OR#`"+\
M`````#+\`@`B_``````R_```(OP`````,OP!`C+\@P`B_``````R_`(`TOP%
M>#E\`@#Z0$YU#0H*"41I<VL@0V%C:&4@:6YS=&%L;&5D#0H*`$-/3CH``$%5
46#H``%!25#H```T*```````"!@!C
`
end

braner@batcomputer.tn.cornell.edu (braner) (01/04/87)

[]

Even though the Megamax C compiler is famous for producing small
(compiled) programs, it doesn't even come close to what's possible
with the total control of an assembler.  As an experiment, I took the
original code of SCACHE (which was mostly in assembly-language anyway),
added installation code also in AL, and assembled with A-Seka.  This
version is 23% as long as the former:  the cache code is the same but
all the C garbage is gone...

Could somebody explain WHAT is all that extra stuff the compiler added,
and how to get rid of it?

Also:  I used an old version of A-Seka.  It has MANY bugs, e.g. it doesn't
handle tabs (in the source code) right, and it produces an unusable .prg
if the code is COMPLETELY relocatable (i.e. ALL the addresses are relative)
- you have to have at least one absolute reference so that A-Seka will
produce a valid relocation table.

Does anybody know if the latest version of A-Seka has improved substantially?
It is a compact (about 20K) assembler/linker/tracer/debugger (with 2 text
editors built-in), and is VERY fast.  It could be wonderful if finished up.

- Moshe Braner

~~~~~~~~~~~~~~~~~~~~~~~ cut here ~~~~~~~~~~~~~~~~~~~~~~
begin 644 SCACHE.PRG
M8!H```'4`````````````````````````````$AY```!EC\\`"9.3ER/2'D`
M``&X/SP`"4Y!7(]"@%*`#(```PU`;0#_]D)G+SP``#,`/SP`,4Y!(`@(````
M9AH@"0@```!F$C`\`!\BV"+8(M@BV%'(__9.=3`\`?\2V%'(__Q.=4-!0T@`
M````/B\`#@Q'``)M""!Y````:D[0)GD```1^/P=.DU2/1_D```%^/"\`#&<$
M2H!G$"!+2D=G!-#\``Q"F$*80I@$1@`&:\8Z+P`*VD8,10`+;KI*1V<(!D4`
M#`9&``Q*;P`$9B9!^0```98P!N%`XT#0P")O``9*,V@`9PYA`/].4D:\16WP
M0H!.=3X%GD8P+P`*/T<`"I!'T6\`##`&0C,(`%)`L$5F]D'Y```!>B"?2'D`
M``$F8`#_5"\Y```!>DJ`9D@\+P`,!$8`!CHO``K:1CXO``YG"`9%``P&1@`,
M1_D```%^(&\`!D/Y```!EC`&X4#C0-+`2?-H``C4``!A`/[*4D:\16WN0H!.
M=0`````````````````````````````````````B?```!'8@42`H__@,@$-!
M0TAG#$'Y````;B%1__PBB$YU#0H*"41I<VL@0V%C:&4@:6YS=&%L;&5D#0H*
0``````(.:A1$1`@*)@I4`$YU
`
end