Finding a function to map from logical to physical addresses

49 Views Asked by At

This is sort of an unusual question. For you to understand, you'll need to look at the picture below. The gray background is irrelevant.

enter image description here

You can notice there are $4$ discs, splitted to numbered logical sectors. What I wish to find is the physical address of a sector (the position within the disc itself).

For example,

  • The sector numbered $13$ is actually located at the physical address number $05$.
  • The sector numbered $06$ is actually located at the physical address number $02$.

Terminology:

  • A Block is a row of sectors ($4$ in our case)
  • A strip is a row of blocks (also $4$ in our case)

Basically, we can reduce our problem only for the first $4$ rows since the same can be applied for the others.

I'd be glad to get help with figuring out a formula (or a pseudo-code) which converts logical to physical addresses.

UPDATE
Barry kindly helped me with converting a logical to physical address (it actually very inventive when I think about it).

I also need to to return the device number ($0-3$).
How do I do that?