Sponsored Content
Top Forums Programming Creating an array to hold posix thread ids: Only dynamic array works Post 302238734 by Roman Voznyuk on Sunday 21st of September 2008 08:21:46 PM
Old 09-21-2008
Quote:
Originally Posted by kmehta
So, shouldnt I face a problem when I place the code directly in the main() function ??
It depends on operating system. In case of Solaris your new thread might not even start before your application ends up.
The basic idea is that pointer your pass to pthread_create must eixsts at the moment you thread starts-up. And if you plan to use this data in this thread (otherwise why do you pass it?) you must guarantee that this data is not being destroyed while your thread is running. Usually people use prthread_join for this purpose.
 

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_scope_options(5)					File Formats Manual					  pthread_scope_options(5)

NAME
pthread_scope_options - list of external options to specify the scheduling contention scope of threads DESCRIPTION
From HP-UX release 11i version 2 and forward, HP-UX supports the "MxN" thread model. With MxN model, application has the flexibility of selecting the type of thread (determined by the contention scope specified) in the application. Based on the contention scope, there are two types of threads, threads and threads. can be used to initialize the attribute object. Subsequently, can be used to set the scope explicitly. If is not used, the default con- tention scope is considered. The default contention scope will be Some external options are provided to control the contention scope without modifying the application source. This is useful for the appli- cation developer to check the performance of the application with multiple thread models before deciding on the thread model appropriate for a particular application. The external scope options can be specified in three different ways: 1. At compile time. 2. In Properties file. 3. Environment variables. 1. Compile Time Options The options provided at compile time are: Forces the system scope irrespective of scope specified in the attribute for thread creation. Forces the process scope irrespective of scope specified in the attribute for thread creation. If contention scope is set by that scope is considered while creating a thread. Otherwise, is considered. The compile time option can be specified with or by defining the same before including in application source files. If none of the above mentioned options is specified, system scope threads will be created unless specifies otherwise. compile option is similar to and is provided for backward compatibility. However, if any of the above mentioned new compile options are used, will not have any effect. 2. Properties File Options Users are given the flexibility to use a properties file to specify various tunables for the library, to help in optimizing their applica- tions without making any source code changes. The default path name of the properties file is Note that this file will have to be explic- itly created by the user. If the application wants the pthread library to read the tunables from the properties file, the environment variable has to be set to 1, on, or ON. The user, through the environment variable can specify a different location for the properties file. In the properties file, lines beginning with are comments. For non-comment lines, the first and second words are extracted. The first word is expected to be the name of one of the tunables, and the second word is expected to be the value of that variable. The properties file supports following tunables to control the scope of threads externally: Forces the system scope irrespective of scope specified in the attribute for thread creation. Forces the process scope irrespective of scope specified in the attribute for thread creation. If contention scope is set by that scope is considered while creating a thread. Otherwise, is considered. If contention scope is set by that scope is considered while creating a thread. Otherwise, is considered. The properties file options and supported on HP-UX 11i v2 will be provided for backward compatibility. However, if any of the above men- tioned new properties file options are used, and will not have any effect. 3. Environmental Variables There are a set of environment variables which when set can override the scope of the threads specified in the application. These environ- ment variables should be set before starting the application to run. The environmental variables supported for controlling the scope are: Forces the system scope irrespective of scope specified in the attribute for thread creation. Forces the process scope irrespective of scope specified in the attribute for thread creation. If contention scope is set by that scope is considered while creating a thread. Otherwise, is considered. If contention scope is set by that scope is considered while creating a thread. Otherwise, is considered. environment variable that was supported on HP-UX 11i v2 will continue to be supported and will have the same effect as However, if any of the above mentioned new environment variables are set, will not have any effect. Precedence if multiple options are specified: o Environmental variable settings take higher precedence over properties file settings which in turn take higher precedence over compile time options. o If more than one setting is done in one of the ways specified above, force option will take higher precedence over default option and the scope set by System scope takes more precedence than process scope. The contention scope set by takes precedence over external scope setting for default scope process and default scope system. EXAMPLES 1. The following settings are done in properties file: and should be done for the properties file to be read by the pthread library. If is not set, will be used. With these settings, will take the precedence, and system scope will be forced for all thread creations. 2. If the following options are defined at compile time with or defined in one of the application header files: and will take higher precedence, and system scope threads will be forced even when is used to specify the process scope. 3. If the following environmental variables are set (say, using sh-posix): will take higher precedence, and system scope is forced for all the threads created in the process. 4. If the following environmental variables are set (say, using sh-posix): will take higher precedence, and process scope is forced for all the threads created in the process. SEE ALSO
pthread(3T), pthread_attr_init(3T), pthread_attr_setscope(3T). pthread_scope_options(5)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy