コード例 #1
0
ファイル: Program.cs プロジェクト: sidecut/xaeios
 static void StartDebugConsole()
 {
     SIP debugConsoleSIP = new SIP(delegate()
     {
         new DebugConsole().Start();
     }, ThreadPriority.Normal, "XaeiOS.DebugConsole");
 }
コード例 #2
0
ファイル: Thread.cs プロジェクト: sidecut/xaeios
 internal Thread(ThreadStart threadStart, ThreadPriority priority, SIP sip, TaskHandle task)
 {
     Task = task;
     _threadStart = threadStart;
     _priority = priority;
     _sip = sip;
 }
コード例 #3
0
ファイル: ResourceManager.cs プロジェクト: sidecut/xaeios
 internal static void RegisterSIP(SIP sip)
 {
     if (_resourceMap.ContainsKey(sip.PID))
     {
         throw new Exception("SIP " + sip.PID + "is already registered with ResourceManager");
     }
     Logging.Trace("Registering SIP with ResourceManager: " + sip);
     _resourceMap[sip.PID] = new NativeArray<IDisposable>();
 }
コード例 #4
0
ファイル: SIPManager.cs プロジェクト: sidecut/xaeios
 /// <summary>
 /// Registers a SIP with the SIPManager.
 /// Sets the PID of the SIP.
 /// </summary>
 /// <param name="sip">The SIP to register</param>
 public static void RegisterSIP(SIP sip)
 {
     if (sip.PID != -1)
     {
         throw new ArgumentException("SIP is already registered.");
     }
     int pid = GetPID();
     sip.PID = pid;
     _sips[pid] = sip;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: mtenpow/tenpow.com
 private static void StartProcessViewer()
 {
     SIP processViewerSIP = new SIP(delegate()
     {
         Logging.Info("Starting XaeiOS.ProcessViewer");
         ProcessViewer processViewer = new ProcessViewer();
         processViewer.UpdateInterval = 2000;
         processViewer.Start();
     }, ThreadPriority.Normal, "XaeiOS.ProcessViewer");
     processViewerSIP.Start();
 }
コード例 #6
0
ファイル: SignalDaemon.cs プロジェクト: sidecut/xaeios
 public static void Start()
 {
     string processName = typeof(SignalDaemon).FullName;
     if (_signalDaemonProcess != null)
     {
         throw new InvalidOperationException(processName + " is already started. Only one signal daemon is allowed.");
     }
     _signalDaemonProcess = new SIP(delegate(){}, ThreadPriority.High, processName, true);
     _exitLoop = new ManualResetEvent();
     _signalDaemonProcess.Start();
 }
コード例 #7
0
 public static void StartDriver()
 {
     string processName = typeof(XmlHttpRequestManager).Name + ".Driver";
     if (_driverProcess != null)
     {
         throw new InvalidOperationException(processName + " is already started. Only one signal daemon is allowed.");
     }
     _driverExit = new ManualResetEvent();
     _driverProcess = new SIP(delegate() { }, ThreadPriority.High, processName, true);
     _driverProcess.CustomSignal += HandleCustomSignal;
     _driverProcess.Start();
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: mtenpow/tenpow.com
        static void StartPhotoSlideshow()
        {
            SIP slideshowProcess = new SIP(delegate()
            {
                // TODO: Fetch photo database from an XML/JSON file using REST
                Photo[] photos = new Photo[]{
                    new Photo("Photos/michaelten-pow.jpg", "My two sisters, Kaya and Alicia, and me"),
                    new Photo("Photos/lounging_at_pool.jpg", "Lounging by the pool at the Planet Hollywood Hotel, Las Vegas"),
                    new Photo("Photos/coaster.jpg", "Autumn and me on the roller coaster at New York, New York, Las Vegas"),
                    new Photo("Photos/just_michael.jpg", "Just me"),
                    new Photo("Photos/paris_vegas.jpg", "Autumn and me at Paris, Las Vegas"),
                    new Photo("Photos/checking_in.jpg", "Checking into the Planet Hollywood Hotel, Las Vegas"),
                    new Photo("Photos/autumn_and_michael.jpg", "Autumn and me"),
                    new Photo("Photos/wii_at_earls.jpg", "Playing Wii Sports Golf at Earl's house"),
                    new Photo("Photos/packed_jeep.jpg", "My Jeep packed full of my cousin Michelle's belongings.  I was helping her move.")
                };

                _slideshow = new PhotoSlideshow(photos, 10 * 1000);
                SignalDaemon.Start();
                ExportDelegate("ShowNextPhoto", ExportedShowNextPhoto);
                ExportDelegate("ShowPreviousPhoto", ExportedShowPreviousPhoto);
                _slideshow.ShowPhoto(0);
                _slideshow.StartSlideshow();
            }, ThreadPriority.Normal, "Tenpow.PhotoSlideshow");

            // install a custom signal handler to call the appropriate method based upon the PhotoSlideshowSignal that we receive
            slideshowProcess.CustomSignal += delegate(int data)
            {
                PhotoSlideshowSignal signal = (PhotoSlideshowSignal)data;
                if (signal == PhotoSlideshowSignal.ShowNextPhoto)
                {
                    _slideshow.ShowNextPhoto();
                }
                else if (signal == PhotoSlideshowSignal.ShowPreviousPhoto)
                {
                    _slideshow.ShowPreviousPhoto();
                }
                else
                {
                    // TODO: Write to standard error
                    Console.WriteLine("Received unknown signal " + data);
                }
            };
            slideshowProcess.Start();
            _slideshowPid = slideshowProcess.PID;
        }
コード例 #9
0
ファイル: ResourceManager.cs プロジェクト: sidecut/xaeios
 internal static void CleanupAndUnregisterSIP(SIP sip)
 {
     Logging.Info("Cleaning up SIP: " + sip);
     // clean up each resource
     NativeArray<IDisposable> resources = _resourceMap[sip.PID];
     for (int i = 0; i < resources.Length; i++)
     {
         Logging.Info("Freeing resource " + resources[i] + " left by SIP: " + sip);
         //try // TODO: XaeiOS BasicMiddleEnd gets a NonAcyclicGraphException during TransitiveClosuresAndTopologicalSort
         //{
         resources[i].Dispose();
         //}
         //catch (Exception e)
         //{
         //    Logging.Log("Unable to free resource " + resources[i] + ".  Exception was: " + e);
         //}
     }
     _resourceMap.Remove(sip.PID);
 }
コード例 #10
0
ファイル: Thread.cs プロジェクト: sidecut/xaeios
 internal Thread(ThreadStart threadStart, ThreadPriority priority, SIP sip)
     : this(threadStart, priority, sip, null)
 {
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: mtenpow/tenpow.com
 private static void StartTwitterWall()
 {
     SIP twitterWallProcess = new SIP(delegate()
     {
         string screenName = "mtenpow";
         int maxItems = 6;
         TwitterWall twitterWall = new TwitterWall(screenName, maxItems);
         twitterWall.DisplayLoading();
         int refreshInterval = 20 * 1000;
         while (true)
         {
             twitterWall.Refresh();
             Logging.Info("TwitterWall will refresh in " + (refreshInterval / 1000) + " seconds");
             Thread.Sleep(refreshInterval);
         }
     }, ThreadPriority.Normal, "Tenpow.TwitterWall");
     twitterWallProcess.Start();
 }
コード例 #12
0
ファイル: Thread.cs プロジェクト: sidecut/xaeios
 public void Start(object parameter)
 {
     if (_parametizedThreadStart == null)
     {
         throw new NotSupportedException("The thread start delegate was not parametized.  Cannot start this thread with a parameter.");
     }
     if (_name == null)
     {
         _name = "Thread: anonymous";
     }
     if (_sip == null)
     {
         _sip = SIP.CurrentSIP;
     }
     _parameter = parameter;
     Task = SystemCalls.CreateTask(null, ParametizedTaskFunction, new TaskCallback(this.InternalCallback), (TaskPriority)_priority, _name);
     //Logging.Trace("Creating thread " + _name + " with task id: " + Task);
     ThreadManager.RegisterThread(this);
     _sip.InitializeThread(this);
     _running = true;
     SystemCalls.StartTask(Task);
 }
コード例 #13
0
ファイル: Thread.cs プロジェクト: sidecut/xaeios
 internal static Thread CreateSystemThread(ThreadPriority priority, SIP sip, TaskHandle kernelTask, string name)
 {
     Thread kernelThread = new Thread();
     kernelThread.Task = kernelTask;
     kernelThread._priority = priority;
     kernelThread._sip = sip;
     kernelThread._name = name;
     return kernelThread;
 }
コード例 #14
0
ファイル: Thread.cs プロジェクト: sidecut/xaeios
 public void Start()
 {
     if (_threadStart == null)
     {
         throw new NotSupportedException("The thread start delegate was parametized.  Cannot start this thread without a parameter.");
     }
     if (_name == null)
     {
         _name = "[anonymous " + (_idCounter++) + "]";
     }
     if (_sip == null)
     {
         _sip = SIP.CurrentSIP;
     }
     // TODO: No code should be run with an infinite time slice, a critical section should mean that only the kernel can interrupt
     Task = SystemCalls.CreateTask(null, new TaskFunction(_threadStart), new TaskCallback(this.InternalCallback), (TaskPriority)_priority, _name);
     //Logging.Debug("Thread " + _name + " is a child of " + _sip + ".  Task: " + Task.ToString());
     ThreadManager.RegisterThread(this);
     _sip.InitializeThread(this);
     _running = true;
     SystemCalls.StartTask(Task);
 }
コード例 #15
0
ファイル: SIPManager.cs プロジェクト: sidecut/xaeios
 public static void UnregisterSIP(SIP sip)
 {
     _sips.Remove(sip.PID);
 }
コード例 #16
0
ファイル: SIP.cs プロジェクト: sidecut/xaeios
 internal static SIP CreateSystemSIP(string name)
 {
     SIP sip = new SIP(name, true);
     sip.SyncRoot = new object();
     sip.Output = new ConsoleTextWriter();
     sip.Error = new ConsoleTextWriter();
     sip._state = SIPState.Running;
     return sip;
 }
コード例 #17
0
ファイル: SIP.cs プロジェクト: sidecut/xaeios
 private void AddChild(SIP child)
 {
     if (child._parent != null)
     {
         throw new ExecutionEngineException("SIP already had a parent");
     }
     Logging.Debug("Process " + child + " is a child of process " + this);
     _children.Add(child);
     child._parent = this;
 }
コード例 #18
0
ファイル: SIP.cs プロジェクト: sidecut/xaeios
 private void ChildExited(SIP child)
 {
     Logging.Debug("Child process " + child + " exited");
     _children.Remove(child);
     TryExit();
 }