John Max Skaller | 1 Dec 2000 13:59
Picon
Picon

Re: Dynamic loading. Again.

Fabrice Le Fessant wrote:

> Well, you are right. You don't need to generate position independent
> code, but it is better if you want the code to be shared between
> processes. Otherwise, each process has its own code, and a shared
> library is not that shared ...

	Nope. The code can be shared anyhow: it is relocated
by patching at load time and everyone uses the same load address.
Only one copy of the code, used by all clients.

	The per process data lives at the same address for
every process, but the underlying memory is swapped for 
every task switch (at least, on the 486 this is done).

	So exactly the same logical memory addresses can be used
by multiple processes without interference. No application level
register or use of relative addressing is required.

	I don't know about Linux, but NT copies the per process
data lazily (that is, each processes copy of the data space
is mapped on to a read only memory page at the same address,
and the page is copied on write to new physical memory,
which is located, for THAT process only, at the same address).

	Summary: all application level NT and Linux-486 code is
relocatable, no application level register is required,
absolute address modes can be used freely. The big problem is, 
in fact, sharing memory between processes!

(Continue reading)

John Max Skaller | 1 Dec 2000 14:34
Picon
Picon

Re: Dynamic loading. Again.

Chris Hecker wrote:
> 
> >{I think all this stinks, and is a result of using a stupid language
> >like C for systems programming .. but that's another story]
> 
> Okay, I'll bite.  Why does the current situation stink, and how would you change it?
> 
> Chris

	I'd start by eliminating global variables;
probably, I'd eliminate the stack as well and use continuation objects.
Function pointers would denote closures (not just code objects).
I'd throw out all primitive data types (except possibly bool).
main would go. Compiled interfaces with type-safe linkage.
Decent syntax. More formal standard. 
Ummm.. just about everything you can think of is wrong with C.

	I'm currently developing an application level language
(called Felix) that does some of this. [No global variables,
closures, procedural continuations, garbage collection.
Functional code still uses the machine stack for performance.
Functions cannot have side effects (but they can depend on
variables in their environment). 

	The translator control inverts procedural code so that
one writes blocking reads, but the generated code is actually
event driven. 

	There are no primitive data types (except, sort of, bool).

(Continue reading)

Philippe NARBEL | 1 Dec 2000 15:07
Picon
Picon

Recherche stages en entreprise orient'es O'Caml


J'enseigne O'Caml dans le cadre du Dess Genie Logiciel de 
l'Universit'e Bordeaux I et certains etudiants desireraient 
faire un stage en entreprise orient'e O'Caml. Auriez-vous
des propositions dans ce sens ?
Ce stage est prevu d'avril a septembre 2001. 

Ph. Narbel
LaBRI

Fabrice Le Fessant | 1 Dec 2000 15:24
Picon
Picon
Favicon
Gravatar

Re: Dynamic loading. Again.


>   The per process data lives at the same address for
> every process, but the underlying memory is swapped for 
> every task switch (at least, on the 486 this is done).

What about libraries mapped at the same address, or on overlapping
segments ? They could be loaded first by different processes, then
another one would want to use both of them and would not be able to
map both of them !!! You MUST have position independent code if you
really want your code to be SHARED.

- Fabrice

Homepage: http://pauillac.inria.fr/~lefessan

Ward Wheeler | 1 Dec 2000 12:37
Favicon

(unknown)

Hello,
	I have an OCAML application that passes arrrays from CAML to C to do some 
string matching, then passes the results back to CAML.  This happens 
alot.  Currently I use Int_val and Field to acces the CAML values.  I have 
been wondering if I should change the code to use the Big_Array Module 
instead.
	Does anyone know if this makes a big difference, pros/cons?
Thanks,
Ward Wheeler

*********************************
Ward Wheeler
Division of Invertebrate Zoology
American Museum of Natural History
Central Park West  <at>  79th St.
New York, NY 10024-5192
1-212-769-5754 (Voice)
1-212-769-5277 (FAX)
*********************************

John Max Skaller | 1 Dec 2000 17:49
Picon
Picon

Re: Dynamic loading. Again.

Fabrice Le Fessant wrote:

> >   The per process data lives at the same address for
> > every process, but the underlying memory is swapped for
> > every task switch (at least, on the 486 this is done).
> 
> What about libraries mapped at the same address, 

	They can't be.

> or on overlapping
> segments ? They could be loaded first by different processes, 

	Only one library can be loaded at a time.
The loader must block while it is loading a library.
[At least, it must block while allocating the address space]

>then another one would want to use both of them and would not be able to
> map both of them !!! You MUST have position independent code if you
> really want your code to be SHARED.

	Suppose I load library X. It gets mapped to

	0xFF00-0000

Now suppose YOU load library X. It is already in memory.
The loader knows that. It gets mapped to

	0xFF00-0000

(Continue reading)

Mattias Waldau | 1 Dec 2000 19:44
Picon
Favicon

RE: sorting of list of vectors (array with one dimension)

Nice suggestions changing the data structure, but I can't change it.

Instead, I implemented the indirection trick by Max Skaller. However instead
of finding how to reorder the data, I just use a temporary data structure
instead.

The algoritm is first to find how to reorder (sort_columns_step_1), and then
l the reordering on each array (sort_columns_step_2).

In this example I like to sort the arrays t1,t2 and t3 according to t1

let t1 = [|2;1;4;3|] in
let t2 = [|true;false;false;true|] in
let t3 = [|"mattias";"magnus";"george";"hugo"|] in
let reorder = sort_columns_step_1 t1 in
   sort_columns_step_2 ~reorder t1;
   sort_columns_step_2 ~reorder t2;
   sort_columns_step_2 ~reorder t3;
   (t1,t2,t3);;
              - : int array * bool array * string array =
[|1; 2; 3; 4|], [|false; true; true; false|],
[|"magnus"; "mattias"; "hugo"; "george"|]

and the code is

let sort_columns_step_1 (a:'a array) : int array =
  let a_i = Array.init (Array.length a) (fun ii -> ii) in
  let compare_a = (fun e1 e2 -> compare a.(e1) a.(e2)) in
  Array.sort compare_a a_i;
  a_i
(Continue reading)

John Max Skaller | 2 Dec 2000 17:00
Picon
Picon

Re: sorting of list of vectors (array with one dimension)

Mattias Waldau wrote:
> 
> Nice suggestions changing the data structure, but I can't change it.
> 
> Instead, I implemented the indirection trick by Max Skaller. However instead
> of finding how to reorder the data, I just use a temporary data structure
> instead.

That's easiest, but it would be nice to find a fast way to reorder
the array in place, in case you get very large arrays, where
constructing a new one would exhaust memory, or slow down
the process due to the VM thrashing the disk.

--

-- 
John (Max) Skaller, mailto:skaller <at> maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

Jean-Christophe Filliatre | 4 Dec 2000 08:44
Picon

Re: Parsing ANSI C using OCAML


In his message of Thu November 30, 2000, Laurent Reveillere writes: 
> I have to build a lexer/parser for the ANSI C language.
> Does anyone now if such a tool exists in OCAML?

I  don't know  of  such a  lexer/parser. But  you  can find  a lot  of
lex/yacc grammars  for ANSI C on  the web, which can  be easily turned
into ocamllex/ocamlyacc grammars. Here is such a site:

     http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

Hope this helps,
--

-- 
Jean-Christophe FILLIATRE
  mailto:Jean-Christophe.Filliatre <at> lri.fr
  http://www.lri.fr/~filliatr

Markus Mottl | 3 Dec 2000 23:51
Picon

PCRE-Ocaml at Sourceforge

Hello,

the PCRE-interface for OCaml (current stable version: 4.2-3) has just
moved to Sourceforge:

  http://pcre-ocaml.sourceforge.net

For those who have not yet tried it, PCRE-OCaml is a library for efficient
and convenient pattern matching, string substitution and splitting using
Perl-style regular expressions and substitution patterns.

Contributions are welcome!

Best regards,
Markus Mottl

--

-- 
Markus Mottl, mottl <at> miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl


Gmane