Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 May 1999 20:11:01 -0500
From:      "G. Adam Stanislav" <adam@whizkidtech.net>
To:        Thomas David Rivers <rivers@dignus.com>
Cc:        dima@tejblum.dnttm.rssi.ru, freebsd-hackers@FreeBSD.ORG
Subject:   Re: wc* routines
Message-ID:  <19990507201101.A216@whizkidtech.net>
In-Reply-To: <199905061154.HAA73794@lakes.dignus.com>; from Thomas David Rivers on Thu, May 06, 1999 at 07:54:01AM -0400
References:  <19990505214934.B217@whizkidtech.net> <199905061154.HAA73794@lakes.dignus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, May 06, 1999 at 07:54:01AM -0400, Thomas David Rivers wrote:
>  I mention this, somewhat facetiously... but one of the fundamental
>  discoveries in computer science was the idea of separation between
>  code and data.   Although you bring up good points; realize that
>  you are violating that tenet... and as such, are inviting potential
>  trouble.

Well, in my home country we have a proverb: Exceptions confirm rules. :-)
(Oh, it's Slovakia, before anyone asks.)

>  Perhaps a half-way point is needed, much as the locale library
>  is implemented.  Provide, in the library, some default table
>  that is a "reasonable subset of everything" so programs don't 
>  just blow up if they can't find the file... then, provide the
>  mechanism for reading the file if they can find it.

I like that idea. I think the EES (Extended European Subset) would be a
reasonable one: It contains a little over 3000 characters, covering more
than European languages. Although I would probably add Devanagari to it -
a small price to pay to include many languages of India to the default
subset. And probably the two kanas as well.

>  And, you shouldn't assume those Egyptologists can actually
>  recompile & relink their code.

Hehe. Good point.

>  For example, if a word-processing
>  company has sold them a program - it's likely to be quite some
>  time before the next release which is recompiled/relinked with
>  newer FreeBSD libraries is available...

Hmmmm.... Isn't the C library linked dynamically? I was under the impression
that if you update the library, all C programs are automatically going to
use it. Isn't that correct?

Now to the big question (since I am still relatively new to FreeBSD): Suppose
several programs running at the same time want to use the wctype functions.
Since there is only one Unicode/ISO 10646, they all need to use the exact
same data loaded from the exact same file. This data, once loaded, is read only.

Is there a way for all programs to share the same data? I mean, I will have
a pointer, _wct, which initially is NULL. Once any of the wctype functions is
called for the first time, the library will check for the existence of that
file. If it does not find it, it will use the reasonable subset.

However, if it does find the file, it will allocate memory and read the file
to it. This is where I would like the _wct pointer and the memory allocated
to it shared by all programs.

By the same token, I need to know how many programs are using it, so when a
program exits, it only frees the memory if it is the last of the programs
using it.

In other words, is there a way to allocate memory shared by several programs,
and is there a way to declare that certain specific variables (e.g. the
_wcs pointer) be shared by all programs?

And if it is possible (I sure hope so, because it would be a major waste of
memory to have to read the same file separately for each program), is there
a way to change the memory, once allocated and filled, to read only, so if
some wild pointer tries to overwrite it, it will not be able to do it?

I know this sounds like a somewhat naive question, but, as I said, I am still
not fully familiar with the inner workings of FreeBSD. I am assuming the answer
to all these questions is yes, and what I really need to know is how to do it.

Adam


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990507201101.A216>