06-07-2010
"I can't think of a good reason to call pthread_self a lot.
why?"
It's a long story, but basically I need a way of accessing application specific "context" information I have stored which is different depending on which thread is running. Using pthread_self() provides a way of having a unique key to that information regardless of where within a program, the execution is. Because pthread_self doesn't require any arguments, I don't need to carry around a parameter everywhere with that key, hence the application doesn't even have to be aware of the mechanism.
Hopefully that makes sort-of sense.
6 More Discussions You Might Find Interesting
1. Programming
I have the following code snippet's. Which one among these would be more expensive ?
#1
for (int fd = 0; fd <= 1024; ++fd)
close(fd);
#2
for (int fd = 0; fd <= 1024; fd += 8)
{
close(fd);
close(fd+1);
close(fd+2);... (6 Replies)
Discussion started by: vino
6 Replies
2. UNIX for Dummies Questions & Answers
My intention was to build a dual boot XP Pro 64 and Ubuntu media server. I had installed the AMD64 version of Ubuntu 8.10 server and thought that I would be able to install Apache server. I need a GUI to work in. I tried to boot and install Mythbuntu 32 bit 8.10, but my machine now won't recognize... (0 Replies)
Discussion started by: docflyboy
0 Replies
3. Ubuntu
I am using Ubuntu 9.10 with Gnome 2.28.
I use the default Nautilus File Manager to view / manage files.
Is there a way to add icons or customize the icons that are above the location bar and below the menus? There is a bar that has icons for "Back" "Forward" "Parent" above the location bar. I... (6 Replies)
Discussion started by: drewk
6 Replies
4. Ubuntu
Gurus,
I want log in locally to my Lucid (10.04) workstation and have my code saved over the network on my samba account
At work, all developers have samba user ids and when we were running Red Hat, we went thru the following procedure to get setup.
* open a shell session to NFS server... (2 Replies)
Discussion started by: alan
2 Replies
5. What is on Your Mind?
You really should not need one third of the entire US budget to buy a pair of running shoes... even if they are name brand. What have these guys been smoking? It reminds me of the old joke...
Customer: At those prices you aren't going to sell many shoes.
Salesman: Ah, but all we need to do is... (4 Replies)
Discussion started by: Perderabo
4 Replies
6. Ubuntu
I need to re-install ubuntu on a system with ubuntu 14.04 already installed. I have the cd but can not seem to boot from it or find the installer. Is there a way to re-install from the command line or how do I do a fresh re-install? Thank you :)
---------- Post updated at 10:13 AM... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT OSF1
pthread_self
pthread_self(3) Library Functions Manual pthread_self(3)
NAME
pthread_self - Obtains the identifier of the calling thread.
LIBRARY
DECthreads POSIX 1003.1c Library (libpthread.so)
SYNOPSIS
#include <pthread.h>
pthread_t pthread_self(void);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
IEEE Std 1003.1c-1995, POSIX System Application Program Interface
PARAMETERS
None
DESCRIPTION
This routine returns the address of the calling thread's own thread identifier. For example, you can use this thread object to obtain the
calling thread's own sequence number. To do so, pass the return value from this routine in a call to the pthread_getsequence_np(3) routine,
as follows:
unsigned long this_thread_nbr;
.
.
.
this_thread_nbr = pthread_getsequence_np( pthread_self( ) );
.
.
.
The return value from the pthread_self(3) routine becomes meaningless after the calling thread is destroyed.
RETURN VALUES
Returns the address of the calling thread's own thread object.
ERRORS
None
RELATED INFORMATION
Functions: pthread_cancel(3), pthread_create(3), pthread_detach(3), pthread_exit(3), pthread_getsequence_np(3), pthread_join(3),
pthread_kill(3), pthread_sigmask(3)
Manuals: Guide to DECthreads and Programmer's Guide
delim off
pthread_self(3)