Today I ran into an interesting problem that I would like to share. I am working on multi-threaded code in C++. Here’s what happened. I started a thread that looks like this: try { do_something() } catch (…) { std::cout << “Got unknown exception” << std::endl; } The do_something() routine eventually called pthread_exit(). Once I […]
Update 06/16/2009: On several occasions, commentators to this article pointed out that this post is somewhat incomplete. Therefore, before I continue, I would like to make some things clear. Before considering the code below, please note that spinlocks are totally useless on uni-processor computers. This is due to a nature of spinlocks, which I will […]
Table of contents Introduction How atomic variables work Atomic variables size limitations Use cases The real thing… Time to see some action Precautions Conslusion IntroductionBACK TO TOC In this article I would like to continue subject I started in my previous two posts (post 1 and post2). Question I am trying to answer is what […]
Posted on November 9, 2008, 9:23 am, by Alexander Sandler, under
Short articles.
Continuing my previous post, I would like to talk about relatively new feature in glibc and pthreads in particular. I am talking about spinlocks.
From some reason this topic never got enough attention in libc. POSIX threads library does addresses this issue, however what starts in POSIX library stays in POSIX library. pthread_self() and friends will get you an identifier that is unique accross your program, but not accross your system. Although thread is a system object, the system […]
Tags:
call,
getpid,
gettid,
identifier,
linux,
pid,
posix,
pthread,
syscall,
system,
thread,
tid 11 Comments |
Read the rest of this entry »