473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Questions about shared libraries (.so)

Hi.

I am writing a shared library to override some libc
functions.

I have the following questions:

Ex.
int XXX=0;
void f() {++XXX; ...; --XXX;}

1.
Are global data (extern) shared among processes
or threads? If a process or a thread accesses f while
another one is also executing f it sees XXX as 0 or 1?

2.
Is there any problem not freeing malloc allocated areas in f
relying on the automatic free at the end of the job?
I am asking this because I want to share some information
between sucessive calls to f in a process but I don't know what
is the last call. So, I don't know when to free the malloc'ed
areas.

Any links to literature about these is welcome.

Thanks for any help.
Nov 14 '05 #1
2 1369
Paulo da Silva wrote:
Hi.

I am writing a shared library to override some libc
functions.

I have the following questions: [snip]
Any links to literature about these is welcome.

Thanks for any help.


Wrong newsgroup. This newsgroup, news:comp.lang.c,
discusses the _standard_ C language which has no
facilities for shared libraries. These are outside
the scope of the language.

Not all platforms support shared libraries. Please
consult a newsgroup dedicated to your platform.
Many newsgroups are listed in the FAQs below.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Nov 14 '05 #2
On Mon, 07 Feb 2005 16:41:55 +0000, Paulo da Silva wrote:
Hi.

I am writing a shared library to override some libc
functions.

I have the following questions:

Ex.
int XXX=0;
void f() {++XXX; ...; --XXX;}

1.
Are global data (extern) shared among processes
or threads?
That would depend on the implementation and how it implements processes
and thread which are not C concepts. Typically however threads share the
same address space whereas processes for normal operations don't.

Given your reference ot .so lubraries comp.unix.prorgammer might be a
better place to discuss this.
If a process or a thread accesses f while
another one is also executing f it sees XXX as 0 or 1?
That would depend on when XXX is accessed. Also consider makin XXX
volatile.
2.
Is there any problem not freeing malloc allocated areas in f relying on
the automatic free at the end of the job?
That depends on what you mean by a "job". You should free memory when you
no longer need it or else you might have a memory leak. On reasonable
systems the memory allocated by a program is reclaimed when the program
terminates.
I am asking this because I
want to share some information between sucessive calls to f in a process
but I don't know what is the last call. So, I don't know when to free
the malloc'ed areas.


If it is a single allocation that's not too large that may not be a
problem, you might think of it like a static variable.

Lawrence
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
0
by: Frieder Loercher | last post by:
Hello, I am developping a (lammpi) parallel Application where any of the processes uses the Python script language. It works fine on Compaq Alpha and SUN Solaris5.9 On AIX5.1, it doesn't...
3
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine...
1
by: rinku24 | last post by:
We have two C++ libraries (Unix Shared objects) with the same class name and no namespace. Is there any way to load both the libraries and selectivly create the instance of the class from...
1
by: RHNewBie | last post by:
Hello, I have an executable which uses two shared libraries(A and Z). I do not have the source code for the executable. However I can tell the executable to load the shared libraries and invoke...
7
by: Steve | last post by:
Hi, We have an application framework library that gets statically linked to any applications we produce. (Windows apps, but I don't think that matters here). The framework is based heavily on...
2
by: Tobias Bergmann | last post by:
Hi, I work on a big project that consists of many small linux C++ CGI binaries. This actually works fine but our problem is that we use many ..so libraries and we need to compile it separately...
3
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another...
4
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.