Exemple #1
0
 /// <summary>
 /// Method call when either of the cores did not have any other remaining threads to run. It has to modify the
 /// synchronizing mechanisms accordingly.
 /// </summary>
 private void FinalizeHighLevelThread()
 {
     ClockBarrier.RemoveParticipant();
     ProcessorBarrier.SignalAndWait();
     Check();
     ProcessorBarrier.RemoveParticipant();
     ClockBarrier.SignalAndWait();
 }
Exemple #2
0
        /// <summary>
        /// Main method through which the simulation starts. It also prints information of the various structures present
        /// as well as the results of the running threads.
        /// </summary>
        /// <param name="slowMotion"> The mode of the execution. "true" stands for slow mode, it means that each 100 cycles
        /// the simulation will stop for 2 seconds and print the current state of the clock and cores, at "false" it jumps
        /// directly to the results.</param>
        public void RunSimulation(bool slowMotion)
        {
            CoreZeroThread.Start();
            CoreOneThread.Start();
            while (ClockBarrier.ParticipantCount > 1)
            {

                ClockBarrier.SignalAndWait();
                if (slowMotion && Clock % Constants.SlowMotionCycles == 0)
                {
                    System.Console.WriteLine("Current Clock: " + Clock);               
                    System.Console.WriteLine("**********************************************************");
                    System.Console.WriteLine("Clock : " + Clock);
                    System.Console.WriteLine("Core Zero Main thread number: " +
                                             CoreZero.Context.ThreadId);                    
                    System.Console.WriteLine("Core One thread number: " +
                                             CoreOne.Context.ThreadId);
                    System.Console.WriteLine("***********************************************************");
                    Thread.Sleep(Constants.DelayTime);
                }
                Clock++;
                Check();                
                ProcessorBarrier.SignalAndWait();                
            }
            

            // At this point the simulation has ended
            // First display the data contents of main memory
            System.Console.WriteLine("Displaying Main Memory:");
            System.Console.Write(Memory.Instance.ToString());
            System.Console.WriteLine("***********************************************************");

            // Now display Data Caches
            System.Console.WriteLine("Displaying Data Cache from Core Zero:");
            System.Console.Write(CoreZero.DataCache.ToString());
            System.Console.WriteLine("***********************************************************");

            System.Console.WriteLine("Displaying Data Cache from Core One:");
            System.Console.Write(CoreOne.DataCache.ToString());
            System.Console.WriteLine("***********************************************************");

            // Finally display the statistics of each thread
            System.Console.WriteLine("Displaying statistics for each thread:");
            foreach (var context in ContextList)
            {
                System.Console.WriteLine(context.ToString());
                System.Console.WriteLine("***********************************************************");
            }
        }