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

The Archive Base Latest Questions

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

For some reason, I create my own stacks for all the threads in my

  • 0

For some reason, I create my own stacks for all the threads in my application by using pthread_attr_setstack function before calling pthread_create. However, I also want to have a custom stack for my main thread. How can I achieve that?

If that is not possible, how can I at least get the stack address and size of the main thread?

  • 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-26T13:01:40+00:00Added an answer on May 26, 2026 at 1:01 pm

    However, I also want to have a custom stack for my main thread.

    You can’t. Stack for main thread is created by OS elf loader. The size of main stack is not fixed statically (only upper limit does, via ulimit -s). OS will grow the stack each time when it is needed.

    How can I achieve that?

    You can only switch a stack by resetting %sp,%bp registers. You should do this very carefully and it will be better to reset them back before exiting.

    If that is not possible, how can I at least get the stack address

    You can estimate stack address by:

    int main()
    {
      int a;
      printf("Stackaddress is near %p\n", &a);
    }
    

    And you can read /proc/pid/maps file of your application and check the address range marked [stack]

    and size of the main thread?

    Size of the main stack is not fixed. This stack is almost empty (contains argv/envp/auxp – filled by OS) when program starts; and it will grow (not shrink) at every access to yet unused stack page. This is a special case of page fault, OS will detect that page fault looks like stack access and will give more physical pages into virtual address space of application.

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

Sidebar

Related Questions

I am using mysqli_stmt_bind_param() to create an INSERT statement. For some reason I am
For some reason when I create a new namespace in Visual Studio 2008 its
I'm working on a new project and for some reason decided to create two
For some reason, this MySQL fails: CREATE SCHEMA IF NOT EXISTS `partB` DEFAULT CHARACTER
For some reason, my visual studio 2008 installation doesn't have the Create Test Project
I am trying to create an ordered list on IE7 but for some reason
I've created a flex-based application and uploaded it to vkontakte . For some reason
If anyone using WingIDE for their python dev needs: For some reason I get
I'm attempting to create my own templates for the search pages using drupal 6.
I'm currently trying to do a time ago function but for some reason, it

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.