Simulator
This lesson explains how to interact with the simulator for the exercise presented in the next lesson.
We'll cover the following...
Welcome to ssd.py
, yet another wonderful simulator provided to you, for free,
by the authors of OSTEP, which is also free. Pretty soon, you’re going to
think that everything important in life is free! And, it turns out, it kind of
is: the air you breathe, the love you give and receive, and a course about
operating systems. What else do you need?
To run the simulator, you just do the usual in the terminal above:
prompt> ./ssd.py
The simulator models a few different types of SSDs. The first is what we’ll
call an ideal
SSD, which actually isn’t much an SSD at all; it’s more like a
perfect memory. To simulate this SSD, type:
prompt> ./ssd.py -T ideal
To see how this one works, let’s create a little workload. A workload, for an
SSD, is just a series of low-level I/O operations issued to the device. There
are three operations supported by ssd.py
: read (which takes an address to
read, and returns the data), write (which takes an address and a piece of data
to write, in this case, a single letter), and trim (which takes an
address). The trim operation is used to indicate a previously written block is
no longer live (i.e., the file it was in was deleted); this is particular
useful for a log-based SSD, which can reclaim the block’s space during garbage
collection and free up space in the FTL. Let’s run a simple workload
consisting of just one write:
prompt> ./ssd.py -T ideal -L w10:a -l 30 -B 3 -p 10
The -L
flag allows us to specify a comma-separated list of commands. Here, to
write to logical page 10, we include the command w10:a
which means “write”
to logical page 10
the data of a
. We also include a few other specifics
about the size of the SSD with the flags -l 30 -B 3 -p 10
– but let’s
ignore those for now.
What you should see on the screen, after running the above:
FTL (empty)
Block 0 1 2
Page 0000000000 1111111111 2222222222
0123456789 0123456789 0123456789
State iiiiiiiiii iiiiiiiiii iiiiiiiiii
Data
Live
FTL 10: 10
Block 0 1 2
Page 0000000000 1111111111 2222222222
0123456789 0123456789 0123456789
State viiiiiiiii iiiiiiiiii iiiiiiiiii
Data a
Live +
The first chunk of information shows the initial state of the SSD, and the second chunk shows its final state. Let’s walk through each piece to make sure you understand what they mean.
The first line of each chunk of output shows the contents of the FTL. This simulator only models a simple page-mapped FTL; thus, each entry within it shows the logical-to-physical page mapping for any live data items.
In the initial state, the FTL is empty:
FTL (empty)
However, in the final state, you can see that the FTL maps logical page 10 to physical page 10:
FTL 10: 10
The reason for this simple mapping is that we are running the ideal
SSD,
which really just acts as a memory; if you write to logical page X
, this SSD
will just (magically) write the ...