Clarification of Answer by
skermit-ga
on
09 Jun 2002 19:24 PDT
"...if hard disk file is designated to accomodate a MAXIMUM of
1,000 records of 240 bytes each. The answer of 252,000 bytes exceeds
the maximum amount. How can this be?"
What is confusing is that you're not reading that the maximum file
size is 1,000 records at 240 bytes, you're reading you need a paging
system that can accomodate at a maximum, 1,000 records at 240 bytes.
Due to something called internal fragmentation (see link below) you're
going to need a storage structure (here a file structure, in OS, a
memory structure) which is bigger than the best case scenario (using
240,000 bytes to store the entire database = 1,000 records * 240
bytes). You're "wasting" 160 bytes (4,000 bytes - (16 records * 240))
every page you use due to this memory fragmentation. Because of that,
you'll need 63 pages (see calculations above) and the total file size
will be 63 pages * 4,000 bytes = 252,000 bytes. One more thing, since
you need 63 pages due to the internal fragmentation you can really
store 63 pages * 16 records = 1,008 records in your file, more than
the 1,000 "maximum" you have to work with. But since there's no way to
design a structure system with half a page in a fixed size
partitioning scheme, you have that little wasted space in each page,
and in the last page you're wasting more than half of the page. (2080
bytes = 4000 bytes - (((1000 bytes - (62 pages * 16 records)) * 240
bytes)) Add up all the wasted spaces, 12,000 bytes = 2080 bytes + (62
pages * 160 bytes), and you see why your file's 252,000 bytes, not
240,000 bytes. Sorry if this clarification is a little confusing, I
tried to write everything out step by step.
Additional Links:
Powerpoint slideshow on memory management systems in operating systems
(only concern yourself with slide #9 (substitute memory for file, it's
the same principle):
http://www.utdallas.edu/~janet/CS4348/CLASSNOTES/Chap7.ppt
skermit-ga