• C

contiguous sec-memory assignment

Hi,
 I am trying to build a mini-DBMS project on linux. I am having difficulty in accessing secondary memory directly so that the data can be stored contiguously ovrer the secondary memory. How can i make sure that the files are allocated contiguous space on the disk?

thanks,
Vikram.
Vikram_BAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grg99Commented:
Why do you need contiguous space?    Linux is very good at caching disk I/O. Plus all modern disk drives have considerable internal buffer memory.   I wouldnt worry about this unless you need to transfer oodles of tens of megabytes per second.
0
ccworkCommented:
I don't understand your question. It is the task of file system to handle your DB file; you don't need to care about it for access. (indeed, you CAN'T expect the data is stored in consectie place in harddisk even using raw access; in other word, even if you store starting from sector 1 to sector 2000, DON'T thought that it is really stored from sector 1 to sector 2000. What geometry presented to OS is just a mask).
0
Kent OlsenData Warehouse Architect / DBACommented:

HI Vikram,

Look at the mmap() API.  It will allow you to address the entire file as congituous memory, while allowing the O/S to store it on disk in "native" format.


Kent
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

ssnkumarCommented:
Writing to secondary disk can not be dictated by the user programs.
The file manager will take care of it. You need not worry about how it is saved in the disk.

If you still want to do it, then you will have to your own filemanager and drivers.

-ssnkumar
0
Vikram_BAuthor Commented:
i guess earlier versions of Oracle DBMS used to request the users to defragment the drives before installing the DBMS. also, Windows defragmentation seems to improve speed of access of the files.

cann't i use the same logic for linux too? if i can defragment the data, cann't i speed up data retrieval and insertion? if i am not wrong, DBMSs can bypass the file system for efficiency purpose.

I am curious to know if i can do the "defragmantation" part using C on linux.

Thanks,
Vikram
0
ssnkumarCommented:
Defragmentation is not a simple program.
I think the Linux already has this and you need not worry about it.

-ssnkumar
0
ccworkCommented:
Defragmentation is independent of OS. Defragmentation means that re-structure the data structure (yeah, file system is just a data structrue). For FAT, it is just allocation table; for NTFS it is a B-tree something and you have to re-order the master file.

It is IMPOSSIBLE to do defragmentation for a partition while the OS is running on that parition (since OS write to disk continously for its internal operation, say swap).
0
grg99Commented:
> Defragmentation is independent of OS. Defragmentation means that re-structure the data structure (yeah, file system is just a data structrue). For FAT, it is just allocation table; for NTFS it is a B-tree something and you have to re-order the master file.

Hmmm, you're forgetting the big part-- shuffling the actual data blocks so they're contiguous.



>It is IMPOSSIBLE to do defragmentation for a partition while the OS is running on that parition (since OS write to disk continously for its internal operation, say swap).

Er, um, Every version of Windows has been able to defragment a mounted or system volume that's on-line.
So IMPOSSIBLE is a bit of a stretch.


0
NovaDenizenCommented:
One way to do it is with disk partitions.  Use a resizing disk partitioning utility to make a new partition (say, /dev/hda7 ).  Then, change ownership and permissions on /dev/hda7 so that your application will be able to use it.  You can treat /dev/hda7 just like a big fixed-size file, meaning you can fopen() it, mmap() it, or whatever.  It's guaranteed that this will not be fragmented, and access will be a little more efficient than in a regular file.  

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.