Sponsored Content
Top Forums Programming hash tables, pthread_key_create Post 88082 by Corona688 on Monday 31st of October 2005 02:15:39 PM
Old 10-31-2005
hash tables, pthread_key_create

I want to store a bunch of pthread_t types in a hash table, but since pthread_t is not an integer value, I cannot hash it. I was hoping to store a unique nonzero as key 0 for each thread with thread-specific data ala pthread_key_create/pthread_setspecific, but but as it turns out only the first thread to create a pthread_key_t can get a key #0! And storing an array to keep track of which thread has which key would defeat the whole point of a hash table.

So is there any way I can store one single integer value per posix thread, anonymously? I can't keep a key index or a pointer because it needs to be accessible from a signal handler.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Returning Hash Tables in Perl

Hi: Does anybody know how to return hash tables created in a function? I have something like so: %a_hash_table = build_a_hash_table(); sub build_a_hash_table { my(%hash_table); #some code to build hash table: "%hash_table" for e.g return %hash_table; } ----> This... (1 Reply)
Discussion started by: mirzabhai
1 Replies

2. UNIX for Dummies Questions & Answers

Passing Hash Tables to Subroutines

Hi: How do I pass a hash table down to a subroutine along with some other variables? For example, I have say a subroutine play_with_hash: sub play_with_hash { my( $var1, $var2, %my_hash ) = @_; #do stuff with %my_hash ........... } Then I want to call the subroutine... (1 Reply)
Discussion started by: mirzabhai
1 Replies

3. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies

4. Programming

Compression algorithm( usage of Hash tables)

Hi All, i was browsing thru' the opensource glib(deflate/inflate) algorithms.. which i am supposed to implement. I came across Dictionary usage (Hash tables), LZ77 algorithm and Huffman coding in that.. i couldn't follow on the Hash table implementation in that. Anybody there to give some... (5 Replies)
Discussion started by: rvan
5 Replies

5. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

6. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

7. Programming

Hash tables concepts

How hash tables are used to quickly locate a data record? (4 Replies)
Discussion started by: rupeshkp728
4 Replies

8. UNIX for Dummies Questions & Answers

Hash Tables of Buffers

Hello, I want to know how hash tables for buffers were implemented in Unix and now, in linux how they are implemented ? I am aware of what hashing is..also quite familiar with Unix/Linux. Special case is how device numbers comes into picture..I am curious ! If possible consider some... (0 Replies)
Discussion started by: istevan
0 Replies

9. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

10. Shell Programming and Scripting

Dynamically parse BibTeX and create hash of hash

Hello gurus, Iam trying to parse following BibTex file (bibliography.bib): @book{Lee2000a, abstract = {Abstract goes here}, author = {Lee, Wenke and Stolfo, Salvatore J}, title = {{Data mining approaches for intrusion detection}}, year = {2000} } @article{Forrest1996, abstract =... (0 Replies)
Discussion started by: wakatana
0 Replies
PTHREAD_EQUAL(3)					     Linux Programmer's Manual						  PTHREAD_EQUAL(3)

NAME
pthread_equal - compare thread IDs SYNOPSIS
#include <pthread.h> int pthread_equal(pthread_t t1, pthread_t t2); Compile and link with -pthread. DESCRIPTION
The pthread_equal() function compares two thread identifiers. RETURN VALUE
If the two thread IDs are equal, pthread_equal() returns a nonzero value; otherwise, it returns 0. ERRORS
This function always succeeds. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------------+---------------+---------+ |Interface | Attribute | Value | +----------------+---------------+---------+ |pthread_equal() | Thread safety | MT-Safe | +----------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
The pthread_equal() function is necessary because thread IDs should be considered opaque: there is no portable way for applications to directly compare two pthread_t values. SEE ALSO
pthread_create(3), pthread_self(3), pthreads(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2015-08-08 PTHREAD_EQUAL(3)
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy