public bool Run()
        {
            Console.WriteLine("JAVA - DEOS\n");

            theTimer         = new NewTimer();
            thePeriodicClock = new PeriodicClock(Registry.uSecsInFastestPeriod);
            systemClock      = new Clock(thePeriodicClock, theTimer);

            DEOSKernel.ColdStartKernel();

            int result = DEOSKernel.CreateThreadK("user1", 0, 21, 1);

            logger.Info("{threadName}|{result}", "user1", result);

            result = DEOSKernel.CreateThreadK("user2", 0, 21, 1);
            logger.Info("{threadName}|{result}", "user2", result);

            int tickResult = Clock.NOINTERRUPTS;

            for (int i = 0; i < 1000; i++)
            {
                DEOS.println("****************************");
                DEOS.println("Current time: " + DEOS.systemClock.GetCurrentTime());

                DEOS.println(Scheduler.CurrentThread().ToString() + " is the current thread");

                tickResult = DEOS.systemClock.Ticks();

                Scheduler.CurrentThread().GetBody().Run(tickResult);
            }

            return(true);
        }
Exemple #2
0
        public void Run(int tickResult)
        {
            DEOS.Inc();

            if (tickResult == Clock.NOTIMECHANGE)
            {
                DEOS.println("No interrupts!");
                DEOS.println(thread.ToString() + " waiting until next period");
                DEOSKernel.WaitUntilNextPeriodK(thread); //yieldCPU();
            }
            else
            {
                if (DEOS.RandBool())
                {
                    DEOS.println("---Choice 0 of main---");
                    DEOS.println(thread.ToString() + " waiting until next period");
                    DEOSKernel.WaitUntilNextPeriodK(thread);
                }
                else
                {
                    DEOS.println("---Choice 1 of main---");

                    GetInterrupted(tickResult);
                }
            }
        }
Exemple #3
0
        public void Run(int tickResult)
        {
            //Verify.assertTrue(Timer.timer || Timer.tick);
            DEOS.Inc();

            if (tickResult == Clock.NOTIMECHANGE)
            {
                if (DEOS.RandBool())
                {
                    //System.out.println("Thread: " + thread + " - Depth: " + depth);
                    DEOS.println("No interrupt - Choice 0:");
                    DEOS.println(thread.ToString() + " waiting until next period");
                    DEOSKernel.WaitUntilNextPeriodK(thread);

                    //yieldCPU();
                }
                else
                {
                    //System.out.println("Thread: " + thread + " - Depth: " + depth);
                    DEOS.println("No interrupt - Choice 1:");
                    DEOS.println(thread.ToString() + " deleting");
                    int result = DEOSKernel.DeleteThreadK(thread); //deleteThread();
                    logger.Info("{threadName}|{result}", thread.ToString(), result);
                }
            }
            else
            {
                Random rand = new Random();
                switch (rand.Next(2))
                {
                case 0:

                    //System.out.println("Thread: " + thread + " - Depth: " + depth);
                    DEOS.println("Choice 0:");
                    DEOS.println(thread.ToString() + " waiting until next period");
                    DEOSKernel.WaitUntilNextPeriodK(thread);

                    //yieldCPU();
                    break;

                case 2:

                    //System.out.println("Thread: " + thread + " - Depth: " + depth);
                    DEOS.println("Choice 2:");
                    DEOS.println(thread.ToString() + " deleting");
                    int result = DEOSKernel.DeleteThreadK(thread);
                    logger.Info("{threadName}|{result}", thread.ToString(), result);

                    //deleteThread();
                    break;

                case 1:

                    //System.out.println("Thread: " + thread + " - Depth: " + depth);
                    DEOS.println("Choice 1: ");
                    GetInterrupted(tickResult);

                    break;
                }
            }
        }