|
8BIT OPERATING SYSTEM FOR ZX-SPECTRUM
\develop \ioma
The manager of memory
Here I wish to tell idea of the manager of memory, not at a physical level (/dev/mem) it zanimatsja will be the driver of memory, namely the module which will be sdelit behind the allocated sites, to borrow and release, to conduct search and the account. Certainly the manager of memory on a spectrum it not grateful business, even to that any started proramma can sharahnut on ports and bangs system. At the best we shall receive lag and "dump" of a computer, in huchshem the damaged site can incorrectly fulfil and put not reperable uvechija on a disk. However in my opinion not all so is sad, for example on the same AMIGA there is no protection of memory, as for example on petsete. However at accurate juzanii and correctly written software, I think problems should not be. As if to start before the written software (game, demy) here already all depends on a concrete case, or it is possible to correct a correct output in system, or after start-> reboot!
But we shall depart from izlivanija waters:) also we shall pass to the idea! And the idea consists in the following, we have a number of restrictions (iron speccy), and we can monolitno simultaneously address 1 bank of memory in 16e. Behind a rare case monolitno 32e (with *8000 on *FFFF). But it is meant, that in memory some processes (programs) and an allocated monolith can work at once can be no more 16e! But it so the theory. We shall return to idea. Frequently process does not need 16e, and reservation in such mastabah not expedient use of resources. Therefore pochitav clever books:) it has been decided to cut 16e on segments on 2e. And for search of an empty seat to make a bit card in which free sites would be marked with bats: 1 - the free site, 0 - is borrowed (why so, rather the reverse a little below) so we shall receive 1 byte of a bit card will be responsible for 1 bank of memory (16e.)
Now a search engine of a free site. We shall admit make search in 5-th bank having read through, we receive a following picture - 7,6,2 - segments are borrowed, 5,4,3,1,0 - segments are free. In a binary kind we receive a picture %001110011. We need to find area in 6e, that is 3 monolithic segments on 2e. Having presented binarno we shall receive number %00000111. Now the first we shall designate A, and a required place - B. We make operation A AND B, result in C. We check if C and B are equal, means we have reached desirable result and the empty seat is, if is not present we execute a command tsiklichesko displacement to the left B, and we repeat operation A AND B. Schematically, it looks so:
Thus for four stages we have found a required cell. Certainly it while in the theory:) also it is necessary poeksperementirovat in practice. For example, preliminary to check up, instead of whether the element of a bit card 0 is equal? Then here and to search there is nothing, but idea I think you have understood. (ksta with a bit card in 16e it is possible to address up to 256Ia!!:) and if to stretch up to 128e - 2Aa!!! Imagine spek with such frame?:)
P.S. At once it would be desirable to specify one moment, here can voznikunt a question when to the program it can be demanded more memories, than 16e. In this case at once it would be desirable to tell, that 16e it under ispolnjamyj a code! And only! For example executed file consists at least of several sektsy: section of an executed code, section of resources (a picture, an icon itd), section of data (for example tables or still something). And so restrictions in 16 are imposed only on an executed code (so to say main {}), section of resources and data can is and in other banks (sektsijah), in an executed code, will be returned by system of the address where to take this or that resource (I think it it is not critical?) if the executed code starts to exceed 16e it is more expedient to use system of libraries (they too can be in other parts of memory).
P.P.S. All this is certainly good:) but there is a question of other plan, for example vozmem the text editor or the editor semlov, such programs are very exacting to memory: (and the buffer in 16e can seem somehow is small: (here I see two variants of the decision of a problem, it is possible to make the mixed type of memory (for example in the end of each segment 2e to allocate 2 bajta with the reference to a following segment of this chain), but here at once there can be a mess, torrmoza, and superfluous use of memory (on 16e we shall lose the order of 16 bytes!). There is a second variant, for example to dump neispolzujumuju memory in swap on a hard disk. That is we have access to 16e real memory, and in swap its size is not limited! But here a binding to a hard!
Voobshchem I look forward to responses in feedback'e who that thinks? Can what ideas will or wishes?.
|
|