Ejemplo n.º 1
0
        /// <summary>
        /// Prepare for the next schedule by popping entries from the stack
        /// until we find some tid entries that are not slept.
        /// </summary>
        public void PrepareForNextSchedule()
        {
            if (Rand != null)
            {
                NextStackPos = 0;
                return;
            }

            // Deadlock / sleep set blocked; no selected tid entry.
            {
                TidEntryList top = GetTopAsRealTop();

                if (top.IsNoneSelected(Contract))
                {
                    Pop();
                }
            }


            // Pop until there are some tid entries that are not done/slept OR stack is empty.
            while (StackInternal.Count > 0)
            {
                TidEntryList top = GetTopAsRealTop();

                if (top.BacktrackNondetChoices(Contract))
                {
                    break;
                }

                top.SetSelectedToSleep(Contract);
                top.ClearSelected(Contract);

                if (!top.AllDoneOrSlept())
                {
                    break;
                }

                Pop();
            }

            NextStackPos = 0;
        }
Ejemplo n.º 2
0
        private void AddThreadIdToRaceReplaySuffix(TidEntryList tidEntryList)
        {
            // Add thread id to the RaceReplaySuffix, but adjust
            // it for missing thread ids.

            int tid = tidEntryList.GetSelected(Contract);

            var index = MissingThreadIds.BinarySearch(tid);

            // Make it so index is the number of missing thread ids before and including threadId.
            // e.g. if missingThreadIds = [3,6,9]
            // 3 => index + 1  = 1
            // 4 => ~index     = 1
            if (index >= 0)
            {
                index += 1;
            }
            else
            {
                index = ~index;
            }

            RaceReplaySuffix.Add(new TidForRaceReplay(tid - index, tidEntryList.NondetChoices));
        }