diff --git a/judge/scripts/lib/dir_init.rb b/judge/scripts/lib/dir_init.rb
--- a/judge/scripts/lib/dir_init.rb
+++ b/judge/scripts/lib/dir_init.rb
@@ -12,6 +12,25 @@
# This library maintain a reference counter on the processes using the
# directory. It locks the dir to manage critical section when
# updating the reference counter.
+#
+# Example usage:
+#
+# dman = DirInit::Manager.new("mydir")
+#
+# dman.setup do
+# # do some initialization
+# end
+#
+# #... do anything you want
+#
+# dman.teardown do
+# # clean up
+# end
+#
+# DirInit::Manager ensures that the block passed to setup
+# only runs once by the first process in the concurrent dir usage and
+# block passed to teardown runs once by the last process in
+# that concurrent activities leaving that dir.
module DirInit