[Tutor] Simplistic drive simulation

R. Alan Monroe amonroe at columbus.rr.com
Sun Mar 13 07:51:51 CET 2011

I'm trying to mentally plan out the most bare bones drive simulation
possible, but I have this nagging feeling that I'm missing something.
I was just going to start with, say, 16 or 64 "blocks", then randomly
add and delete ficticious "files" (which won't have any actual
content - I'm just trying to do the block management portion). For
drive=[None * 16]
add 3 files A,B,C
delete file B
add file D

1. Is there some more clever way of tracking this than the very naive
toc = {
  A: [0, 1, 2],
  D: [3, 4, 5, 9, 10],
  C: [6, 7, 8]
} ?

2. Is there some more clever way of adding files beyond the very naive
brute force approach (pseudocode):
while file still has more to write:
      while drive[block]!=none:
            block += 1
      drive[block] = file.pop(0)

Neither of these seem like they'd scale very well (say, up to the
resolution of your screen, with one block per pixel). The end goal is
just a basic do-nothing light show that simulates
fragmentation/defragmentation as eye candy.


More information about the Tutor mailing list