09-29-2005
1. Not really - but read the getrusage man page for details
edit:
should have mentioned pthread_attr_getstacksize(), which gets memory allocated to the stack.
Last edited by jim mcnamara; 09-29-2005 at 01:21 PM..
10 More Discussions You Might Find Interesting
1. Programming
hi all,
can anyone tell me some good site for the mutithreading tutorials, its application, and some code examples.
-sushil (2 Replies)
Discussion started by: shushilmore
2 Replies
2. Programming
Is there anybody has documents about NPTL
I wanna study about it , but can't find the documents....
anyone help appreciate
:) :) :) (1 Reply)
Discussion started by: alan.zhao
1 Replies
3. Programming
pthread_create(&tid, &Attr, A, NULL);
pthread_create(&tid, &Attr, B, NULL);
pthread_create(&tid, &Attr, C, NULL);
A,B,C are the name of the functiont that the thread excute
Hi all !
I want to ask so with these commands ,how the program will excute .
What the way it will do .
Please... (0 Replies)
Discussion started by: iwbasts
0 Replies
4. Programming
Hi all!
I am implementing an http server in c++ using the posix thread, but i am having a memory leak and i cannot find the reason.
I have already commented out the section that initializes the threads and i found out, the problem is when i initialize/run the threads.
In the threads i have... (1 Reply)
Discussion started by: laurovalente
1 Replies
5. Programming
Hello,
I have created program that run threads one by one, maximum 100. Each thread will process one block of data, and once it`s finished, new thread is created with new block of data....etc
I have array of values to control status of each thread, like this:
array_thread_status=1... (11 Replies)
Discussion started by: orangem
11 Replies
6. Programming
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
Discussion started by: kmehta
4 Replies
7. UNIX for Advanced & Expert Users
i am creating threads in my program using the POSIX interface.
when the thread starts executing i run out of memory and get a core dump.
i have tried to increase the threads stack size using pthread_attr_setstacksize, but of no use since i guess the dynamic memory is allocated on the heap and... (1 Reply)
Discussion started by: aniketkadu2002
1 Replies
8. Programming
I can see a number of header files in the POSIX standard related to TCP/IP based socket programming:
arpa/inet.h
net/if.h
netdb.h
netinet/in.h
netinet/tcp.h
sys/socket.h
Except for socket.h, I am a little confused what's the purpose of so many header files and when to include which.... (3 Replies)
Discussion started by: jaywalker
3 Replies
9. Programming
in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario:
client:Knock Knock
server:who's there
client: Eric
Server:Eric,Welcome.
client:exit
all process terminated
... (1 Reply)
Discussion started by: ouou
1 Replies
10. Programming
I want to create a program that creates 2 child process, and each of them creates 2 threads, and each thread prints its thread id. I0ve allread done that the outuput isn't the outuput i want.
When a run the following comand "$./a.out | sort -u | wc -l" I have the folowing output
2
$:
It should... (3 Replies)
Discussion started by: pharaoh
3 Replies
LEARN ABOUT X11R4
pthread_attr_getstacksize
PTHREAD_ATTR_SETSTACKSIZE(3) Linux Programmer's Manual PTHREAD_ATTR_SETSTACKSIZE(3)
NAME
pthread_attr_setstacksize, pthread_attr_getstacksize - set/get stack size attribute in thread attributes object
SYNOPSIS
#include <pthread.h>
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
Compile and link with -pthread.
DESCRIPTION
The pthread_attr_setstacksize() function sets 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_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
On success, these functions return 0; on error, they return a nonzero error number.
ERRORS
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
These functions are provided by glibc since version 2.1.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+-----------------------------+---------------+---------+
|Interface | Attribute | Value |
+-----------------------------+---------------+---------+
|pthread_attr_setstacksize(), | Thread safety | MT-Safe |
|pthread_attr_getstacksize() | | |
+-----------------------------+---------------+---------+
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
NOTES
For details on the default stack size of new threads, see pthread_create(3).
A thread's stack size is fixed at the time of thread creation. Only the main thread can dynamically grow its stack.
The pthread_attr_setstack(3) function allows an application to set both the size and location of a caller-allocated stack that is to be
used by a thread.
BUGS
As at glibc 2.8, if the specified stacksize is not a multiple of STACK_ALIGN (16 bytes on most architectures), it may be rounded downward,
in violation of POSIX.1, which says that the allocated stack will be at least stacksize bytes.
EXAMPLE
See pthread_create(3).
SEE ALSO
getrlimit(2), pthread_attr_init(3), pthread_attr_setguardsize(3), pthread_attr_setstack(3), pthread_create(3), pthreads(7)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
Linux 2017-09-15 PTHREAD_ATTR_SETSTACKSIZE(3)