Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Not Lazy stack option for threads: (12 Items)
   
Not Lazy stack option for threads  
Hi,
We are trying to set the NOTLAZY Stack option for all threads. After doing this when we do "pidin mem", i see some 
threads showing 128K(132K) and some threads still show 4096(132K). I was hoping all threads should show all stack space 
assigned as 128K. Also what does 128K(132K) mean ?
 
Please let me know.
 
Regards,
Manas
RE: Not Lazy stack option for threads  
> Also what does 128K(132K) mean

That looks like a fully allocated stack - there's a guard page at the bottom of the stack to detect overflow. The guard 
page never has any physical memory associated with it, so that explains the 4K difference between the physical (128K) 
and virtual (132K) memory that' s been allocated.

Why are you trying to use NOTLAZY?

-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-05-13 3:17 AM
To: general-community
Subject: Not Lazy stack option for threads

Hi,
We are trying to set the NOTLAZY Stack option for all threads. After doing this when we do "pidin mem", i see some 
threads showing 128K(132K) and some threads still show 4096(132K). I was hoping all threads should show all stack space 
assigned as 128K. Also what does 128K(132K) mean ?
 
Please let me know.
 
Regards,
Manas




_______________________________________________

General
http://community.qnx.com/sf/go/post106534
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com
Re: RE: Not Lazy stack option for threads  
Thanks. We need to allocate stack for threads upfront for safety requirement. I am using pthread_attr_setstacklazy() 
with PTHREAD_STACK_NOTLAZY option to set the not lazy stack on other threads from Main thread. 

How can we set the NOT LAZY stack option on the main thread ?

Regards,
Manas
RE: RE: Not Lazy stack option for threads  
Do you need the full 128K of stack? I would think that you could get by with a lot less space.

The -S command line option of the ldrel utility (accessible through the qcc -N option I believe) can set the size of the
 main thread stack and make it non-lazy.

Alternatively, you could just call a function at the beginning of main() that does:

    void grow_my_stack(void)) {
         char array[HOW_MUCH_DO_I_NEED];
         memset(array, 0, sizeof(array));
    }

-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-08-13 5:34 AM
To: general-community
Subject: Re: RE: Not Lazy stack option for threads

Thanks. We need to allocate stack for threads upfront for safety requirement. I am using pthread_attr_setstacklazy() 
with PTHREAD_STACK_NOTLAZY option to set the not lazy stack on other threads from Main thread. 

How can we set the NOT LAZY stack option on the main thread ?

Regards,
Manas



_______________________________________________

General
http://community.qnx.com/sf/go/post106616
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com
Re: RE: RE: Not Lazy stack option for threads  
Thanks Brian.

Still I am not getting how to set the main thread stack to 128 KB by using grow_my_stack() as you mentioned. Can you 
please give a small sample code to do the same ?

Thanks,
Manas
RE: RE: RE: Not Lazy stack option for threads  
int main(void) {
   grow_my_stack();
   ...rest of the code...
}

// put this function in a different source file from main() so compiler doesn't
// inline it.
void grow_my_stack() {
     char dummy[50*1024]; // choose appropriate size of array

    // use memset_s() rather than memset() so compiler
    // doesn't optimize it away
     memset_s(dummy, 0, sizeof(dummy));
}

-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-11-13 10:52 PM
To: general-community
Subject: Re: RE: RE: Not Lazy stack option for threads

Thanks Brian.

Still I am not getting how to set the main thread stack to 128 KB by using grow_my_stack() as you mentioned. Can you 
please give a small sample code to do the same ?

Thanks,
Manas



_______________________________________________

General
http://community.qnx.com/sf/go/post106679
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com
Re: RE: RE: RE: Not Lazy stack option for threads  
Thanks Brian. I did the steps as you mentioned, I tried to make the stack to 100KB. The below output came for pidin mem.


    pid     tid name                       prio STATE            code  data        stack
  589851   1 usr/bin/appmgr      13r REPLY            136K 1228K  104K(516K)*
  589851   2 usr/bin/appmgr      13r RECEIVE          136K 1228K  128K(132K)
  589851   2 usr/bin/appmgr      13r RECEIVE          136K 1228K  128K(132K)

I have one doubt here. For the 1st thread which is main(), the stack shows 104K(516K). 

104K is OK but why does it shows (516K) ?

Please let me know. Thanks Manas
RE: RE: RE: RE: Not Lazy stack option for threads  
That's the amount of virtual address space allocated to the stack.

-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-12-13 8:06 AM
To: general-community
Subject: Re: RE: RE: RE: Not Lazy stack option for threads

Thanks Brian. I did the steps as you mentioned, I tried to make the stack to 100KB. The below output came for pidin mem.


    pid     tid name                       prio STATE            code  data        stack
  589851   1 usr/bin/appmgr      13r REPLY            136K 1228K  104K(516K)*
  589851   2 usr/bin/appmgr      13r RECEIVE          136K 1228K  128K(132K)
  589851   2 usr/bin/appmgr      13r RECEIVE          136K 1228K  128K(132K)

I have one doubt here. For the 1st thread which is main(), the stack shows 104K(516K). 

104K is OK but why does it shows (516K) ?

Please let me know. Thanks Manas



_______________________________________________

General
http://community.qnx.com/sf/go/post106686
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com
Re: RE: RE: RE: RE: Not Lazy stack option for threads  
Thanks Brian for your support.

Can I do the same thing as grow_my_stack(), with any system calls/ QNX calls in main(). Like pthread_attr_setstacklazy.

Thanks,
Manas
RE: RE: RE: RE: RE: Not Lazy stack option for threads  
I'm not sure I follow what you're asking. Grow_my_stack() works by touching all the stack pages you want to use up front
, while the program is initializing. I don't see how something like pthread_attr_setstacklazy()  comes in to it.


-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-12-13 10:32 PM
To: general-community
Subject: Re: RE: RE: RE: RE: Not Lazy stack option for threads

Thanks Brian for your support.

Can I do the same thing as grow_my_stack(), with any system calls/ QNX calls in main(). Like pthread_attr_setstacklazy.

Thanks,
Manas



_______________________________________________

General
http://community.qnx.com/sf/go/post106727
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com
Re: RE: RE: RE: RE: RE: Not Lazy stack option for threads  
Sorry I confused you.

Is there a QNX function which is similar to Grow_my_stack() function ? so that i can use that instead of my own function
 grow_my_stack().

Regards,
Manas
RE: RE: RE: RE: RE: RE: Not Lazy stack option for threads  
Nope.

-----Original Message-----
From: manas sahoo [mailto:community-noreply@qnx.com] 
Sent: November-13-13 10:41 PM
To: general-community
Subject: Re: RE: RE: RE: RE: RE: Not Lazy stack option for threads

Sorry I confused you.

Is there a QNX function which is similar to Grow_my_stack() function ? so that i can use that instead of my own function
 grow_my_stack().

Regards,
Manas




_______________________________________________

General
http://community.qnx.com/sf/go/post106769
To cancel your subscription to this discussion, please e-mail general-community-unsubscribe@community.qnx.com