Sponsored Content
Top Forums Programming Understanding Condition variables Post 302573539 by jim mcnamara on Monday 14th of November 2011 10:41:49 PM
Old 11-14-2011
I do not understand your confusion very well. Here is a stab at an answer that may help.

pthread_cond_t variables MUST BE USED with separate mutexes. Mutexes do not take on values like 42. Think of cond_t variables as special add-on features for mutexes that take on a value.

See this page, scroll down to condition variables.

Linux Tutorial: POSIX Threads
 

10 More Discussions You Might Find Interesting

1. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

2. UNIX for Dummies Questions & Answers

pthread condition variables and mutexes?

I am trying to understand the exact difference between condition variables and mutexes in thread synchronization ?. I know mutex will control the thread access to shared data and condition variables will be useful for waiting for certain event or condition to occur . But I couldn't understand why... (2 Replies)
Discussion started by: siddaonline
2 Replies

3. Programming

Condition variables

Hi, I am reading through the pthreads tutorial and had a question on the example they have given for condition variables. Here is the code snippet: This is what the thread waiting on the condition variables doing: pthread_mutex_lock(&count_mutex); while (count<COUNT_LIMIT) { <---... (10 Replies)
Discussion started by: the_learner
10 Replies

4. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

5. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

7. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

8. Shell Programming and Scripting

BASH arrays and variables of variables in C++

Sometimes it is handy to protect long scripts in C++. The following syntax works fine for simple commands: #define SHELLSCRIPT1 "\ #/bin/bash \n\ echo \"hello\" \n\ " int main () { cout <<system(SHELLSCRIPT1); return 0; } Unfortunately for there are problems for: 1d arrays:... (10 Replies)
Discussion started by: frad
10 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. UNIX for Dummies Questions & Answers

How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1 username1=userid poihostname1=dellsys.com port1=8080 How can I pass these variables into below code... RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Discussion started by: manohar2013
4 Replies
PTHREAD_CONDATTR_DESTROY(3P)				     POSIX Programmer's Manual				      PTHREAD_CONDATTR_DESTROY(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
pthread_condattr_destroy, pthread_condattr_init - destroy and initialize the condition variable attributes object SYNOPSIS
#include <pthread.h> int pthread_condattr_destroy(pthread_condattr_t *attr); int pthread_condattr_init(pthread_condattr_t *attr); DESCRIPTION
The pthread_condattr_destroy() function shall destroy a condition variable attributes object; the object becomes, in effect, uninitialized. An implementation may cause pthread_condattr_destroy() to set the object referenced by attr to an invalid value. A destroyed attr attributes object can be reinitialized using pthread_condattr_init(); the results of otherwise referencing the object after it has been destroyed are undefined. The pthread_condattr_init() function shall initialize a condition variable attributes object attr with the default value for all of the attributes defined by the implementation. Results are undefined if pthread_condattr_init() is called specifying an already initialized attr attributes object. After a condition variable attributes object has been used to initialize one or more condition variables, any function affecting the attributes object (including destruction) shall not affect any previously initialized condition variables. This volume of IEEE Std 1003.1-2001 requires two attributes, the clock attribute and the process-shared attribute. Additional attributes, their default values, and the names of the associated functions to get and set those attribute values are implemen- tation-defined. RETURN VALUE
If successful, the pthread_condattr_destroy() and pthread_condattr_init() functions shall return zero; otherwise, an error number shall be returned to indicate the error. ERRORS
The pthread_condattr_destroy() function may fail if: EINVAL The value specified by attr is invalid. The pthread_condattr_init() function shall fail if: ENOMEM Insufficient memory exists to initialize the condition variable attributes object. These functions shall not return an error code of [EINTR]. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
See pthread_attr_init() and pthread_mutex_init(). A process-shared attribute has been defined for condition variables for the same reason it has been defined for mutexes. FUTURE DIRECTIONS
None. SEE ALSO
pthread_attr_destroy(), pthread_cond_destroy(), pthread_condattr_getpshared(), pthread_create(), pthread_mutex_destroy(), the Base Defini- tions volume of IEEE Std 1003.1-2001, <pthread.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 PTHREAD_CONDATTR_DESTROY(3P)
All times are GMT -4. The time now is 08:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy