Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6003367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:06:41+00:00 2026-05-23T01:06:41+00:00

I have a question: if we have an application, which uses no threads, we

  • 0

I have a question: if we have an application, which uses no threads, we can link it in two ways:

1) Link as usual, without -lpthread and -ldl

2) Add to the link two libraries: libpthread and libdl.

E.g.

$ cat a.c
int main(){printf("Hehe");}
$ gcc a.c -w -o a
$ gcc a.c -w -o a1 -ldl -lpthread

By default, both libs are dynamically linked:

$ ldd a
    linux-gate.so.1
    libc.so.6
    /lib/ld-linux.so.2
$ ldd a1
    linux-gate.so.1
    libdl.so.2
    libpthread.so.0
    libc.so.6
    /lib/ld-linux.so.2

How much difference will be there between version a and version a1 ? What will be working in different way inside application itself and int glibc ? Will linking of pthreads change something inside from thread-unsafe to thread-safe algorithm?

E.g.

$ strace ./a 2>&1 |wc -l
     73
$ strace ./a1 2>&1 |wc -l
    103

In a1 trace, two additional libs are loaded, some more mprotects are called, and added section of:

 set_tid_address; set_robust_list; rt_sigaction x 2; rt_sigprocmask; getrlimit; uname
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:06:42+00:00Added an answer on May 23, 2026 at 1:06 am

    glibc itself contains stub code for many pthread functions. These glibc pthread functions do nothing. However, when the program is linked with libpthread then those stubs are replaced with the real pthread locking functions.

    This is intended for use in libraries that need to be thread safe but do not use threads themselves. These libraries can use pthread locks, but those locks will not actually happen until a program or library that links to libpthread is loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather strange question: I have a Java application which uses applications
I have a question about how to deploy WPF application into a PC without
I have an application X which uses shared libraries A,B and C. Shared library
i have an application running on JBoss Seam 2, which uses rich faces as
I have a rather complex application at https://github.com/BigBadOwl/iStreamer-Download-Manager which uses Rtmpdump and Ffmpeg libraries
I have winforms application which uses nhibernate and active records to access the database.
I have an application which uses traditional Database for all of its data ,
My question is about thinking through Rails app. I have a rich ajax-application which
I have a client application (WPF, C#, .net4) which uses POCO entity model connected
I have a web application which uses LDAP for log in. I'm using Openid4Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.