Dealing with too small thread stacks
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).
As we cannot detect if the user set a stack address in pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).
It seems to me we can detect the parameters in the pthread_attr_t using pthread_attr_getstack. So, we can get __wrap_pthread_create to fail if the size is not sufficient.
Signature · 1 line
Gilles.
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).
Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.
Nope, unfortunately not:
"If the pthread_attr_getstack() function is called before the stackaddr attribute has been set, the behavior is unspecified."
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).
Quoted 8 lines
Quoted 3 lines
It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
Signature · 1 line
Gilles.
Quoted 23 lines · Gilles Chanteperdrix
Quoted 22 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
Quoted 7 lines
Quoted 2 lines
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Gilles Chanteperdrix
Quoted 24 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."
Quoted 8 lines
Quoted 4 lines
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of pthread_attr_setstack() on pthread_attr_getstacksize(), maybe more luck there?
Signature · 1 line
Gilles.
Quoted 33 lines · Gilles Chanteperdrix
Quoted 32 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).Quoted 8 lines
Quoted 3 lines
It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
Quoted 6 lines
Quoted 3 lines
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?
setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 8 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).
Another aspect in this: I just realized that the glibc tends to ignore our "+ getpagesize()" in the stack calculation. That's at least true for the x86-64 systems with glibc 2.19 on which I tested.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 38 lines · Jan Kiszka
Quoted 37 lines · Gilles Chanteperdrix
Quoted 35 lines · Jan Kiszka
Quoted 23 lines · Gilles Chanteperdrix
Quoted 22 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
Quoted 7 lines
Quoted 2 lines
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Quoted 7 lines
Quoted 2 lines
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Signature · 1 line
Gilles.
Quoted 42 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 39 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Gilles Chanteperdrix
Quoted 24 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."Quoted 8 lines
Quoted 4 lines
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?
Quoted 7 lines
Quoted 4 lines
setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Sure, that would be the best way.
Along that, I would recommend raising the minimum to 2*PTHREAD_STACK_MIN.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 48 lines · Jan Kiszka
Quoted 47 lines · Gilles Chanteperdrix
Quoted 45 lines · Jan Kiszka
Quoted 33 lines · Gilles Chanteperdrix
Quoted 32 lines · Jan Kiszka
Quoted 30 lines · Gilles Chanteperdrix
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Gilles Chanteperdrix
Quoted 13 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).Quoted 8 lines
Quoted 3 lines
It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
Quoted 6 lines
Quoted 3 lines
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Quoted 6 lines
Quoted 2 lines
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Sure, that would be the best way.
Along that, I would recommend raising the minimum to 2*PTHREAD_STACK_MIN.
What for ? We know that the system crashes if the stack is too small, but that is the consequence of the user choice, there is not much we can do about it. What I would concentrate on, and I think we had that on xenomai 2.x is to have a reasonable default stack size. Actually, we could wrap pthread_attr_init to define our own default and be done with it.
Signature · 1 line
Gilles.
Quoted 54 lines · Gilles Chanteperdrix
Quoted 53 lines · Jan Kiszka
Quoted 42 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 39 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Gilles Chanteperdrix
Quoted 24 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."Quoted 8 lines
Quoted 4 lines
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?Quoted 7 lines
Quoted 4 lines
setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Sure, that would be the best way.
Quoted 9 lines
Quoted 1 line
Along that, I would recommend raising the minimum to 2*PTHREAD_STACK_MIN.
What for ? We know that the system crashes if the stack is too small, but that is the consequence of the user choice, there is not much we can do about it. What I would concentrate on, and I think we had that on xenomai 2.x is to have a reasonable default stack size. Actually, we could wrap
pthread_attr_initto define our own default and be done with it.
The current minimum PTHREAD_STACK_MIN + PAGE doesn't work reliably (see my other posting). Thus we can either give up on checking the minimum completely (much simpler) or raise it to a value that has at least an effect.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 65 lines · Jan Kiszka
Quoted 54 lines · Gilles Chanteperdrix
Quoted 53 lines · Jan Kiszka
Quoted 42 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 39 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Gilles Chanteperdrix
Quoted 24 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."Quoted 8 lines
Quoted 4 lines
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?Quoted 7 lines
Quoted 4 lines
setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Sure, that would be the best way.
Quoted 9 lines
Quoted 1 line
Along that, I would recommend raising the minimum to 2*PTHREAD_STACK_MIN.
What for ? We know that the system crashes if the stack is too small, but that is the consequence of the user choice, there is not much we can do about it. What I would concentrate on, and I think we had that on xenomai 2.x is to have a reasonable default stack size. Actually, we could wrap
pthread_attr_initto define our own default and be done with it.
Quoted 4 lines
The current minimum
PTHREAD_STACK_MIN+ PAGE doesn't work reliably (see my other posting). Thus we can either give up on checking the minimum completely (much simpler) or raise it to a value that has at least an effect.
Again, trying to enforce a minimum looks like a bad idea to me. I would rather have pthread_attr_init set a default value. And larger than PTHREAD_STACK_MIN + pagesize (but much smaller than the default 2MiB). I believe POSIX does not define what value is set by pthread_attr_init, so we can do what we want.
Signature · 1 line
Gilles.
Quoted 65 lines · Jan Kiszka
Quoted 54 lines · Gilles Chanteperdrix
Quoted 53 lines · Jan Kiszka
Quoted 42 lines · Gilles Chanteperdrix
Quoted 41 lines · Jan Kiszka
Quoted 39 lines · Gilles Chanteperdrix
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Gilles Chanteperdrix
Quoted 24 lines · Jan Kiszka
Quoted 10 lines · Gilles Chanteperdrix
Quoted 9 lines · Jan Kiszka
Hi,
analyzing page faults of an application that prefers to set its own stacks, I noticed a problem in Xenomai (2 and 3), at least from the usability POV: We document the minimum stack stack as
PTHREAD_STACK_MIN
+ 1 page, at least in Xenomai 3, and we enforce that on thread creation. However, enforcement is doomed to fail if the stack is preallocated (and that too small).Quoted 8 lines
Quoted 4 lines
As we cannot detect if the user set a stack address in
pthread_attr_t, I would suggest to fail thread creation instead of performing it with improper parameters. Other suggestions? If not, I would prepare a patch for Xenomai 3 (for 2 only if desired).It seems to me we can detect the parameters in the
pthread_attr_tusingpthread_attr_getstack. So, we can get__wrap_pthread_createto fail if the size is not sufficient.Nope, unfortunately not:
"If the
pthread_attr_getstack()function is called before the stackaddr attribute has been set, the behavior is unspecified."Quoted 8 lines
Quoted 4 lines
It is unspecified by POSIX, but Xenomai supports only two implementations, glibc and uClibc, so, we can look at what these two libraries do. I would bet they return you a NULL stack pointer or something.
I would have expected that, too, but the results for glibc seem random. Plus there is the risk that something changes, thus we become version-dependent.
Ok then, what about the influence of
pthread_attr_setstack()onpthread_attr_getstacksize(), maybe more luck there?Quoted 7 lines
Quoted 4 lines
setstack defines the size getstacksize returns. So does setstacksize.
What happens during setstacksize is apparently that the address is set to NULL - size. But, again, that is just the current glibc behaviour.
Yes, ok, but in order to test the stack size passed by the user, it simply means we can use getstacksize and bail out if not sufficient.
Sure, that would be the best way.
Quoted 9 lines
Quoted 1 line
Along that, I would recommend raising the minimum to 2*PTHREAD_STACK_MIN.
What for ? We know that the system crashes if the stack is too small, but that is the consequence of the user choice, there is not much we can do about it. What I would concentrate on, and I think we had that on xenomai 2.x is to have a reasonable default stack size. Actually, we could wrap
pthread_attr_initto define our own default and be done with it.
Quoted 4 lines
The current minimum
PTHREAD_STACK_MIN+ PAGE doesn't work reliably (see my other posting). Thus we can either give up on checking the minimum completely (much simpler) or raise it to a value that has at least an effect.
As in xenomai 2.x, I would suggest the maximum of __WORDSIZE * 1024 and PTHREAD_STACK_MIN as a default stack size.
I think the idea of adding pagesize to PTHREAD_STACK_MIN comes from the implementation of signals which were pulling siginfo structs from kernel after each syscall. Since this thing is long gone (even in xenomai 2.6 I believe), we have no reason to try and enforce another minimum than POSIX.
Signature · 1 line
Gilles.