Advertisement
Guest User

Untitled

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