?
Solved

contiguous sec-memory assignment

Posted on 2005-03-22
9
Medium Priority
?
366 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:Vikram_B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 22

Expert Comment

by:grg99
ID: 13600270
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
 
LVL 1

Expert Comment

by:ccwork
ID: 13600289
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
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13600721

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ssnkumar
ID: 13608783
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
 

Author Comment

by:Vikram_B
ID: 13608835
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
 
LVL 8

Expert Comment

by:ssnkumar
ID: 13608880
Defragmentation is not a simple program.
I think the Linux already has this and you need not worry about it.

-ssnkumar
0
 
LVL 1

Expert Comment

by:ccwork
ID: 13631798
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
 
LVL 22

Expert Comment

by:grg99
ID: 13632304
> 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
 
LVL 22

Accepted Solution

by:
NovaDenizen earned 75 total points
ID: 13633185
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question