| And that's why I hate word problems. Half way through, tracks, fragments
and sectors are introduced without definition. Sigh.
Suppose f=3, t=10, and n=4. You want the logical blocks mapped like:
unit #0 unit #1 unit #2 unit �3
group 0 0 1 2 3 4 5 6 7 8 9 10 11
group 1 12 13 14 15 16 17 18 19 20 21 22 23
group 2 24 25 26 27 28 29 30 31 32 �3 34 35
group 3 36 37 38 39 40 41 4� 43 44 45 46 47
...
Let the (input) logical block number be x. Now the unit number u(x)
is simple: u(x� = (x div f) mod n. The group number g(x) is given by:
g(x) = (x div f) div n, or g(x) = x div (f*n), and the block nu�ber
within a fragm�nt is (x mod f).
But now for the complication. Each unit has only (t mod f)*f useable
blocks per track, and we want to find the block number of x, relative
to the beginning of the unit -- call this b(x). Thus, b(x) mod t will
always be less than (t mod f)*f. In the above example,
x 0 1 2 12 13 14 24 25 26 36 37 38 ...
b(x) 0 1 2 3 4 5 6 7 8 10 11 12 ... (b(x) = 9 is missing)
Thus, b(x) is something like g(x) * f + (x mod f), except that we need to
'skip� some b�ocks -- of every t blocks, we skip (t mod f) blocks. So,
b(x) = (g(x) div (t div f)) * t
+ (g(x) mod (t div f)) * f + (x mod f). (Eq.1)
or,
b(x) = ( g(x) di� (t div f) ) * (t mod f)
+ g(x) * f + (x mod f). (Eq.2)
Eq.1 is easier to understand; eq.2 is derived fr�m it after noting that
(x div k) * n + (x mod k) = (x div k) * (n-k) + x
|
| Talk about quick response! Thank you very much for the solution. There
is a small typo that I'll bring up, just in case anyone is interested:
>>>But now for the complication. Each unit has only (t mod f)*f useable
>>>blocks per track, and we want to find the block number of x, relative
Actually, each unit has only (t div f)*f useable blocks.
Also, I'm totally unable to fathom where (eq. 2) came from. Feeding
it into the simulation doesn't yield the same answers as (eq. 1),
which yields a correct solution.
However, thank you again. Your help was very timely, and I sure
appreciate it.
Jeff
p.s. I couldn't resist the word problem. The other choice was
to describe the series in terms of ordered pairs...but I
hadn't figured out a way to do so that would reflect the general
problem. Fourth grade strikes again!
|
| Thanks for pointing out the problems. Equation 1 is:
b(x) = (g(x) div (t div f)) * t
+ (g(x) mod (t div f)) * f + (x mod f).
Letting z = (t div f), this is:
b(x) = (g(x) div z) * t + (g(x) mod z) * f + (x mod f)
= (g(x) div z) * (t - f*z) + (g(x) div z) * f*z
+ (g(x) mod z) * f + (x mod f)
= (g(x) div z) * (t - f*z) + (x mod f)
+ f * ((g(x) div z) * z + (g(x) mod z))
b(x) = (g(x) div z) * (t - f*z) + (x mod f) + f * g(x)
But,
t - f*z = t - f*(t div f) = t mod f
So substituting the definition of z back into b(x) gives:
b(x) = (g(x) div (t div f)) * (t mod f) + (x mod f) + f * g(x)
This is the same as before.
Note that when evaluating these expressions in your program,
(x div a) div b = x div (a*b)
This will reduce the number of divisions.
P.S. The funny characters in .1 are due to some nasty line noise.
|