The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
getting problem in my code:::: plz help...(multithreaded appn with serial comm.) arunchaudhary19 High Level Programming 0 10-29-2007 09:38 AM
getting problem in my code:::: plz help...(multithreaded appn with serial comm.) arunchaudhary19 Linux 0 10-26-2007 07:24 AM
Hi errno in sys/stat.h vijlak High Level Programming 6 11-11-2006 09:13 PM
errno pb dts High Level Programming 3 08-06-2004 10:51 AM
login error after sys-unconfig, errno = 13 roing UNIX for Dummies Questions & Answers 14 02-08-2004 11:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-31-2001
S.Vishwanath S.Vishwanath is offline
Registered User
  
 

Join Date: Jan 2001
Posts: 48
Getting errno in a Multithreaded program

In Tru64 Unix, the 'errno' variable is not thread safe.
Could anybody help me about how to make it thread safe or how to check 'errno' in a Multithreaded program ????

The Programming process is like this.

There are some definite number of threads having their own task.
There is one particular thread which tries to read from Disk.
We know that there can be n-number of possibilities for a read to fail. So, depeinding upon the error number thrown from a read failure., I call appropriate thread to take some action .

This task works fine when implemented as a Monolithic Program (i.e., non-multi threaded approach) but since my program is a multithreaded I'm not able to get the appropriate error no. as it is not thread safe.

So, can any body help me out with some technic/method of getting/traping out the appropriate errno.

Thanks in advance.
  #2 (permalink)  
Old 12-31-2001
shaik786
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Each thread gets it's own copy of the global variable: errno. This is done automatically by the Threads Library. So, have fun!!!

Rgds
SHAIK
  #3 (permalink)  
Old 03-25-2002
S.Vishwanath S.Vishwanath is offline
Registered User
  
 

Join Date: Jan 2001
Posts: 48
Sorry for the Delayed Update.

In case of Multi Threaded Programming., just before including the
pthread.h file just define _REENTRANT., then the system will take care of making the errno thread safe.

Ex:-

#define _REENTRANT

#include <pthread.h>

main()
{
}

Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0