Sponsored Content
Top Forums Programming Creating an array to hold posix thread ids: Only dynamic array works Post 302238622 by Roman Voznyuk on Sunday 21st of September 2008 08:13:45 AM
Old 09-21-2008
Where is this code called from?
I guess from some function.
In this case first example works fine becuase dynamically allocated threadids exists beyond this fucntion, but it second example it dies immediately.
Remember, pthread_create doesn't wait for actual start-up of new thread.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a dynamic array in ksh

Hi, Is it possible to create a dynamic array in shell script. I am trying to get the list of logfiles that created that day and put it in a dynamic array. I am not sure about it. help me New to scripting Gundu (3 Replies)
Discussion started by: gundu
3 Replies

2. UNIX for Advanced & Expert Users

MAX SIZE ARRAY Can Hold it

Hi, Do anyone know what's the max size of array (in awk) can be store before hit any memory issue. Regards (3 Replies)
Discussion started by: epall
3 Replies

3. Shell Programming and Scripting

Dynamic Array Issue

Could one of you, please, provide some input regarding my problem below and it is as follows: I have 2 files that I need to make sure are identical before processing: First, I sort both files Second, I do a diff file1 file2 > File 3 This provides me with the difference. Now, I need to... (6 Replies)
Discussion started by: ddedic
6 Replies

4. Shell Programming and Scripting

How to hold string array in shell scripts

Gents, Below is the Shell script which I am trying to hold a string of array that is passed from a java file. But it is not working . Can any one please help me to by fixing it. #!/bin/csh/ set copy = ($argv) echo $copy >> /home/users/bavananr/rrr.log echo $copy >>... (3 Replies)
Discussion started by: brajesh
3 Replies

5. Shell Programming and Scripting

creating a dynamic array

i want to create an array the array elements are populated depending upon the number of entries present in a data file The data file is created dynamically how to achieve the same thanks (1 Reply)
Discussion started by: trichyselva
1 Replies

6. Programming

array dynamic allocation

Hi, I have the following problem: i must allocate a dynamic array from a subroutine which should return such array to main function. The subroutine has already a return parameter so i thought of pass the array as I/O parameter. I tried the following program but it doesn't work (segmentation... (11 Replies)
Discussion started by: littleboyblu
11 Replies

7. Shell Programming and Scripting

dynamic index for array in while loop

Hi, I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies

8. Programming

readdir and dynamic array memory corruption

Hi everyone I am developing an utility. At some part of it I read directory entries to a dynamic array: struct list It stores pointers to items: list.entries, which are structures: struct entry If a number of files in a directory is greater then number of elements an array was initially... (11 Replies)
Discussion started by: torbium
11 Replies

9. Programming

Memory corruption in dynamic array of strings

I put together a C function to add strings to a dynamic array of strings (mostly for educational purpose to explain pointers to my kid). It works, but sometimes one or two strings in the array becomes corrupted. Running example on 64 bit Ubuntu, gcc ver. 4.8.4 Hope my code is self-explanatory: ... (2 Replies)
Discussion started by: migurus
2 Replies

10. Shell Programming and Scripting

Creating a pseudo-array in dash, (POSIX).

Arrays in dash, (POSIX). Hi gurus... I am thinking of trying AudioScope.sh in pure POSIX so... I need an array in dash, I know it is not possible but pseudo-arrays are. I have two versions that work, the second is an idea from the WWW. The first is what I would like to use. There are... (8 Replies)
Discussion started by: wisecracker
8 Replies
PTHREAD_JOIN(3) 					     Library Functions Manual						   PTHREAD_JOIN(3)

NAME
pthread_join - wait for termination of another thread SYNOPSIS
#include <pthread.h> int pthread_join(pthread_t th, void **thread_return); DESCRIPTION
pthread_join suspends the execution of the calling thread until the thread identified by th terminates, either by calling pthread_exit(3) or by being cancelled. If thread_return is not NULL, the return value of th is stored in the location pointed to by thread_return. The return value of th is either the argument it gave to pthread_exit(3), or PTHREAD_CANCELED if th was cancelled. The joined thread th must be in the joinable state: it must not have been detached using pthread_detach(3) or the PTHREAD_CREATE_DETACHED attribute to pthread_create(3). When a joinable thread terminates, its memory resources (thread descriptor and stack) are not deallocated until another thread performs pthread_join on it. Therefore, pthread_join must be called once for each joinable thread created to avoid memory leaks. At most one thread can wait for the termination of a given thread. Calling pthread_join on a thread th on which another thread is already waiting for termination returns an error. CANCELLATION
pthread_join is a cancellation point. If a thread is canceled while suspended in pthread_join, the thread execution resumes immediately and the cancellation is executed without waiting for the th thread to terminate. If cancellation occurs during pthread_join, the th thread remains not joined. RETURN VALUE
On success, the return value of th is stored in the location pointed to by thread_return, and 0 is returned. On error, a non-zero error code is returned. ERRORS
ESRCH No thread could be found corresponding to that specified by th. EINVAL The th thread has been detached. EINVAL Another thread is already waiting on termination of th. EDEADLK The th argument refers to the calling thread. AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr> SEE ALSO
pthread_exit(3), pthread_detach(3), pthread_create(3), pthread_attr_setdetachstate(3), pthread_cleanup_push(3), pthread_key_create(3). LinuxThreads PTHREAD_JOIN(3)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy