The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
highly optimized file reading and writing?
Discuss highly optimized file reading and writing? in the C Programming forum on Dev Shed. highly optimized file reading and writing? C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 13th, 2003, 06:22 PM
|
|
matthewdoucette.com
|
|
Join Date: May 2002
Posts: 635

Time spent in forums: 10 h 8 m 16 sec
Reputation Power: 11
|
|
|
highly optimized file reading and writing?
I want to know if this is possible:
To write an array of data directly to the disk and then later read it back into memory without ever having to parse the data.
In more detail, the write to the disk would be an exact byte per byte copy, (done whichever way is the fastest and most optimized possible), directly from memory to disk, without worrying about data structures and variables. The read from the disk will be exactly the same, ignoring all data structures, variables, and any parsing what-so-ever. The read will directly overwrite the exact space in memory that is already declared. If this could be done, then I think this is the fastest way to store an array of data to disk that needs to be constantly reloaded into memory to be udpated and then quickly stored again.
Is this possible?
__________________
Matthew Doucette / Xona.com
|

January 13th, 2003, 06:27 PM
|
|
matthewdoucette.com
|
|
Join Date: May 2002
Posts: 635

Time spent in forums: 10 h 8 m 16 sec
Reputation Power: 11
|
|
|
(BTW, I know that it would be faster to simply keep the data in memory and update the data in memory and then periodically write the whole thing to disk, especially seeing that this is a webpage application, but this is not an option as I have not learned how to do this yet.)
|

January 13th, 2003, 07:56 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Yes, it is possible to do a write to disk and reread the data into a buffer. However, it sounds like you probably want to use shared memory instead, especially if you want to share some common data between multiple instances. This way, you can avoid disk I/O
Hopefully this link may prove to be useful.
|

January 23rd, 2003, 11:37 AM
|
|
matthewdoucette.com
|
|
Join Date: May 2002
Posts: 635

Time spent in forums: 10 h 8 m 16 sec
Reputation Power: 11
|
|
Thanks for the link, Scorpions4ever, but I think I am going to try to save everything to disk before I learn how to code a server that handles requests and all of that.
Quote: Originally posted by Scorpions4ever
Yes, it is possible to do a write to disk and reread the data into a buffer. | Ok, if I can do this, can I reread the data into a buffer located in the exact space of memory as an already defined and declared array, for example?
|

January 23rd, 2003, 03:39 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Quote: Originally posted by Doucette
Ok, if I can do this, can I reread the data into a buffer located in the exact space of memory as an already defined and declared array, for example? |
Yes, you can. If you think about it, when you're reading any character string (whether from file or from console), you're putting it into an already defined and declared character array. The only thing you need to watch out for is to ensure that your buffer is large enough to contain the data that you're reading back into it.
|

January 24th, 2003, 11:09 AM
|
|
matthewdoucette.com
|
|
Join Date: May 2002
Posts: 635

Time spent in forums: 10 h 8 m 16 sec
Reputation Power: 11
|
|
|
Excellent. This is obviously the fastest way to write data to a disc and later read it back. No parsing what-so-ever.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|