- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- thread-local storage doesnt work with gcc
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:31 PM
тАО08-30-2007 08:31 PM
Re: thread-local storage doesnt work with gcc
That's not true. The following code does compile with gcc 4.2.0 and works:
--------------------------------------------------
#include
#include
#define NUM_THREADS 4
static void *Work(void *num);
int main(void) {
int NumberOfThreads = NUM_THREADS;
pthread_t Worker[NUM_THREADS];
int j, ret;
for(j = 0; j < NumberOfThreads; j++) {
ret = pthread_create(&Worker[j], NULL, (void *)&Work, (void *)j);
if(ret) {
fprintf(stderr, "Error while Creating Threads\n");
return -1;
}
}
for(j = 0; j < NumberOfThreads; j++) {
pthread_join(Worker[j], NULL);
}
return 0;
}
static void *Work(void *num) {
int i;
for(i = 0; i < 100; i++) {
int j;
char buf[256]= {'\0'};
for(j = 0; j < (int)num; j++) {
sprintf(buf,"%s\t\t",buf);
}
printf("%s%d\n",buf, i);
}
return;
}
--------------------------------------------------
/opt/hp-gcc-4.2.0/bin/gcc -pthread -o parallel parallel.c && ./parallel
--------------------------------------------------
So Pthreads work on my machine with GCC and CC, but TLS does only work with CC.
MfG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:42 PM
тАО08-30-2007 08:42 PM
Re: thread-local storage doesnt work with gcc
That's what Steve meant, gcc wasn't configured to handle the __thread keyword.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2007 08:51 PM
тАО08-30-2007 08:51 PM
Re: thread-local storage doesnt work with gcc
But maybe there is another Keyword that separately enables TLS-support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2007 03:26 AM
тАО09-04-2007 03:26 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-09-2007 11:22 PM
тАО09-09-2007 11:22 PM
Re: thread-local storage doesnt work with gcc
Thank You
- « Previous
-
- 1
- 2
- Next »