pthread arguments, just how many?

pthread arguments, just how many?

Post by Buffy The Cache Cod » Sun, 11 Nov 2001 05:26:58



I've been searching the internet to find out
just how many arguments do pthread_getspecific take?

With so many hits on the search, it seems like
POSIX accepts two interfaces!  Can this be so?!

On Solaris:

void *pthread_getspecific(pthread_key_t key);

On HPUX:

int pthread_setspecific(
           pthread_key_t key,
           pthread_addr_t value);

Which one is it?

Thanks.

 
 
 

pthread arguments, just how many?

Post by Dragan Cvetkovi » Sun, 11 Nov 2001 05:33:33



Quote:> I've been searching the internet to find out
> just how many arguments do pthread_getspecific take?

> With so many hits on the search, it seems like
> POSIX accepts two interfaces!  Can this be so?!

> On Solaris:

> void *pthread_getspecific(pthread_key_t key);

> On HPUX:

> int pthread_setspecific(
>            pthread_key_t key,
>            pthread_addr_t value);

> Which one is it?

> Thanks.

Well, both :-) One is pthread_getspecific(), the other is
pthread_setspecific(), so there is no conflicts.

Bye, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole

 
 
 

pthread arguments, just how many?

Post by Arnold Hendrik » Sun, 11 Nov 2001 05:32:37



Quote:> I've been searching the internet to find out
> just how many arguments do pthread_getspecific take?

One.

Quote:> On Solaris:
> void *pthread_getspecific(pthread_key_t key);
> On HPUX:
> int pthread_setspecific(
>            pthread_key_t key,
>            pthread_addr_t value);

You're quoting pthread_SETspecific on HPUX, not pthread_GETspecific.

--

B-Lex Information Technologies, http://www.b-lex.com/

 
 
 

pthread arguments, just how many?

Post by Patrick Doy » Mon, 12 Nov 2001 06:05:24




Quote:>I've been searching the internet to find out
>just how many arguments do pthread_getspecific take?

>With so many hits on the search, it seems like
>POSIX accepts two interfaces!  Can this be so?!

>On Solaris:

>void *pthread_getspecific(pthread_key_t key);

>On HPUX:

>int pthread_setspecific(
>           pthread_key_t key,
>           pthread_addr_t value);

>Which one is it?

It's both.  (Hint: look at the first letter after the underscore.  :-)

--
--
Patrick Doyle

 
 
 

1. Safe pthread argument passing ?? Help !

Thank you in advance for your concern.

I'd like to know what's the safe method to pass a argument into a
newly created thread. I have no reference in Posix Thread, thus I
am not sure about this. Suppose there are 2 functions:

void X (void *arg) { ... };

void Y () {
    struct arg_t arg;
     ... ...
    pthread_create (&thread, NULL, X, &arg);

Could this be the case: before thread X begin to use arg, function Y
exited first, thus the pointer that X got is out of date. When X trys
to use *arg, an error will occur.

How to solve this problem ? I'm trying to use mutex. That is, add a
mutex member in struct arg_t, then, before creating the thread, in Y:

void Y () {
    ....
    pthread_mutex_lock (&arg.mutex);
    pthread_create (&thread, NULL, X, &arg);
    pthread_mutex_lock (&arg.mutex);

void X (struct arg_t *arg) {
    ....
    /* use arg ... then arg is no longer needed */
    pthread_mutex_unlock (&arg->mutex);
    ....

Could you tell me is this the good way to do this ? What is the best
solution ?

Thanks !

- Jerrey

2. netatalk performance

3. argument parser strips out " in arguments

4. Configuring Linksys Wireless AP

5. script questions - passing argument as argument to another program

6. Please help--WindowsXP cannot copy large files to Samba

7. newbie: (command and its arguments) as a sh script argument

8. boot net:dhcp options

9. Taking arguments from pipe 'plus' one more argument

10. pushd <no arguments> versus cd <no arguments>

11. The argument to end all pro-Linux arguments

12. a bug with pthread?

13. pthreads and gdb