Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I think Eric's method is *close* to optimal. Fundamentally, you need
- to flip at least one bit every 30 seconds, or you aren't changing the
- memory state when the clock position changes (which would mean
- that you cannot possibly be tracking the clock's state). The optimum
- solution, in terms of avoiding resets for as long as possible, would be
- to flip as few bits as possible at every 30 second interval. Eric's
- method is to flip exactly one bit per interval (obviously the fewest
- possible) until you've flipped 7200 of your 8176 bits, at which point
- his method goes beserk and wastes the remaining 976 bits (or
- almost 12% of the total), plus 900 byte erases (which are also bit
- flips that could be used for encoding information). So there's over
- 20% wastage, and hence scope for a 25% increase in longevity...
- The fact that the number of bits you've got to play with isn't a nice
- integer multiple of the number of distinct states you're trying to track
- complicates things slightly, but let's ignore that for the moment and
- describe the algorithm we'd ideally like to use. If the two numbers
- were in a nice integer ratio, the optimum solution would be to start
- with all bits set to one (which would indicate, for example, 12
- o'clock). 30 seconds later, we'd flip the first bit to zero; then 30
- seconds later flip the next bit; etc. This continues until we've flipped
- all 8176 bits to zero, then 30 seconds later we reset the first *byte*
- to all ones; 30 seconds after that we reset the second byte to all
- ones; etc. This continues until we've reset all bytes, at which point
- we're back to the original state and everything repeats from the top,
- having taken (8176 + 1022) * 30 seconds = 76.65 hours. (For a
- given memory state you can always distinguish whether you were in
- the middle of flipping bits to zero or bytes to one by whether the
- memory holds zeros followed by ones or ones followed by zeros, or is
- all zeroes or all ones -- all these states refer to unambiguous
- positions in the cycle.) Going through all 100 000 erase cycles will
- take 875.0 years, which I think is the absolute theoretical maximum
- you can attain. In practice you can't quite achieve this, because you
- also need to keep track of how the 9198-period memory cycle aligns
- with the 1440-period clock cycle. So...
- To achieve a practical optimum, I think you need to sacrifice a few
- bits to record the clock state corresponding to the all-ones memory
- state that the current memory cycle begins with. This requires at
- least ln(1440) / ln(2) = 10.5 bits -- let's assume for the moment that
- it takes a full eleven bits, and try to improve on that later (and I'm
- not even joking...). So the algorithm is now to reserve the top eleven
- bits for recording the mapping from memory cycle phase to clock
- cycle phase, and then apply the theoretical-optimum algorithm
- described above to the remaining 1020.625 bytes. In other words,
- you flip bits to zero until you've flipped 8165 bits, then you reset
- bytes to all ones until you've reset 1021 bytes (the final reset of
- which clobbers your memory-to-clock-cycle phase shift record). As
- you reset the 1021st byte and clobber the phase info, you then
- immediately also reset the top byte and write the new phase shift
- back to (eleven bits of) the top two bytes (because you are now at
- the start of a new memory cycle and so have a new phase shift).
- Thus the top two bytes don't update any more frequently than the
- other 1020, and we reset all bytes once every (8165 + 1021)
- intervals. Hence the system lifetime is 873.86 years (99.87% of the
- 875 years absolute theoretical maximum).
- I think you may also be able to recover some (probably not all) of
- that additional half-bit of entropy we haven't used yet, at the cost of
- some additional code complexity. The idea is that there will be some
- bit patterns that never occur in those top eleven bytes holding the
- phase info (as they only ever hold values in the range 0-1439). It
- may therefore be possible *for some specific values in that range* to
- flip an additional bit (which one will depend on which precise phase
- value is being stored) to give a bit pattern that would never
- otherwise occur and which can thus continue to represent the
- original phase value *plus an additional interval count*. You would
- need to watch out that you only ever assign a given unused bit
- pattern to a single, unique phase info value, and that the unused bit
- pattern is reachable from the corresponding phase info value
- without needing a byte reset. If you manage to use the full half bit of
- entropy in this way, you can push the system lifetime to 873.9 years!
- I think I shall leave the details "as an exercise for the student",
- though...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement