Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/cml/src/Unix/syscall.sml
ViewVC logotype

View of /sml/trunk/src/cml/src/Unix/syscall.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (20 years ago) by monnier
File size: 975 byte(s)
bring revisions from the vendor branch to the trunk
(* syscall.sml
 * COPYRIGHT (c) 1996 AT&T Research.
 * Some system calls may take a long time to complete and may
 * be interrupted by timer signals before they complete.  This
 * module implements mechanisms to protect against this problem.

structure Syscall : sig

    val isIntr : OS.syserror -> bool

    val doSyscall : ('a -> 'b) -> 'a -> 'b
	(* do a system call, and restart if it is interrupted *)

    val doAtomicSyscall : ('a -> 'b) -> 'a -> 'b
	(* do a system call with timer signals masked *)

  end = struct

    structure S = Scheduler

    fun isIntr err = (err = Posix.Error.intr)

    fun doAtomicSyscall f x = let
	  val _ = S.stopTimer()
	  val y = (f x) handle ex => (S.restartTimer(); raise ex)
	    S.restartTimer(); y

    fun doSyscall f x = let
	  fun try 0 = doAtomicSyscall f x
	    | try n = ((f x)
		handle (ex as OS.SysErr(_, SOME err)) =>
		  if isIntr err then try(n-1) else raise ex)
	    try 3


ViewVC Help
Powered by ViewVC 1.0.0