Thread local storage on ancient AIX


 
Thread Tools Search this Thread
Top Forums Programming Thread local storage on ancient AIX
# 1  
Old 04-10-2009
Thread local storage on ancient AIX

What I'm given:
Pure C code in one file that has to compile on Windows, SunOS, and AIX. My task is making minimal changes to the code to make it thread safe. I'm not in control of threads - they are created elsewhere. The code has a function invoked externally. The first call to this function is solitary. I.e. I'm guaranteed that no other call in any other thread will be made until it returns. It allows me to initialize mutexes during that call. The task seems very easy to accomplish with pthread library.

However, there is a complication. There are situations, when two consecutive calls to the function within a thread are related, and the first needs to pass some information to the next call. The natural way to accomplish it is to declare a thread local variable in global context. For this I use __thread directive, and it seems to work perfectly on SunOS. For AIX, on the other hand, this does not work. Since for our compilation we use the least common denominator for the broadest support, AIX complains that __thread directive is not compatible with the platform.

1. Is there anything AIX specific that allows to declare thread local variable in global context besides __thread directive?
2. What would be the most elegant (least code changes) work around?
# 2  
Old 04-10-2009
Been a long time since I was foraging around in that sort of mess, but here's maybe a nudge. You didn't say anything about compiler / linkers or versions or OS versions or any of that sort of thing, so here's a possibility to follow up on if you're using this on the AIX box (-qtls option of XL C/C++ V9.0 for AIX):

IBM Compilers
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Migrate /export/home from storage path to local

I am newbies in solaris, hope u guys can help me, I need to transfer /export/home directory that currently mount at storage and migrate into local disk. may i know the best way to do it? Thanks (6 Replies)
Discussion started by: Deeo
6 Replies

2. Solaris

How to differ local disks from attached from storage ones?

Hello. I have a solaris box with several local disks and several come from SYMMETRIX storage. Is there any way to tell format (or other util) to show only local disks? (6 Replies)
Discussion started by: urello
6 Replies

3. Programming

Thread function local variables

As I know threads share the memory. But, what about the local variables in the thread function? if i call multiple threads would they allocate seperate local variables for themselves? like thread_func() { int i, j; string... } Are the above local variables defined for each of... (1 Reply)
Discussion started by: saman_glorious
1 Replies

4. AIX

Do I need to configure my local windows to FTP files from local windows to a UNIX AIX server?

Hi Friends, I have this script for ftping files from AIX server to local windows xp. #!/bin/sh HOST='localsystem.net' USER='myid_onlocal' PASSWD='mypwd_onlocal' FILE='file.txt' ##This is a file on server(AIX) ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE... (1 Reply)
Discussion started by: rajsharma
1 Replies

5. Shell Programming and Scripting

crontab; copy most recent *.mpg file from local machine to smb storage device

Hello, I've been searching your forum for an answer to the following question and whilst I've seen several which may help I'm afraid my inexperience with UNIX systems has got the better of me and I'm incapable of piecing your considerable expertise together. Problem: I have a linux box which... (5 Replies)
Discussion started by: julezsht
5 Replies

6. AIX

unused storage on AIX 4.3

Hi, How do I query for unused partition in AIX 4.3 with DAS and SAA storage? I know most unix administrator don't put all the capacity on the system at once. thanks, vene (1 Reply)
Discussion started by: venerayan
1 Replies

7. Programming

Can't dlopen() a library containing Thread Local Storage

Hi, I have a small test c program which tries to dlopen a shared library(libjvm.sl). But i get error as "Can't dlopen() a library containing Thread Local Storage" My program is as below when i run the program i get error any pointers why the error?? I am using hp-ux . The... (1 Reply)
Discussion started by: shriashishpatil
1 Replies

8. AIX

AIX and Storage

Hi:- What is the best way to determine what type of storage is attached to an AIX server? Thanks, (2 Replies)
Discussion started by: janet
2 Replies
Login or Register to Ask a Question