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

SCM Repository

[smlnj] Diff of /sml/branches/rt-transition/system/Basis/Implementation/NJ/internal-signals.sml
ViewVC logotype

Diff of /sml/branches/rt-transition/system/Basis/Implementation/NJ/internal-signals.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3422, Mon Jul 27 16:31:56 2009 UTC revision 3423, Mon Jul 27 16:56:26 2009 UTC
# Line 92  Line 92 
92    (* these run-time functions deal with the state of a signal in the system. *)    (* these run-time functions deal with the state of a signal in the system. *)
93      val getSigState : system_const -> int               = SMLNJRuntime.getSigState      val getSigState : system_const -> int               = SMLNJRuntime.getSigState
94      val setSigState : (system_const * int) -> unit      = SMLNJRuntime.setSigState      val setSigState : (system_const * int) -> unit      = SMLNJRuntime.setSigState
95    (* The states are defined as: *)  
96      val ignoreSigState = 0    (* The states are defined in the IDL spec *)
97      val defaultSigState = 1      val ignoreSigState = SMLNJRuntime.IGNORE_SIG
98      val enabledSigState = 2      val defaultSigState = SMLNJRuntime.DEFAULT_SIG
99        val enabledSigState = SMLNJRuntime.ENABLED_SIG
100    
101    (* clear the signal table of handlers *)    (* clear the signal table of handlers *)
102      fun clearSigTbl _ = Array.modify (fn _ => NONE) (!sigTbl)      fun clearSigTbl _ = Array.modify (fn _ => NONE) (!sigTbl)
# Line 183  Line 184 
184                  in                  in
185                    setInfo(sigId, {act=act, mask=mask+1, signal=signal})                    setInfo(sigId, {act=act, mask=mask+1, signal=signal})
186                  end                  end
187          (* scan over the sorted mask list and the list of all signals.  Record which signals are masked          (* scan over the sorted mask list and the list of all signals.  Record
188           * and how many new signals are masked.           * which signals are masked and how many new signals are masked.
189           *)           *)
190            fun computeNewMask ([], _, _, _, 0) =            fun computeNewMask ([], _, _, _, 0) =
191                (* no signals are masked, so we only update the local state *)                (* no signals are masked, so we only update the local state *)
# Line 226  Line 227 
227                  end                  end
228          (* return true if decrementing this signal's count will unmask it. *)          (* return true if decrementing this signal's count will unmask it. *)
229            fun isUnmasked (SIG(id, _)) = (#mask(getInfo id) <= 1)            fun isUnmasked (SIG(id, _)) = (#mask(getInfo id) <= 1)
230          (* scan over the sorted mask list and the list of all signals.  Record which signals          (* scan over the sorted mask list and the list of all signals.  Record
231           * are masked and how many new signals are unmasked.           * which signals are masked and how many new signals are unmasked.
232           *)           *)
233            fun computeNewMask ([], _, _, _, 0) =            fun computeNewMask ([], _, _, _, 0) =
234                (* no signals are unmasked, so we only update the local state *)                (* no signals are unmasked, so we only update the local state *)
235                  List.app decMask sigs                  List.app decMask sigs
236              | computeNewMask ([], [], masked, nMasked, _) = (              | computeNewMask ([], [], masked, nMasked, _) = (
237                (* NOTE: we must update are local view of the mask before we change the OS's view                (* NOTE: we must update are local view of the mask before we
238                 * to avoid a race condition!                 * change the OS's view to avoid a race condition!
239                 *)                 *)
240                  List.app decMask sigs;                  List.app decMask sigs;
241                  setSigMask (makeMask (masked, nMasked)))                  setSigMask (makeMask (masked, nMasked)))
# Line 324  Line 325 
325    (* Here is the ML handler that gets invoked by the run-time system.    (* Here is the ML handler that gets invoked by the run-time system.
326     * It is responsible for dispatching the appropriate ML handler.     * It is responsible for dispatching the appropriate ML handler.
327     *)     *)
328      fun sigHandler (code, count, resume_k) =      fun sigHandler (code, count, resume_k) = (case (Array.sub(!sigTbl, code))
         (case (Array.sub(!sigTbl, code))  
329            of (SOME{act=HANDLER handler, mask=0, signal}) =>            of (SOME{act=HANDLER handler, mask=0, signal}) =>
330               handler(signal, count, resume_k)               handler(signal, count, resume_k)
331  (*DEBUG  (*DEBUG
# Line 337  Line 337 
337                                | SOME{act=IGNORE, ...} => "IGNORE"                                | SOME{act=IGNORE, ...} => "IGNORE"
338                                | SOME{act=DEFAULT, ...} => "DEFAULT"                                | SOME{act=DEFAULT, ...} => "DEFAULT"
339                                | SOME{act=HANDLER _, mask, ... } =>                                | SOME{act=HANDLER _, mask, ... } =>
340                                  concat ["HANDLER(mask=",Int.toString mask,                            concat ["HANDLER(mask=",Int.toString mask, "<>0)"]
                                         "<>0)"]  
341                                  (*end case *))                                  (*end case *))
342                   val msg = concat["inconsistent state ", act,                   val msg = concat["inconsistent state ", act,
343                                    " for signal ", Int.toString code]                                    " for signal ", Int.toString code]

Legend:
Removed from v.3422  
changed lines
  Added in v.3423

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