- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- free posix thread resources
Operating System - Linux
1754333
Members
3096
Online
108813
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2007 02:09 AM
08-22-2007 02:09 AM
Hello:
I am tring to free thre resources generated by treads but i can´t.
The programa i have made is very simple. Ii generates many threads that wait a certain amount of time and then finish.
What i do not understand is why when they finish thre resources are not free.
Is it posible that the SO frees them later. ?
Do you think this is the normal behavior of the SO ? I have seen many threads tutorials,manual examples and i do not see anything diferent of what i have in the code.
Do you think my code is wrong ?
#include
#include
void *HiloPrueba(void *);
pthread_t hilo_escucha;
void *res_exit;
int main(int argc, char *argv[])
{
printf("\nMirar consumos");
fflush(stdout);
sleep(20);
for (int i=1;i<=100;i++)
{
pthread_create(&hilo_escucha, NULL, HiloPrueba,NULL);
fflush(stdout);
}
printf("Todos los hilos creados\n");
printf("30 segs para mirar consumo\n");
sleep(100);
fflush(stdout);
}
void *HiloPrueba(void *arg)
{
printf("Hilo creado\n");
pthread_detach(pthread_self());
sleep(30);
printf("\nSe acabo el tiempo");
fflush(stdout);
pthread_cleanup_push();
pthread_exit(NULL);
}
I am wathing the values of memory this process is using with glance plus.
Thanks in advance.
Solved! Go to Solution.
- Tags:
- pthread
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2007 04:33 AM
08-22-2007 04:33 AM
Solution
>I am trying to free the resources generated by threads but i can't.
The resources are freed in order for your process to use them again. Of course your kernel thread has been removed. But all of the memory has been put back into the pool only for that process.
>Is it possible that the SO frees them later?
>Do you think this is the normal behavior of the OS?
If by SO you mean OS, yes. Yes, normal.
>Do you think my code is wrong?
No, only your expectations. :-)
>I am watching the values of memory this process is using with glance plus.
Are you looking at memory segments?
Since each thread stack is mmapped, that can be freed. But libpthread maintains a pool of thread stacks for the next pthread_create. I wouldn't think it would have 100 but it may have all, since you created them all with the default stacksize.
The resources are freed in order for your process to use them again. Of course your kernel thread has been removed. But all of the memory has been put back into the pool only for that process.
>Is it possible that the SO frees them later?
>Do you think this is the normal behavior of the OS?
If by SO you mean OS, yes. Yes, normal.
>Do you think my code is wrong?
No, only your expectations. :-)
>I am watching the values of memory this process is using with glance plus.
Are you looking at memory segments?
Since each thread stack is mmapped, that can be freed. But libpthread maintains a pool of thread stacks for the next pthread_create. I wouldn't think it would have 100 but it may have all, since you created them all with the default stacksize.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2007 09:47 PM
08-27-2007 09:47 PM
Re: free posix thread resources
Thanks.
I have asked HP and they told me the way is working is fine. It is doing what is supposed to.
Regards
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP