From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,8e9b885446835ab4 X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1994-11-09 05:27:05 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!spool.mu.edu!sgiblab!uhog.mit.edu!grapevine.lcs.mit.edu!think.com!paperboy.osf.org!rsalz From: rsalz@osf.org (Rich Salz) Newsgroups: comp.unix.osf.misc Subject: Re: errno and DCE and threads Date: 9 Nov 1994 13:27:05 GMT Organization: Open Software Foundation Message-ID: <39qin9$9g6@paperboy.osf.org> References: <39lsjk$lrf@clam.hi.com> NNTP-Posting-Host: sulphur.osf.org Cc: In article <39lsjk$lrf@clam.hi.com> wright@clam.hi.com (David Wright) writes: >The single biggest problem is errno handling. Errno is a single, >global variable in standard Unix. (Granted, this was a really bad >design decision, but we're stuck with it.) Since DCE applications are >multi-threaded, they need to be able to keep errno on a per-thread >basis (so they don't trip over each other's values). If you read the definition of errno in the ANSI standard, you'll see that errno can be a #define that evaluates to an lvalue. This means you can do things like this: /* Returns the address of the per-thread "errno" field in the current * thread. Assumes each thread has an internal state struct. */ extern int *pthread_errno_np(void); #define errno (*pthread_errno_np()) In practice, however, it's probably easier to just store errno in the internal per-thread state block and copy it in/out as part of your thread task context switch. For kernel threads, the kernel should just be doing the right thing. /r$