Подсистема управления процессами
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
r > HighestPriority) HighestPriority = process.Prior;
ProcessPriorities[index] = process.Prior;
if (index >= 1)
{
double FreeProcessorTime = 100;
double TimePerProcess = 100 / (index + 1);
double PriorityWeight = 0;
int HighPriorityProcessCount = 0;
// расчёт для процессов с приоритетом ниже самого большого
for (int i = 0; i < index + 1; i++)
{
if (ProcessPriorities[i] != HighestPriority)
{
switch (ProcessPriorities[i])
{
case ThreadPriority.Lowest: PriorityWeight = 0.2;
break;
case ThreadPriority.BelowNormal: PriorityWeight = 0.4;
break;
case ThreadPriority.Normal: PriorityWeight = 0.6;
break;
case ThreadPriority.AboveNormal: PriorityWeight = 0.8;
break;
}
FreeProcessorTime -= TimePerProcess * PriorityWeight;
dataGridView1.Rows[i].Cells[4].Value = Math.Round(TimePerProcess * PriorityWeight);
}
else HighPriorityProcessCount++;
}
// расчёт для процессов с самым большим приоритетом
for (int i = 0; i < index + 1; i++)
{
if (ProcessPriorities[i] == HighestPriority)
{
dataGridView1.Rows[i].Cells[4].Value = Math.Round(FreeProcessorTime / HighPriorityProcessCount);
}
}
}
else dataGridView1.Rows[0].Cells[4].Value = "100";
index++;
}
void a_WorkingStateChanged(object sender, EventArgs e)
{
BetaProc b = sender as BetaProc;
manager.SetWaitProperty(b);
}
private void Form1_Load(object sender, EventArgs e)
{
manager.reporterD = dataGridView1;
// Заполняем RadioGroup processType и processPriority объектами RadioButton
RadioButton[] processTypeRadioButtons = new RadioButton[3];
for (int i = 0; i < groupBox1.Controls.Count; i++) processTypeRadioButtons[i] = (RadioButton)groupBox1.Controls[i];
RadioButton[] processPriorityRadioButtons = new RadioButton[5];
for (int i = 0; i < groupBox2.Controls.Count; i++) processPriorityRadioButtons[i] = (RadioButton)groupBox2.Controls[i];
processType = new RadioGroup(processTypeRadioButtons);
processPriority = new RadioGroup(processPriorityRadioButtons);
}
private void button2_Click(object sender, EventArgs e)
{
int processID = (int)dataGridView1.SelectedRows[0].Cells[0].Value - 1;
if (processID != -1 && (string)manager.reporterD.Rows[processID].Cells[3].Value != "Завершен")
{
manager.ReturnMas()[processID].Stop();
manager.reporterD.Rows[processID].Cells[2].Value = "Приостановлен";
}
}
private void button3_Click(object sender, EventArgs e)
{
int processID = (int)dataGridView1.SelectedRows[0].Cells[0].Value - 1;
if ((string)manager.reporterD.Rows[processID].Cells[2].Value == "Приостановлен")
{
manager.ReturnMas()[processID].Restart();
manager.reporterD.Rows[processID].Cells[2].Value = "Возобновлен";
}
}
private void button4_Click(object sender, EventArgs e)
{
int processID = (int)dataGridView1.SelectedRows[0].Cells[0].Value - 1;
if (processID != -1)
{
manager.ReturnMas()[processID].Delete();
manager.reporterD.Rows[processID].Cells[2].Value = "Завершен";
}
}
}
}