re-entrant libraries - is C deficient?

Tom Horsley tom at ssd.csd.harris.com
Wed Oct 3 21:18:29 AEST 1990


>>>>> Regarding re-entrant libraries - is C deficient?; alanf at bruce.cs.monash.OZ.AU (Alan Grant Finlay) adds:

alanf> I'm sure there are other languages that provide a solution to this
alanf> problem.  For example in Pascal I can have nested procedures (I know
alanf> this is not quite a solution since the application must be compiled
alanf> in the scope of the nested procedures - but it is part way to a
alanf> solution).

I would guess that the majority of all Pascal implementations (or any other
language that allows nested procedure definitions) implement nested
procedures via static links. When it comes right down to it, a static link
is nothing more that a hidden parameter passed in to every routine that
points to the lexically correct parent stack frame (which can be thought of
as a structure). In other words, just because Pascal hides all the mechanism
does not mean that it is any lower overhead.

I hasten to add (before I get flamed to death) that many compilers may
reduce this overhead considerably by passing the static link in a register
rather than on the stack, but then on most RISC machines these days, most
arguments are passed in registers anyway.

I also hasten to add that the above comment is not an endorsment of C over
Pascal - if you need nested procedures it is obviously simpler to use a
language that actually supports them directly rather than having to create
artificial structures with extra arguments, etc.

Back to the original point - the C library is definitely deficient when it
comes to being re-entrant. The standard AT&T and/or Berkely source is chock
full of global variables being used to pass junk around between internal
static routines, etc. This becomes a real drag when you try to implement
threads. The C library needs lots of work before it can be used safely from
multiple threads of control...
--
======================================================================
domain: tahorsley at csd.harris.com       USMail: Tom Horsley
  uucp: ...!uunet!hcx1!tahorsley               511 Kingbird Circle
                                               Delray Beach, FL  33444
+==== Censorship is the only form of Obscenity ======================+
|     (Wait, I forgot government tobacco subsidies...)               |
+====================================================================+



More information about the Comp.lang.c mailing list