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

  • SEARCH
  • Home
  • 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 7553687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:07:40+00:00 2026-05-30T11:07:40+00:00

On Linux, for a C/C++ program using pthreads, is there a way to see

  • 0

On Linux, for a C/C++ program using pthreads, is there a way to see how threads were scheduled for the life of a process? I’d like to see which CPU(s) on which every thread runs. I’d like to see when threads were pre-empted (and why).

We have set up a test environment where two identical machines run identical processes. There is a third machine generating “clock” events to which the two machines listen (sent via multicast). The machines’ processes do some stuff at each clock, then send a result to the third machine. The idea is that the third machine eliminates the clock synchronization problem (between the two identical machines). Our expectation is that the results coming back should be at exactly (or almost exactly) the same time. And generally they are. The problem is, we see occasional spikes, where one result is dramatically delayed (by an order of 10x the standard deviation of all results).

We are looking at micro-second level optimization. In this arena, cache misses and thread wake-up times become an issue. It is known that the total number of threads across all processes is greater than the number of CPU cores.

I suspect that these spikes are caused by the occasional “perfect storm” of thread preemption, thread-CPU migration (and therefore cache miss). Within the various processes, there are actually only two or three “important” threads doing time-sensitive work. The rest are ancillary/support threads, of lower priority. In total, the number of important/time-sensitive threads is actually equal to (or less than) the number of cores.

I suspect that the solution to this is to carefully assign important threads to their own core(s), and dump all the support threads onto their own core. But this would require a fair amount of development effort, and I’d like to confirm my suspicions before heading down this road.

  • 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-30T11:07:42+00:00Added an answer on May 30, 2026 at 11:07 am

    strace – simple tool to trace process behavior, but seems can not check the core id.

    lttng – need patch the kernel, but more impressive, you can know exactly what each core is doing like context switch/interrupt handling.

    Update: As Mathieu Desnoyers mentioned, lttng can be used as Linux kernel modules since 2.6.36, no kernel patching needed now.

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

Sidebar

Related Questions

I am writing a program using threads in c++ in linux. Currently, I am
Working in Linux and using C++. I have a program which initiates a thread.
There is nothing in the way the program uses this data which will cause
I developed a command-line (non GUI) C program on Linux using QT Creator, which
I am porting a C# program to Linux (using Mono). The only compatibility issues
Question: Is it possible to compile a program on linux using a .dll file?
Newbie to C. I'm writing an ANSI C program (on Linux using gcc 4.4.6)
I'm using Linux Inotify to detect FS events on my program. How could I
I was working on a program in Netbeans on Linux using a gcc compiler
i am trying to write a program in java (on linux) using RandomAccessFile class

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.