Want a C Function to get current thread's stack size

This is a discussion on Want a C Function to get current thread's stack size within the C Programming forums, part of the General Programming Boards category; Hi, I wanna know the currently running thread's stack size ?? Thankz in advance !!!...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    10

    Thumbs up Want a C Function to get current thread's stack size

    Hi,
    I wanna know the currently running thread's stack size ??

    Thankz in advance !!!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Well that's a fairly meaningless question without some idea of what OS / Compiler / thread library you're using.
    If that library doesn't tell you, then it's a tough ask.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    man getrlimit
    I don't know how on windows, but I imagine I can find the answer on google faster than you can respond to this.

    Damn, I failed you, you may now all mock me for my cockyness.
    Last edited by valis; 07-25-2006 at 04:07 PM.

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    10
    hi,
    I m really sorry,Sorry for inconvinience....
    Compiler is VC++6.0 ,OS using is Windows2000server.
    Actually I have been doin a program in sockets using Win32 API.
    Here I m running several threads so Is there any possibility to know the size of the currently running thread's memory size how much it's using.

    Thankz.

  5. #5
    Registered User
    Join Date
    Jul 2006
    Posts
    10
    HI,
    do u mean in google search?? yaeh, i tried but no result?? If u don't mind could u please send me the answer for this?


    Thankz,
    m.sudhakar

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Well to know how much you've got in total, read this
    http://msdn.microsoft.com/library/de...eatethread.asp

    This might help - you gotta spend more time reading MSDN, or at least skimming it so you know roughly what sort of things are available even if you don't remember the details.
    http://msdn.microsoft.com/library/de...eadcontext.asp

    There is also this hack.
    Code:
    char *stackBase;
    ptrdiff_t stackSize ( void ) {
      char dummy;         // on the stack, at end of current call chain
      return stackBase - &dummy;
    }
    
    DWORD WINAPI ThreadProc ( LPVOID lpParameter ) {
      char dummy;         // on the stack at the start
      stackBase = &dummy;
      // rest of thread code goes here, calling whatever functions it needs.
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jul 2006
    Posts
    10
    hi,
    SALEM !... Thanks a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. illegal function overloading????
    By Mr_Jack in forum C++ Programming
    Replies: 3
    Last Post: 12-17-2003, 12:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21