Browse thread
[Caml-list] Best way to synchronize OS processes?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Best way to synchronize OS processes? |
On Tue, May 11, 2004 at 11:05:23AM -0700, Ranjan Bagchi wrote:
> Hi --
>
> I'm writing some code which will end up executing concurrently on
> several OS processes. I'd like to serialize access to some specific OS
> resources (for instance, writing to a single file). The Unix module
> doesn't appear to offer anything like a critical section or an OS
> mutex. Is there a preferred way to do this?
What about Unix.lockf?
Rich.
val lockf : file_descr -> lock_command -> int -> unit
(** [lockf fd cmd size] puts a lock on a region of the file opened
as [fd]. The region starts at the current read/write position for
[fd] (as set by {!Unix.lseek}), and extends [size] bytes forward if
[size] is positive, [size] bytes backwards if [size] is negative,
or to the end of the file if [size] is zero.
A write lock (set with [F_LOCK] or [F_TLOCK]) prevents any other
process from acquiring a read or write lock on the region.
A read lock (set with [F_RLOCK] or [F_TRLOCK]) prevents any other
process from acquiring a write lock on the region, but lets
other processes acquire read locks on it. *)
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
If I have not seen as far as others, it is because I have been
standing in the footprints of giants. -- from Usenet
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners