caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Unix.lockf should support SEEK_SET flag
@ 2007-11-23 10:45 Heejong Lee
  0 siblings, 0 replies; only message in thread
From: Heejong Lee @ 2007-11-23 10:45 UTC (permalink / raw)
  To: caml-list

Hello, caml-list members

Let me suggest something very important to ocaml developers.

Recently, I'm developing an application that uses multi-cores. As we  
know, Ocaml doesn't have kernel level thread because of the garbage  
collector issues. Instead of real thread, I chose Cothread and Netshm  
for thread emulation using process and shared memory. Unfortunately, I  
suffered from a lot of strange bugs for many weeks.

After tracing every system call, I found the bug. Cothread and Netshm  
use record locking provided by Unix.lockf. On current implementation  
of Unix.lockf, locking method should be two steps, lseek and lockf.  
However, since forked processes share opened file offsets, race  
condition can happen between lseek and lockf. There were many bugs  
from the fact that both Netshm and Cothread use lseek and lockf. Their  
lockings would be incomplete in some situations.

To avoid this problem, I extended Unix.lockf to support SEEK_SET flag  
of fcntl to designate the offset directly. This solves all strange  
bugs above. I think that Unix.lockf should support SEEK_SET option  
officially.

I want to hear your opinions.

--
Heejong Lee


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-23 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-23 10:45 Unix.lockf should support SEEK_SET flag Heejong Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).