void ExecuteReloadCmd() { TaskEntryList.Clear(); var values = _taskService.GetOpenEntries().ToList(); TaskEntryList.AddRange(values); }
/// <summary> /// Update the sleep sets for the top operation on the stack. /// This will look at the second from top element in the stack /// and copy forward the sleep set, excluding tasks that are dependent /// with the executed operation. /// </summary> public static void UpdateSleepSets(Stack stack) { if (stack.GetNumSteps() <= 1) { return; } TaskEntryList prevTop = stack.GetSecondFromTop(); TaskEntry prevSelected = prevTop.List[prevTop.GetSelected()]; TaskEntryList currTop = stack.GetTop(); // For each task on the top of stack (except previously selected task and new tasks): // if task was slept previously // and task's op was independent with selected op then: // the task is still slept. // else: not slept. for (int i = 0; i < prevTop.List.Count; i++) { if (i == prevSelected.Id) { continue; } if (prevTop.List[i].Sleep && !IsDependent(prevTop.List[i], prevSelected)) { currTop.List[i].Sleep = true; } } }
/// <summary> /// Returns or forces the next choice to schedule. /// </summary> private bool GetNextHelper(ref IAsyncOperation next, List <IAsyncOperation> ops, IAsyncOperation current) { int currentSchedulableId = (int)current.SourceId; // "Yield" and "Waiting for quiescence" hack. if (ops.TrueForAll(op => !op.IsEnabled)) { if (ops.Exists(op => op.Type is AsyncOperationType.Yield)) { foreach (var op in ops) { if (op.Type is AsyncOperationType.Yield) { op.IsEnabled = true; } } } else if (ops.Exists(op => op.Type is AsyncOperationType.WaitForQuiescence)) { foreach (var op in ops) { if (op.Type is AsyncOperationType.WaitForQuiescence) { op.IsEnabled = true; } } } } // Forced choice. if (next != null) { this.AbdandonReplay(false); } bool added = this.Stack.Push(ops); TaskEntryList top = this.Stack.GetTop(); Debug.Assert(next is null || added, "DPOR: Forced choice implies we should have added to stack."); if (added) { if (this.UseSleepSets) { SleepSets.UpdateSleepSets(this.Stack); } if (this.Dpor is null) { top.SetAllEnabledToBeBacktracked(); } else if (this.Dpor.RaceReplaySuffix.Count > 0 && this.Dpor.ReplayRaceIndex < this.Dpor.RaceReplaySuffix.Count) { // Replaying a race: var tidReplay = this.Dpor.RaceReplaySuffix[this.Dpor.ReplayRaceIndex]; // Restore the nondet choices on the top of stack. top.NondetChoices = tidReplay.NondetChoices; // Add the replay tid to the backtrack set. top.List[tidReplay.Id].Backtrack = true; Debug.Assert(top.List[tidReplay.Id].Enabled || top.List[tidReplay.Id].OpType is AsyncOperationType.Yield, "Failed."); ++this.Dpor.ReplayRaceIndex; } else { // TODO: Here is where we can combine with another scheduler: // For now, we just do round-robin when doing DPOR and random when doing random DPOR. // If our choice is forced by parent scheduler: if (next != null) { top.AddToBacktrack((int)next.SourceId); } else if (this.Rand is null) { top.AddFirstEnabledNotSleptToBacktrack(currentSchedulableId); } else { top.AddRandomEnabledNotSleptToBacktrack(this.Rand); } } } else if (this.Rand != null) { // When doing random DPOR: we are replaying a schedule prefix so rewind the nondet choices now. top.RewindNondetChoicesForReplay(); } int nextTid = this.Stack.GetSelectedOrFirstBacktrackNotSlept(currentSchedulableId); if (nextTid < 0) { next = null; // TODO: if nextTidIndex == DPORAlgorithm.SLEEP_SET_BLOCKED then let caller know that this is the case. // I.e. this is not deadlock. return(false); } if (top.TryGetSelected() != nextTid) { top.SetSelected(nextTid); } Debug.Assert(nextTid < ops.Count, "nextTid >= choices.Count"); next = ops[nextTid]; // TODO: Part of yield hack. if (!next.IsEnabled && next.Type is AsyncOperationType.Yield) { // Uncomment to avoid waking a yielding task. // next = null; // TODO: let caller know that this is not deadlock. // return false; next.IsEnabled = true; } Debug.Assert(next.IsEnabled, "Not enabled."); return(true); }