Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] "noalloc" + enter/leave blocking section - safe?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@o...>
Subject: [Caml-list] "noalloc" + enter/leave blocking section - safe?
Hi,

one important question: is it safe to use "noalloc" with
C-functions that contain calls to "caml_enter_blocking_section" and
"caml_leave_blocking_section" to allow other POSIX-treads?

I have the following external function:

  (** Synchronize all filesystem buffers with disk. *)
  external sync : unit -> unit = "unix_sync" "noalloc"

It is implemented as follows:

  CAMLprim value unix_sync()
  {
    caml_enter_blocking_section();
      sync();
    caml_leave_blocking_section();
    return Val_unit;
  }

When removing the "noalloc" attribute, I cannot reproduce the problem
(crash) reported in bug report #3019 anymore, but I'm not sure whether
this is just a coincidence.

Of course, functions with this attribute shouldn't allocate anything on
the OCaml-heap or throw exceptions.  But I thought that context-switches
would be safe?

Best regards,
Markus

-- 
Markus Mottl          http://www.oefai.at/~markus          markus@oefai.at

-------------------
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