8BIT OPERATING SYSTEM FOR ZX-SPECTRUM
iron OS, system of drivers
One of the key moments of any operational system - is the system of drivers. System of transparent access to resources of a computer and absence of attachment to one concrete zhelezke. It in a sufficient measure unties hands to the programmer. But except for all it it is competent napisanyj the interface of interaction, to several processes simultaneous access allows to provide to one resource of iron. Prividu an example. obchitavshis once again clever books:) Me has pulled on the some people eksperementy. How i
t is realized systems o
f drivers in system Windows and UNIX (FreeBSD)?.
eksperement consist in the following. On one o
f terminals the command cat/dev/fd0> dump (
f a diskette at image) has been executed, and on the second terminal I have tried vybolnit a command ls/floppy (to display contents of a diskette, analogue DIR in MSDOS). On my surprise the catalogue was deduced instantly (not interrupting a command cat). Further I have tried to read through and copy a file on a diskette. The head of the disk drive has made pair movements and and process of copying of a diskette at image has proceeded. When I have read through the catalogue of a diskette, the file was on a place. Now we take Windows:) we Open same a diskette in Total Commader'a it is remarkable:) We start WinImage and we start to read a diskette at image. Now we are switched to Total Commander'o and.... ops! The Disk is borrowed! On it our experiment also has ended, and not having begun: (Certainly for quite some time now in windows have appeared the WDM-driver, but as they say - not destiny...
I think here and so all is clear, komentirovat there is nothing. We shall return to our variant. Proceeding from the above described experiment, it would be desirable to ask a question - and how to realize system of the general access? Certainly there are exclusive situations when for example the device needs to be monopolized, for example at record of a disk, or work of the modem, but it only at a mode record, to read to us of anything I think, nedolzhno to stir!? Though finally all will depend on a final stage of a design of the driver. I think it is possible budet to break into some modes: free (a mode when, the device freely also is not present, any process which to it addresses), public (a mode when there is even one process, kotororyj reads at present data from this device, other processes can read and write), state (a mode when one process carries out the monopolized record in the device, other processes can read through from the device, but cannot write) and private (to the device other processes should write the monopolized access of process read). What mode to choose, I think it it is necessary to choose to the driver, depending on made operation. I shall explain on an example. For example process1 prozvodit reading from a diskette (the mode public is exposed, to default always free), further appears process2 which record (the mode varies on state) makes. process1 it will not affect performance at all. Further we shall admit pojavletsja process3 which wishes to make full pereinitsializatsiju diskettes (format) and by that the mode private demands. Schematically it looks so:
All is as though remarkable, but here there are some questions! predstvljaete that will be, if everyone lomanetsja rulit? Here again I see some decisions. In the first it is necessary to provide sequence of performance of processes. In clever books suggest to realize a mode of semaphores. That is on performance of process to allocate any time, then management is transferred following process and so on. Except for that it is necessary to consider feature of transition from one mode in another (free-> public-> state-> private). Besides there can be a situation when process can and not wait access to the device and as consequence is simple naprosto to hang: (the Output from this situation - "alarm clock":) Inside the counter of inquiries to the device and if it approaches to zero (or to the certain number of attempts) to process the message "TIMEOUT" comes back turns. Process solves, that it to do or to make inquiry once again, or to come to the end with sobshcheniem about a mistake. If to represent schematically the following algorithm of access of process to the device turns out:
Some comments to the scheme: in the beginning the status of the device if it private in the further any actions are impossible, voetomu is expected is checked shall not take off yet on tajmautu, or all the same we shall wait changes of the status. In this case the example for vypolenija Read (enough status state), for vyponenija Save neohodimo is resulted, that the status would be public! And for transition in an exclusive mode of dialogue with the device (private) it is necessary and at all, that ustrojsvo would be in a mode free. The semaphore here carries out a role not only the switch between processes obrashchajushchimesja to the given process but as enables vyponenija other processes of system. The truth considering feature of iron (otsutsvija IRQ and DMA) a spectrum, I think it is necessary to all this to test in real, instead of in the theory.
On the given scheme the algorithm of access to the device in a mode of record is represented. In the first cycle we expect clearing the device (if it is borrowed in a mode private), whether further is checked carries out still any process record if is not present the mode state is exposed. Further having waited the turn at a semaphore, process writes down the block of data. After end of all operations there is a check if it was unique process the mode free is exposed, otherwise - public. Further prevedena the scheme for a mode private:
Inherently it not strongly differs from the scheme for a mode save. Exceptions are made by that for that what to pass in a mode private would be necessary that the device would be in a mode free. That is all the previous processes should be completed.
Voobshchem I look forward to responses in feedback'e who that thinks? Can what ideas will or wishes?.
P.S. At the given stage the information on iron of a spectrum gathers what to come to a certain standard. Already there is a certain similarity of drivers for HDD controllers of type KAY and Scorpion (SMUC), but the more data acts about others possible, the it is more complex to come to a certain standard in a format of drivers. What to facilitate to itself a life in the future program HardDisk Search*Test (it is accessible in section download) is written. On the one hand its purpose is search of a hard disk and a conclusion of the information on it. Such for example, as quantity of heads, cylinders, sectors, the version of an insertion, and many other things. But sdrugoj with its help it is possible to choose an optimum format of drivers, proskolku it allows podgruzhat different the driver. Are at present written the driver for controllers of type KAY and Scorpion (SMUC) and they work 100 %. On the approach a writing under other types kontronrollerov. If you wish to take part aaoa-testing write email@example.com.
PPS. As the writing similar (HDST) programs and under other iron, with the purpose of revealing of iron is planned. In process of popolenija, in section \develop \nessy will appear sootvetsvujushchie subitems.