Version française
Home     About     Download     Resources     Contact us    
Browse thread
features of PCRE-OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <gerd@g...>
Subject: Re: features of PCRE-OCaml
On Fri, 08 Dec 2000, Markus Mottl wrote:
>Gerd Stolpmann schrieb am Friday, den 08. December 2000:
>> However, the PCRE stubs can be improved in one point: The master lock could be
>> released while the engine executes the regexp. Several threads could then
>> use the engine at the same time which would improve the responsiveness of
>> multi-threaded programs, and the programs would run faster on SMP systems.
>
>Are there annotations which one could use to indicate reentrancy of
>external functions? This would make it fairly easy to get rid of this
>problem. This information could then also be used for program analysis.

There are two functions making it easy: enter_blocking_section and
leave_blocking_section. For example, the stub for the read syscall of the Unix
library:

value unix_read(value fd, value buf, value ofs, value len) /* ML */
{
  long numbytes;
  int ret;
  char iobuf[UNIX_BUFFER_SIZE];

  Begin_root (buf);
    numbytes = Long_val(len);
    if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
    enter_blocking_section();
    ret = read(Int_val(fd), iobuf, (int) numbytes);
    leave_blocking_section();
    if (ret == -1) uerror("read", Nothing);
    bcopy(iobuf, &Byte(buf, Long_val(ofs)), ret);
  End_roots();
  return Val_int(ret);
}

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------