Sponsored Content
Top Forums UNIX for Advanced & Expert Users Linkage of POSIX threads function calls Post 302501461 by jsimsa on Thursday 3rd of March 2011 03:07:26 PM
Old 03-03-2011
Linkage of POSIX threads function calls

I wonder if someone knows what is the rationale behind linking function calls of the POSIX threads library at link-time vs. run-time.

For example, if I create the following program:

Code:
#include <pthread.h>

void noop() {
  return;
}

int main() {
  pthread_self();
  pthread_atfork(noop, noop, noop);
  return 0;
}

and compile it on Ubuntu version 10.10 with gcc version 4.4.5 using:

Code:
gcc -o test -lpthread -pthread test.c

then the pthread_self symbol is linked (dynamically) at run-time, while the pthread_atfork symbol is linked (statically) at link-time.

Further, there is the case of pthread_equal, code of which might be inlined (assuming __USE_EXTERN_INLINES is defined).

My project plans to use a run-time interposition based wrapper for the POSIX threads library functions to monitor and control interaction of a program with the pthreads library. Cases such as pthread_atfork and pthread_equal are giving me a headache :-).

--Jiri

Last edited by pludi; 03-03-2011 at 04:33 PM.. Reason: please use code tags
 

9 More Discussions You Might Find Interesting

1. AIX

overriding function calls without recompiling

i want to replace the *alloc and free function calls in an existing project with my own functions, to be able to log the adresses etc in a text file. (memoryleak debugging) I think LD_PRELOAD is what i am looking for. That way i could create a Library with my own malloc functions and link them... (1 Reply)
Discussion started by: Lazzar
1 Replies

2. Programming

POSIX threads

Hello ! Let's supose I have a main function in C , and two POSIX threads. I give you an example down : int main() { int something; char else; void *FirstThread(); void *SecondThread(); .. <start those two pthreads ..> return 0;} void *FirstThread() { ... } void *SecondThread()... (2 Replies)
Discussion started by: !_30
2 Replies

3. HP-UX

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people! I've got this own library: -------------------------------------------- Personal.h -------------------------------------------- #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdarg.h> #include <string.h> ... (0 Replies)
Discussion started by: donatoll
0 Replies

4. Programming

Tracing Function Calls in a program

Apart from writing debug and statements in constructors is there any way by which we can trace the function call stack at any depth? The issue that we always face is that when program crashes (Web Server running on Linux) we have no idea where it crashes and we have to do the hard way of... (1 Reply)
Discussion started by: uunniixx
1 Replies

5. Programming

POSIX threads and data safety

I created multiple POSIX threads (on readhat Linux) in a C program in my app. What I am doing is - I am creating threads equal to the number of CPUs in the system and and equal number of instances of a certain data structure, basically a queue implementation. I am assigning one ID to the thread... (2 Replies)
Discussion started by: radiatejava
2 Replies

6. Programming

ndd commands using function calls

Hi, Is there any function calls available ( for using in a C program ) to get the Ethernet Link status. ? I am looking for the status available from ndd /dev/hme link_status And how about plumbing and configuring an interface using C program ? BTW, Is all this documented... (3 Replies)
Discussion started by: shibz
3 Replies

7. UNIX for Advanced & Expert Users

Posix threads

Hi, consider the code below: #include <stdio.h> . . struct myStruct { char *message ; int id; }; . . . void *thread_function( void *ptr ); nt main() { pthread_t thread1, thread2 ,thread3 ; struct myStruct nico1; (2 Replies)
Discussion started by: Behnaz
2 Replies

8. Programming

need help with posix threads

Hi, I am new to posix threads. The no of threads to be created depends on the runtime. If I get the number of threads, I need to forward declare pthread_t mythread; how to do that can I use pointers and use malloc()?? I also have another question. The pthread_join is used to make... (0 Replies)
Discussion started by: brett01
0 Replies

9. Shell Programming and Scripting

Question about Function calls

Hello everyone, here's my problem: I want to create two shell scripts. one of them should includes some functions, the other one just the function calls. Is this possible? Can i call a function which is placed in a scriptfile eg functions.sh out of another script eg call.sh? :confused: And if... (2 Replies)
Discussion started by: Sebi0815
2 Replies
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy