File locking primitives?

David T. Lewis lewis at mail.msen.com
Sat Mar 15 14:37:41 UTC 2003


On Fri, Mar 14, 2003 at 04:02:55PM +0100, Cees de Groot wrote:
> On Fri, 2003-03-14 at 15:57, Cees de Groot wrote:
> > Is there a way to get to the underlying file handle from a fileID? I've
> > looked through the plugin code, but I still think I'm missing something
> > (ie where are all the sqWriteFile, ... defined?)
> 
> Sorry, didn't look hard enough - my searches left out the platform tree.
> 
> Err, am I right in concluding that all file I/O goes through the
> (notoriously slow) C stdio library? Ouch. That'll kill most database
> efforts ;-). And it's probably a bit hard to go from a FILE * to a unix
> file handle inside Squeak :-(
> 
> Is FFI any fast? I'd like to re-route all OmniBase I/O calls (open,
> close, lseek, read, write) to the Unix system calls to see whether it
> makes a large enough difference to bother, but if FFI is slow that won't
> help. 

Load OSProcess, then IOHandle, from SM. OSPP does a lot of what you want
with files, and IOHandle makes it nicely browsable in Squeak. The quickest
path to get file locking primitives would be to clone some of the methods
in OSPP. See the primitives in category "primitives - files" in class
UnixOSProcessPlugin.

Most Squeak VM's use stdio (FILE *), but on Win32 you are talking directly to
the Win32 HANDLEs.

On Unix, to see how to get at a low level file handle, try something like:
  OSProcess accessor unixFileNumber: SourceFiles second ioHandle

Try opening an explorer on a FileStream and looking at its ioHandle. This
is an image-side view of the SQFile data structure in the VM.

I guess I should stick some file locking prims in OSPP one of these days.

Dave



More information about the Squeak-dev mailing list