<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - keigoi</title>
<link>http://snipplr.com/users/keigoi/language/other/tags/OCaml</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Fri, 24 May 2013 20:49:06 GMT</pubDate>
<item>
<title>(Other) OCaml memory allocation and context switching</title>
<link>http://snipplr.com/view/19509/ocaml-memory-allocation-and-context-switching/</link>
<description><![CDATA[ <p>OCaml runtime is known to do context switch at the point allocation occurs (confirmed on current version 3.11.1).
This snippet shows that context switch never occurs if the thread does not do any allocation, i/o nor synchronization.
compile with:

ocamlopt -thread -I +threads -I unix unix.cmxa threads.cmxa filename.ml

the function allocation allocates some memory on OCaml side, while allocation2 does on C side. 
In latter case allocation never occur on OCaml side, hence context doesn't switch, and one of the thread runs forever, while the other starves.

See also:http://snipplr.com/view/19485/</p> ]]></description>
<pubDate>Thu, 10 Sep 2009 12:04:25 GMT</pubDate>
<guid>http://snipplr.com/view/19509/ocaml-memory-allocation-and-context-switching/</guid>
</item>
<item>
<title>(Other) OCaml threads context switch example</title>
<link>http://snipplr.com/view/19485/ocaml-threads-context-switch-example/</link>
<description><![CDATA[ <p>this example checks that when the context switch occurs in the O'Caml runtime.
compile it with:


ocamlc -vmthread -I +threads -I unix unix.cmxa threads.cmxa filename.ml
ocamlc -thread -I +threads -I unix unix.cmxa threads.cmxa filename.ml
ocamlopt -thread -I +threads -I unix unix.cmxa threads.cmxa filename.ml


both 1. and 2. terminates, while 3. not (on my OCaml 3.11.1, on Mac OS X).

See also:http://snipplr.com/view/19509/</p> ]]></description>
<pubDate>Thu, 10 Sep 2009 04:34:04 GMT</pubDate>
<guid>http://snipplr.com/view/19485/ocaml-threads-context-switch-example/</guid>
</item>
</channel>
</rss>