LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-25-2010, 05:26 PM   #1
vragukumar
LQ Newbie
 
Registered: Dec 2009
Posts: 6

Rep: Reputation: 0
Save/Load data segment of Dynamically loaded Shared Object library


All,

Our application uses a dynamically loaded shared object library (codec library) to compress and decompress audio streams.

There happens to be several static and global variables in this shared object library. Hence it is not possible to process two interleaved unrelated media streams using this shared object codec library because each stream corrupts/changes the contents of these static/global variables.

Is there a way through which a context save (save contents of data segment of shared object) and a context load (load previously saved contents of data segment of shared object)operation can be performed on the shared object library. This way the context for each media stream can be saved and loaded before and after processing the "other" media stream respectively.

Thanks in advance.
Regards,
Vikram.
 
Old 08-25-2010, 06:18 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by vragukumar View Post
All,

Our application uses a dynamically loaded shared object library (codec library) to compress and decompress audio streams.

There happens to be several static and global variables in this shared object library. Hence it is not possible to process two interleaved unrelated media streams using this shared object codec library because each stream corrupts/changes the contents of these static/global variables.

Is there a way through which a context save (save contents of data segment of shared object) and a context load (load previously saved contents of data segment of shared object)operation can be performed on the shared object library. This way the context for each media stream can be saved and loaded before and after processing the "other" media stream respectively.

Thanks in advance.
Regards,
Vikram.
Why not save/load just the modified global/static data ?
 
Old 08-26-2010, 11:26 AM   #3
vragukumar
LQ Newbie
 
Registered: Dec 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Sergei,

Thank you for your response.

Yes that is a possibility, but it turns out that what you are suggesting is a rather cumbersome solution for us. These shared objects are generated from third party code. Not all global symbols are exported by the shared object. And it is rather tedious to go through 50+ files to determined all global/ static declarations and export them.

This is the reason why we are looking for an approach where the entire data segment of the shared object can be saved/reloaded.

Thanks and Regards,
Vikram.
 
Old 08-26-2010, 12:29 PM   #4
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,144

Rep: Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127Reputation: 1127
You could read /proc/self/smaps to find the writable 4KB pages that were mapped by the act of loading the .so.

Those are effectively what you seem to mean by "data segment" of the shared object, but

If the code in the shared object allocates and deallocates any objects from the heap, the shared objects "data segment" would contain only pointers to those heap objects. If you saved/restored/swapped just the "data segment" you would be corrupting the heap any time you save/restore across a boundary of allocate or deallocate on the heap.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] yum failed to map segment from shared object robmoser Red Hat 4 04-19-2010 01:22 PM
Shared object constructor not called when library loaded adevi003 Programming 2 10-12-2009 05:51 AM
Where is LKM's text and data segment once it is loaded into kernel? tommy24 Linux - Kernel 4 07-25-2008 10:13 PM
shared object library won't load (libstdc++) sleepylight Linux - General 4 04-27-2004 05:24 PM
problem in dynamically loading the shared object sumit Programming 1 01-10-2002 04:15 PM


All times are GMT -5. The time now is 02:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration