when can we destory thread attributes using pthread_attr_destroy() for detached thrd


 
Thread Tools Search this Thread
Top Forums Programming when can we destory thread attributes using pthread_attr_destroy() for detached thrd
# 1  
Old 03-31-2009
when can we destory thread attributes using pthread_attr_destroy() for detached thrd

Hi All,
I am creating detached threads using pthread_create(). As we know, we need to pass the thread attribute structure as an argument to the pthread_Create() API.
I want to know what is the good time to destroy this thread attributes using pthread_attr_destroy() call. Also, I want to know whether we need to call the API pthread_attr_init(&attr_thread) and pthread_attr_setdetachstate(&attr_thread, PTHREAD_CREATE_DETACHED) every time we are creating a detached thread using pthread_create(&threadId, &attr_thread, (void *)ssp_handleAsynchSoipData, NULL).
Presently in my case I am creating and destroying the attribute structure immediately after the call to pthread_create(). But I am susspecting if this is the cause of the crash I am getting in my program.
Has anybody come across such problem. Please suggest
Thanks
# 2  
Old 03-31-2009
pthread_attr_destroy() destroys the thread attributes object, reclaiming its storage space. Accorded to POSIX.1-2008 the results of otherwise referencing the object after it has been destroyed are undefined.

On some implementations it has no effect on the threads previously created with that object. Therefore destroying the threads attribute object immediately after the call to pthread_create() does not cause a crash. Depends on your particular implementation.
# 3  
Old 04-03-2009
OK. One more wuestion. What is the affect if I use just "return", intead of pthread_exit() in my thread function body.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Boot Solaris 10 from detached root mirrors

I recently ran some patching on a Solaris 10 server and as per normal procedure I detached the LVM root disk mirrors first to preserve the pre-patching copy of the OS. During the patching, I ran into some issues which I managed to resolve and completed the patching. However, I was looking around... (5 Replies)
Discussion started by: Grippo
5 Replies

2. UNIX for Dummies Questions & Answers

Run a detached process

Hey guys, Just wondering is there anyway that I would be able to run a detached process that would continue to run regardless of me being logged into the linux host? (4 Replies)
Discussion started by: killaram
4 Replies

3. Programming

detached thread is causing program crash

Hi All, I have scenario where my callback function data_update() can be called anytime. I have written the function data_update() such that it will create detached thread for processing the data sent to this function. data_update() { pthread_attr_t attr_thread; ... (1 Reply)
Discussion started by: wonderman
1 Replies

4. HP-UX

How do i cleanup the removed/detached devices ???

Hi, Am new to HPUX . I need your assistance.. I had attached a Clariion(storage) LUN into HPUX machine, devices with 2GB(c8t0d0) and 1GB(c8t0d1) space. Later some point of time, detached these devices from HPUX machine and executed 'insf' command to build the new devices directory special... (4 Replies)
Discussion started by: raghu265
4 Replies

5. Programming

POSIX - Hot to check if detached thread is still active

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

Can SIGTERM to main process kill the detached threads?

Hi, I am stuck up with a strange problem. I am writing an application - a kinda tracker that reads data from memcache and invokes theads to process each record of the memcache. I dont want to join all my threads because my tracker should poll the cache in regular intervals say sum 300... (2 Replies)
Discussion started by: deepti_v25
2 Replies

7. Solaris

Solaris DiskSuite, boot from detached disk

Hi, I am running Solaris 8 on Sun server with 2 hard drives. I have configured mirroring on the system using DiskSuite tool in order to have the same data on both disks. Now I want to perform some software upgrade and I would like to use the second disk as a backup disk. This means taking this... (3 Replies)
Discussion started by: carlossg
3 Replies
Login or Register to Ask a Question