Adventurer #09
30 апреля 1999
  TR-DOS  

Exchange of experience - TR-DOS: the disk included with interrupts.

<b>Exchange of experience</b> - TR-DOS: the disk included with interrupts.
     (C) Ivan Roshchin



            Work with disk

       included in the interrupt



     1. Theoretical information



     The computer ZX SPECTRUM execution
teams exchange of information between memory and disk is the 
direct participation of the CPU Z80: 



  RAM <-> Z80 <-> VG93 <-> disk



     As you can see, if during execution
this command will interrupt, Z80
distracted by his handling of the team will fail "data loss". So
way to work with the disk superimposed
certain restrictions.

     It should be noted that in modern
computers use the so-called
direct memory access, when the exchange of information between 
the memory and any external device occurs without the 
participation of the CPU: 



           <-> RAM <HD


    CPU


           <-> Controller <>

                drive <

                                  disc


     Spectrum - out-of-date computer,
and lack of hardware that
would allow "parallel" to work with
disk and do something else, we have
compensate for software support. For
this we must first understand how
by executing commands VG93
(Eg, "read sector") are included in the interruption.



     Note: Of course, everything said about the instructions 
read refers to write command. 



     The speed of data exchange between VG93
and Z80 is 250 kbit / s, and the disk rotates
a speed of 300 rpm. Based on these
data define the number of bytes per track (note that
rate of 1 kbit = 1000 bits, not 1024):


     (250 * 1000 / 8) * 60/300 = 6250 bytes


     Approximately the same value (plus or minus five bytes) 
can be obtained by using to determine the length of the track 
program Afrodita 3.0. 

     Now calculate how many interruptions
occurs within one revolution of the disk, if their frequency is 
known and equal to 50 Hz:



     50 * 60/300 = 10


     Thus, at every turn of the disc has just ten interrupts.
As already stated, if the termination
happen during the reading of the sector, then
this sector will not be read. It turns out that this sector 
will not be able to read and drive back the next time, since 
while it is read again will interrupt. And we come to the 
conclusion that reading sectors in interrupt enable quite 
impossible. 



     Note: there is still a way to implement reading in such 
conditions. If not Could not read sector, the process must be 
out of sync the disk rotation and the time of the interruption. 
Do it can be very simple: stop the engine

drive, and then run it.
After this it remains only to repeat
read the desired sector.



     And what, you ask, run various demo, in which the reading 
of sectors combined with playing music on an interrupt? It 
turns out that not all that bad. The fact is that in fact such 
a strict synchronization is not. Thus, the "Pentagon" when 
clocked at 3, 5 MHz gap between interrupts is about 71,680 
cycles. In this case, the frequency interrupt is:



     3500000/71680 = 48, 83 Hz



     Note: accordingly, such
will be the same framerate connected
to the "Pentagon" monitor or TV.
As you can see, this is a little different from
standard (50 Hz). Also, this leads to
that is used in many programs the timer that runs on interrupts
will lose 1 to 4 seconds per minute,
as can be easily verified.



     Now, during one revolution of the disk will 48, 83 * 
60/300 = 9, 77, interrupts. Consider how many bytes is a 
magnetic head in the gap between two interruptions:



     6250 / 9, 77 = 640 bytes


     If we assume that the first interruption
came at a time when the magnetic
head was in the beginning of the track, we get the following 
table: 


 sequence number offset from the beginning

    Interrupt track, bytes


         1 0

         2 640

         March 1280

         April 1920

         May 2560

         6 3200

         7 3840

         8 4480

         9 5120

        10 5760

        11150 (next turn)

        12 790

        13 1430

        14 2070

        15 2710

        16 3350

        17 3990

        18 4630

        19 5270

        20 5910

        21300 (next turn)

        ... ...



     It is seen that even if the sector does not read a single 
turnover of the track, it is possible that it will be read at 
the next traffic, since the onset of interrupt will be shifted 
to 150 bytes. 



     Note: On my "Pentagon" in the
The experiments showed that due to the reduced speed of 
rotation of the disc (299, 4 rpm instead of 300) the time of 
the interrupt shift than 150, and 138 bytes. In further

calculations to figure this is the
value. For each computer it
own, and, as we shall see, it depends on the degree of her slow 
reading of sectors. 



     We calculate what would be equal to the time
full disk access with illegal interrupts:


     0, 2 * 160 = 32 seconds


     Now let's try to estimate how many
time will slow down reading a single track standard TR-DOS disk 
included with interrupts. 



     Note: we assume that
reading tracks, the program first reads all the sectors in a 
row (in this case some of them, obviously, will not be 
correctly read because of an interruption), and

then every time you drive back
tries to read all previously incorrectly
a few sectors, and so on until
all sectors have been read.

     Please note that if the sequence is read multiple tracks
(Eg, 4), and each track is read, for example, 2, 5 turnover disc
all 4 lanes will be read not for the 4 * 2,
5 = 10, and a 4 * 3 = 12 rpm disc. This
due to the fact that when we give a command position on another 
track, and then give the command reading the sector, SH

does not immediately begin to read the sector, and will
expect the index pulse, indicating
at the beginning of the track.



     It is obvious that reading a single track (measured in 
revolutions the disk) will be determined by the time read 
"worst" sector, ie, a sector for reading

which will be allocated the largest number of attempts.

     The length of the sector on the disk is equal to TR-DOS
256 bytes. Consider the scheme, how can
reads this sector in the worst case:

 1 0 <- shows at

                          reading of
 2138 <- byte happened

                          interruption
 3


     That is, during the first turnover of the disk interrupt 
occurs while reading the bytes from offset 0, the second moment 
of turnover the onset of interruption to shift to 138

bytes so that the sector will not be read again, and finally, 
the third of the turnover, he read.


     Thus, we see that the reading of one track to slow down in 
3 times. Accordingly, the entire disk read by 32 * 3 = 96 
seconds, which is perfectly consistent with experimental data.


     Now consider the process of reading a single track disk 
MS-DOS. Sector Size 512 bytes. In this case, reading the 
"worst" of the sector can occur in two possible scenarios: 
either it reads on the fifth turnover of the disc, or on the 
ninth. This is shown in the diagram:


 1 0

 2 138

 3 276

 4 414

 5



 January 1993

 2 231

 3 369

 4 507

 May 5

 6 143

 7 281

 8 419

 9


     Practice shows that the reading of a single track MS-DOS 
disk in the middle increases of 7 and 6 times, then have a 
second option is implemented a bit more first.


     It is evident that because of the greater length of sector 
reading slows even more than a drive TR-DOS. In the TR-DOS gets

at least some advantage.


     But to work with the IS-DOS disk with
interrupts can not be included at all. I think you've guessed 
why - sector of 1024 bytes will be read for so long

that during this time will happen
interrupt, but maybe not one. By
the same reason, when included interrupts
can not format the drive or to perform
read command track.


     How do you implement simultaneous
playing music and reading a disc (without
any delay!) in the demo, as
POWER UP EYE ACHE and 2? Apparently, there
used this method: procedure
Music playback is started after
reading the next sector. But at the same
procedure call is not synchronized with
interrupts, and read errors are accompanied by unpleasant 
howling. 





Other articles:

From the authors - The authors of the magazine.

From the authors - Adventurer - the section of the popular magazines heritage.

Presentation - A new program for collecting tunes: UniPlayer v1.0

Presentation - a new graphical editor 3Color Studio.

Presentation - an unusual boot: Program Box version 2.0

Presentation - a new quest: Full Shit.

Presentation - a level editor for games Raven Black: Black Raven Editor v1.0

Presentation - the new editor for digital music: EARACHE v1.0

Interface - Letters from readers: Dawid Willis, Ivan Roshchin, Cav Inc. (Competition for the best name for your sound card, glitches in HRUST v1.0 and XAS v9.06 +)

Interface - How do we (CPU) were FunTop'e.

Interface - Opinion: on acquaintance with the PC.

Interface - branded cheats for the games: Midnight Resistance, Chase HQ2, Havoc, Turbo Girl, Fast Bredd, Turbo Boat.

System - An overview of new sistemok: Sprite Maker v4.0, Turbo Copier v2.0, Sample Studio, Art Works 1, Burst Eyes v1.2, Excess Sample Editor v1.4.25, Excess Deluxe Paint v1.1, Graphic Station, BA v1.0, Global Commander v1.31, Quick Commander v2.3, Stall Spriter v0.1, AGA v1.0, Ultra Sonic v0.1, Universal Sprite Studio v1.0, HRUST v1.1, STORM v1.3.

Review - Overview of gaming innovations: Leprekon, Fuck Communistov, Sherwood, GOAT, Kill PC 2, Chainick: Horror in the flat.

Review - Review of the demos: Black Raven 2 v0.000, Crime Santa Clause Deja VU, Awaken, Japan Crossword, Pussy: Love story from Titanic.

Guests - An Interview with Nicodim'om from Yaroslavl (the author of Prince of Persia and the Pirates).

Guests - An interview with a group of Rybinsk Expirience (authors kvecta Full Shit).

Guests - CPU on the life and future plans.

Promotion - A strategy game: Sword OF Bane.

Promotion - parsing the game of Rock Star: Rock Star ate my Hamster.

Exchange of experience - Rapid procedure for finding the root of the number and Testing Kempston-port of SerzhSoft'a.

Exchange of experience - The procedure for generating sine.

Exchange of experience - spinner - izvraschalka (Zoom Rotator).

Exchange of experience - SerzhSoft'a report on the regional Olympiad in Informatics in 1998.

Exchange of experience - TR-DOS: the disk included with interrupts.

Ottyag - 23 things you can do with the program hanging. Symbols - grimassy in the program notes. 20 things you can do if ochen want to drink, but you have no money. Verse of the monk.

Ottyag - Competition test: Test: What you need a computer? Test for the Communists. Test: Can I rely on you? Quiz: Who are you Spektrumist? (User or lamer).

Ottyag - Terminator 3 sleigh day (or the truth again, somewhere in there).

Iron - Sound card with direct access to: DMA Sound Card (description schemes and programming).

News - News from local groups: Volume 4, Groboclone, Surdakar, Di-Tech Labs, Auryn, Rainbow Dreams, Experience.

Advertising - advertising and announcements from spektrumistov.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Introduction - the reasons for registration of new newspapers.
B.B.S. News - The work BBS'ok.
History - A day in the life SEMEN'a.
Detective - Wanted: LOS INHUMANOS, MERCS ...
Fantasy - Eysenck Asimov "The man who never small." A herd of stellar dragons.
Razbiralka - Cheats THE GREAT ESCAPE.
solid jokes - 8 holes. Collection of statements by Soviet officers (continued).
Advertising - Advertisements and announcements ...

В этот день...   21 November