Home > pthread attr getstacksize example > pthread_attr_setstacksize error

Pthread_attr_setstacksize Error


ManualREAD_ATTR_SETSTACKSIZE(3) NAME top pthread_attr_setstacksize, pthread_attr_setstacksize example pthread_attr_getstacksize - set/get stack size attribute in thread attributes pthread_stack_min object SYNOPSIS top #include int pthread_attr_setstacksize(pthread_attr_t *attr, size_t pthread_attr_getstacksize stacksize); int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize); Compile and link with -pthread. DESCRIPTION top The pthread_attr_setstacksize() function sets

Pthread_attr_getstacksize Example

the stack size attribute of the thread attributes object referred to by attr to the value specified in stacksize. The stack size attribute determines the minimum size (in bytes) that will be allocated for threads created using the thread attributes object attr. The pthread_stack_min value pthread_attr_getstacksize() function returns the stack size attribute of the thread attributes object referred to by attr in the buffer pointed to by stacksize. RETURN VALUE top On success, these functions return 0; on error, they return a nonzero error number. ERRORS top pthread_attr_setstacksize() can fail with the following error: EINVAL The stack size is less than PTHREAD_STACK_MIN (16384) bytes. On some systems, pthread_attr_setstacksize() can fail with the error EINVAL if stacksize is not a multiple of the system page size. VERSIONS top These functions are provided by glibc since version 2.1. ATTRIBUTES top For an explanation of the terms used in this section, see attributes(7). ┌─────────────────────────────┬───────────────┬─────────┐ │Interface │ Attribute │ Value │ ├─────────────────────────────┼───────────────┼─────

*attr, size_t stacksize); int pthread_attr_getstacksize(const pthread_attr_setstacksize invalid argument pthread_attr_t *attr, size_t *stacksize); DESCRIPTION The

Pthread_attr_getstacksize Example Code

functions pthread_attr_setstacksize() and pthread_attr_getstacksize(), respectively, set and get the thread

Pthread Get Stack Size

creation stacksize attribute in the attr object. The stacksize attribute defines the minimum stack size (in http://man7.org/linux/man-pages/man3/pthread_attr_setstacksize.3.html bytes) allocated for the created threads stack. RETURN VALUE Upon successful completion, pthread_attr_setstacksize() and pthread_attr_getstacksize() return a value of 0. Otherwise, an error number is returned to indicate the error. The pthread_attr_getstacksize() http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_attr_setstacksize.html function stores the stacksize attribute value in stacksize if successful. ERRORS The pthread_attr_setstacksize() function will fail if: [EINVAL] The value of stacksize is less than PTHREAD_STACK_MIN or exceeds a system-imposed limit. These functions will not return an error code of [EINTR]. EXAMPLES None. APPLICATION USAGE None. FUTURE DIRECTIONS None. SEE ALSO pthread_attr_init(), pthread_attr_setstackaddr(), pthread_attr_setdetachstate(), pthread_create(), , . DERIVATION Derived from the POSIX Threads Extension (1003.1c-1995) UNIX is a registered Trademark of The Open Group. Copyright © 1997 The Open Group [ Main Index | XSH | XCU | XBD | XCURSES | XNS ]

Today's Posts Advanced Search Find the answer to your Linux question: Entire Site Articles Downloads Forums Linux Hosting Forum GNU Linux Zone Programming / Scripting Thread stack size failure If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. ** If you are logged in, most ads will not be displayed. ** Linuxforums now supports the Tapatalk app for your mobile device. Results 1 to 2 of 2 Thread: Thread stack size failure Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Enjoy an ad free experience by logging in. Not a member yet? Register. 03-27-2006 #1 jdhedden View Profile View Forum Posts View Articles Just Joined! Join Date Mar 2006 Posts 1 Thread stack size failure I am working with the Perl's threads module, adding a new API for controlling thread stack size. I have received a couple of failure reports with the following error message: Thread creation failed: pthread_attr_setstacksize(2097152) returned 22 (Note: This is descriptive - the actual function call is below). This shows that the pthread_attr_setstacksize function was called with the stack size of 2MB (exactly), and that the function returned EINVAL. If you get the source code for the pthread_attr_setstacksize function, you find that the only cause for this error code is too small of a stack size: /* Catch invalid sizes. */ if (stacksize < PTHREAD_STACK_MIN) return EINVAL; Usually that minimum is 16K, however, the threads module code checks against whatever PTHREAD_STACK_MIN is set to, so 2MB should be valid. Within the threads module code, stack size is carried as an IV (64-bit int): typedef struct ithread_s { ... IV stack_size; } ithread; IV stack_size; And the call to pthread_attr_setstacksize casts it to size_t: # ifdef _POSIX_THREAD_ATTR_STACKSIZE /* Set thread's stack size */ if (thread->stack_size > 0) { rc_stack_size = pthread_attr_setstacks


Related content

pthread_attr_setstacksize error code 22

Pthread attr setstacksize Error Code table id toc tbody tr td div id toctitle Contents div ul li a href Pthread attr getstacksize a li li a href Pthread stack min a li li a href Pthread attr getstacksize Example a li ul td tr tbody table p p p Resolved bugs Rejected bugs Report a new bug This queue relatedl is for tickets about the threads CPAN pthread get stack size distribution Report information The Basics Id Status resolved Priority pthread attr getstacksize example code Queue threads People Owner Nobody in particular Requestors jdhedden cpan org Cc AdminCc Bug