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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/cml/src/Win32/syscall.sml
ViewVC logotype

Annotation of /sml/trunk/src/cml/src/Win32/syscall.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 137 - (view) (download)

1 : monnier 137 (* syscall.sml
2 :     *
3 :     * COPYRIGHT (c) 1998 Bell Labs, Lucent Technologies.
4 :     * COPYRIGHT (c) 1996 AT&T Research.
5 :     *
6 :     * Some system calls may take a long time to complete and may
7 :     * be interrupted by timer signals before they complete. This
8 :     * module implements mechanisms to protect against this problem.
9 :     *)
10 :    
11 :     structure Syscall : sig
12 :    
13 :     val isIntr : OS.syserror -> bool
14 :    
15 :     val doSyscall : ('a -> 'b) -> 'a -> 'b
16 :     (* do a system call, and restart if it is interrupted *)
17 :    
18 :     val doAtomicSyscall : ('a -> 'b) -> 'a -> 'b
19 :     (* do a system call with timer signals masked *)
20 :    
21 :     end = struct
22 :    
23 :     structure S = Scheduler
24 :    
25 :     fun isIntr err = false (* TOFIX: this'll break... (err = Posix.Error.intr) *)
26 :    
27 :     fun doAtomicSyscall f x = let
28 :     val _ = S.stopTimer()
29 :     val y = (f x) handle ex => (S.restartTimer(); raise ex)
30 :     in
31 :     S.restartTimer(); y
32 :     end
33 :    
34 :     fun doSyscall f x = let
35 :     fun try 0 = doAtomicSyscall f x
36 :     | try n = ((f x)
37 :     handle (ex as OS.SysErr(_, SOME err)) =>
38 :     if isIntr err then try(n-1) else raise ex)
39 :     in
40 :     try 3
41 :     end
42 :    
43 :     end;
44 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0