Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Heejong Lee <ihji@ropas.snu.ac.kr>
To: caml-list@yquem.inria.fr
Subject: Unix.lockf should support SEEK_SET flag
Date: Fri, 23 Nov 2007 19:45:01 +0900	[thread overview]
Message-ID: <563FECCB-A6C4-4F21-AEBE-F63B77B71411@ropas.snu.ac.kr> (raw)

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


                 reply	other threads:[~2007-11-23 10:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=563FECCB-A6C4-4F21-AEBE-F63B77B71411@ropas.snu.ac.kr \
    --to=ihji@ropas.snu.ac.kr \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox