Sponsored Content
Top Forums Programming calling pthread_self (on ubuntu), expensive? Post 302427054 by gorga on Thursday 3rd of June 2010 04:25:06 PM
Old 06-03-2010
calling pthread_self (on ubuntu), expensive?

Hi all,

Is anyone aware of what operations are involved when a call to pthread_self() is made, obtaining the unique thread ID on a Ubuntu system (or even any Linux flavour)?

Specifically, to retrieve the thread id, is there any locking required or atomic operations?

I'm building an application for multi-core systems (in C using pthreads) which needs to be scalable and I'm planning to call this function quite often, hence I need some idea how "expensive" it is to do so.

Any help much appreciated.

Thanks.
 

6 More Discussions You Might Find Interesting

1. Programming

Which is more expensive ?

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

Would like to install x86 desktop Ubuntu over AMD64 Ubuntu server

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

Ubuntu / Ubuntu File Manager / Config

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

[UBUNTU] mount.nfs fails in Ubuntu / Works on Red Hat!!!

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?

Very Expensive Running Shoes

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

Re-install Ubuntu 14.04 from system with Ubuntu on it

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
PTHREAD_SELF(3) 					     Linux Programmer's Manual						   PTHREAD_SELF(3)

NAME
pthread_self - obtain ID of the calling thread SYNOPSIS
#include <pthread.h> pthread_t pthread_self(void); Compile and link with -pthread. DESCRIPTION
The pthread_self() function returns the ID of the calling thread. This is the same value that is returned in *thread in the pthread_cre- ate(3) call that created this thread. RETURN VALUE
This function always succeeds, returning the calling thread's ID. ERRORS
This function always succeeds. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +---------------+---------------+---------+ |Interface | Attribute | Value | +---------------+---------------+---------+ |pthread_self() | Thread safety | MT-Safe | +---------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
POSIX.1 allows an implementation wide freedom in choosing the type used to represent a thread ID; for example, representation using either an arithmetic type or a structure is permitted. Therefore, variables of type pthread_t can't portably be compared using the C equality operator (==); use pthread_equal(3) instead. Thread identifiers should be considered opaque: any attempt to use a thread ID other than in pthreads calls is nonportable and can lead to unspecified results. Thread IDs are guaranteed to be unique only within a process. A thread ID may be reused after a terminated thread has been joined, or a detached thread has terminated. The thread ID returned by pthread_self() is not the same thing as the kernel thread ID returned by a call to gettid(2). SEE ALSO
pthread_create(3), pthread_equal(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 2017-09-15 PTHREAD_SELF(3)
All times are GMT -4. The time now is 09:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy