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 6750177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:46:39+00:00 2026-05-26T12:46:39+00:00

In Win32, you can create a thread in suspended mode, by using the dwCreationFlags

  • 0

In Win32, you can create a thread in suspended mode, by using the dwCreationFlags parameter with CREATE_SUSPENDED. I am looking for a similar functionality with pthreads. Note that I don’t want to suspend the thread after running it and then pausing it by using condition variables, but actually create it in suspended mode and then start it later on.

The advantage of using this approach is that I can assign some properties to that thread before running it. For example, bind it to a certain core before starting, which is more efficient than first starting and then assigning it to a core, as it might get moved from one core to another.

If not possible, can we at least bind a thread to a core when calling pthread_create?

  • 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-26T12:46:40+00:00Added an answer on May 26, 2026 at 12:46 pm

    If you want to bind a thread to a CPU right from the start, you can use the form of pthread_create with a pthread_attr_t argument. Linux suports a special attribute pthread_attr_setaffinity_np, which allows the binding of a thread to a certain CPU set. Do not confuse this with pthread_setaffinity_np which requires an already running thread.

    The plan of action is this:

    // create generic attribute set
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    
    // enhance with CPU set
    pthread_attr_setaffinity_np(&attr, ...cpuset-args);
    
    // create thread with right attributes including CPU set
    pthread_t thread;
    pthread_create(&thread, &attr, ...);
    
    // viola, thread runns on given CPU-set, cleanup
    pthread_attr_destroy(&attr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I determine if a Win32 thread has terminated? The documentation for GetExitCodeThread
When I create a project in vs2005. I can also create Win32->Win32Project. I can
Can C# .net be used to create a win32 dll. If possible can someone
Is there a way to create a thread in Qt without using subclassing (ie.
I'm using win32. I wanna create a hidden and undeletable file using CreateFile() if
Possible Duplicate: How do I create a native application using Visual C++ 2008? Can
Using the Win32 APIs, is it possible to create a Window or Dialog in
there'are these lines in the sample Win32 app created default by VS. Can you
What win32 calls can be used to detect key press events globally (not just
How can a Win32 application respond to only the first WM_KEYDOWN notification? The MSDN

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.