close

Вход

Забыли?

вход по аккаунту

?

Rubaev Erik MM-11-1 kursovaya rabota po OS

код для вставкиСкачать
 ???????????? ????????????????? ???????????????
??????????? "?????"
???????? ??????
?? ?????????? "???????????? ??????? ? ?????"
??????? 4
??????: ??-11-1
???????: ?????? ?.?.
?????????????: ??????? ?.?.
?????? 2012
??????????
??????????
1.????????????? ?????2
?????????? ??????????2
2.???????? ?????????6
2.1.???????????? ???????6
2.2.???????? ?????????6
2.3.???????? ??? ?????????(C#)7
2.4.?????????? ?????? ?????????10
3.?????? ???????????? ??????????12
1. ????????????? ?????
???????. ?????????? ??????????
???? ?? ????????? ????? ??, ???????? ?? ?????? ?????????? (?????????????? ??????), ???????? ?????????? ?????????? ?????????? [1]. ? ????????? ??????????? ???????? ?????? ????????? ???????: ??????? (??? ??-???????, ??????) - ?????????? ?????????? ???????????? ????????? ?? ?????????? ???. ??? ?? ??????? ???????????? ????? ??????? ??????, ?????? ?? ??????????? ????????? ????????. ?????????? ?????????? ?????????? ????????? ?????????? ?????????, ?? ???? ???????????? ???????????? ????? ????? ??????????? ???????????? ????????????? ? ??????? ??????????, ? ????? ?????????? ????????? ? ???????????? ?????????, ???????????? ???????? ???????????? ?????????? ?????????, ???????????? ?????????????? ????? ?????????? [1].
???????????????
??????????? ?? ?????????:
??????????????? (????. multitasking) - ???????? ???????????? ??????? ??? ????? ???????????????? ???????????? ??????????? ???????????? (??? ??????????????????) ????????? ?????????? ?????????. ???????? ??????????????? ???????????? ??????? ???????? ?????? ? ?????????????? ?????????????? ????????.
?????????? 2 ???? ??????????????? [4]:
* ?????????? ??????????????? (?????????? ?? ????????? - ???????????? ????????????? ??????????). ????? ????????? - ?????????? ??????? ????, ??????? ????? ????????? ??????????? ???????????? ???????. ????? ???????? ??????????? ????????????? (?????? ? ????????? ????????? ? ????????????? ??????);
* ???????? ??????????????? (?????????? ?? ???????). ?????????? ??????? ???????????? ???? - ????? (???? ????????? ????? ????????? 2 ? ????? ?????? ????????????).
????????? ?????????
? ??????????????? ??????? ??????? ????? ?????????? ? ????? ?? ???? ???????? ????????? [1]:
?????????? - ???????? ????????? ????????, ?? ????? ???????? ??????? ???????? ????? ???????????? ????????? ? ??????????????? ??????????? ???????????;
???????? - ????????? ????????? ????????, ??????? ????????????, ?? ?? ????? ??????????? ?? ????? ?????????? ????????, ?? ???? ????????????? ?????????? ???????, ????????, ?????????? ???????? ?????-??????, ????????? ????????? ?? ??????? ????????, ???????????? ??????-???? ???????????? ??? ???????;
?????????? - ????? ????????? ????????? ????????, ?? ? ???? ?????? ??????? ???????????? ? ????? ? ???????? ?? ????????? ? ???? ????????????????: ??????? ????? ??? ????????? ??? ???? ???????, ?? ????? ???????????, ?????? ????????? ????? ??????????? ??????? ????????.
???????? ? ?????????? ????????
?? ?????????? ????????????? ???????? ??? ?????????? ????? ???? ??????????? ???????? ? ??????????. ??? ????, ????? ??????????? ?????????? ????????, ?????????? ???????????? ????????? ??? ???????????? ?????. ????????? ???????????? ????? ???????????? ?????????? ????????? ? ???????????? ????????, ??????? ?????? ??????????, ??????????? ?? ???????? ?????, ??????????? ? ????????????? ????????? ?????-??????, ?????? ?????? ??????????? ?????? ????????? ????????? ??????? ? ?.?. ??? ?????????? ?????????? ?????????? ???????? [1].
????? ?????, ???????????? ??????? ??? ?????????? ???????????? ????????? ????????? ?????????????? ??????????: ????????????? ????????, ????????? ????????, ?????? ? ??????? ??????????????????? ????????, ????? ?????????? ???????? ???????? ? ?????? ??????????. ? ????????? ?? (????????, ? ?? UNIX) ?????????? ?????? ????, ???????????? ?? ??? ???????????? ?????????, ???????? ???????????? ???????? [1].
?????????? ???????? ?? ????????? ? ?????????? ???????? ????? ??????????? ??????????, ??????? ?????? ???? ????? ???????? ?????????? ???????????? ?????????. ???????? ???????? ???????? ????? ?????????? ?????????? ? ???????????? ???????????? ???????? ?????? ????? ????, ??? ??????? ??????? ? ????????????? ??????????? ???????? [1].
??????? ????????? ???????????? ????? ??????????? ????????? ?????????, ???????????? ? ??????. ????? ???????, ?????? ??????????, ????? ????? ???????, ???????? ?? ??????? ???? ???? ????????? ?? ?????? ??????????, ????????????? ? ??? ? ???????. ????? ??????????? ???????? ????????? ????? ?? ?????????????????, ???????? ? ????????? ????????, ?????????? ???????? ?? ?????? ????????? ? ?????? [1].
??????????? ??? ?????? ????? ?????? ???????????, ????? ??? ???? ???????????? ???????? ????? ?????? ???????. ??????? ??????? - ??? ?????? [1]:
1. ??????? ?????????????? ?????????, ??????????? ?????? ???????, ?? ???? ??? ?????????? ? ????????;
2. ???????? ?????????? ?????? ???????? ? ??????? ??????? ?????????;
3. ????????? ??????? ??????? ???????? ? ??????????? ?????? ??? ? ??????? ????????
???? - ????????? ?????? ? ??????? ??????? ? ????????? LIFO (Last In, First Out).
? ???????? ??????? ????????????? ?????????? ??????? ? ????? ???????? ????? ???????? ????????, ????? ?????????? ????? ???????? ??????? ???? ?? ????. ??? ????????????? ?????? ?????? ?????? ? ?????? ???????? ????????? ????? ?????????? ?? ????????? ???????? [2].
???????????? ????????????? ?????????? ??????? ????? ??????????? ??????????:
* ??????????? ??????????? ????????????? ????????????? ????????? ????????? ???????????? ? ???? ???????????? ? ??? ??????;
* ???????? ? ??????????? ??????? ?????????? ? ???????? ? 100 ??? ???????, ??? ??? ?????????;
* - ????????????? ??????????????????.
????? ????? ?????????? ? ????? ?? ?????????? ?????????. ???????? ????? ??????????? ????? ??, ??? ? ????????? [2].
2. ???????? ?????????
2.1. ???????????? ???????
??????????? ?????????, ???????????? ???????????? ????????? ?????????????? ????????? ? ??????? ? 4 ?????????, ????????????? ?????????? ???????????. 2.2. ???????? ?????????
? ?????? ??????? ???????? ???????? ?? ?????????? ??????????? ?? 1 ?? 5, ?? ?????? - ?? 6 ?? 10, ? ?????? - ?? 11 ?? 15 ? ????????? (?????????) - ?? 16 ?? 20. ? ??????? ?? ????? ????????? ???????? ? ???????????? ???????? 20 ? ???????? 1. ??? ???????? ??? ?????????? ????????????? ????? ???????????. ?????????? ????????? ??????? ?????? ?????????? ????????. ??????? ?????????? (? ??????? ???????????) ?????????????? ??? ???????? ?? ????????? ???????. ???????, ??? ??? ????? ????????? ?????????. ???? ? ???? ??????? ??? ?????????, ?? ?????????????? ???????? ?? ?????? ???????. ?? ????????? ??????, ??? ? ????????? ?????? ? ?????? ???????, ?? ?????? ??? ? ?????????. ??? ??????????????, ??? ?? ??? ? ????????? ???????? ?? ????? ???????, ? ??????? ???????????. ???? ?????? ? ????????? ??????? ?????, ?? ??????????? ???????? ?????? ???????. ?, ???????, ????? ? ??????? ?? ?????????? ???????? ?????? ?? ??????? ???????, ?? ??????????? ???.
???????? ??????: ????? ?????? ?? ?????????? ????????? (??? ??????, ????? ???????????, ?????????, ????? ??????????).
?????? ?????? ???????? ?????? ? ?????????? ?????? ?????????.
??? ??????, ????? ???????????, ?????????, ????? ?????????? (a,0,9,3); (b,1,3,3); (c,8,18,5); (d,9,6,3); (e,10,12,3) (f,11,11,3).
??????? ????? Process, ??????? ????? ?????? ????: ? ??????, ???????????, ???????? ??????? ???????? ? ????????????? ??????. ??? ?? ? ?????? ??????? ??? ???????? ??????: ??????????? ? ??????????? (??? ????????????? ??????), ??????????? ?? ?????????, ????? ToString(??? ?????? ?????????????????? ???????? ????? ?????). ? ?????? Program ??????? ?????? ???????(?????????? ????????????? ?????? Queue). ?????, ? ?????, ?????????? ???????? ??????? ?? ?????????? ?????????, ?????????? ????????????? ?????? ?? ????? "test.txt" ? ? ??????? ??????? ??????? ???????? ?????????????? ?? ????????, ? ??????????? ?? ???????????. ? Console ????????? ??????? ? ???????????? ??????????? ??????. ????? ????????? ??? ???? ????, ? ??????? ??????????? ?????? ???????(??????????? ???? startTime ? ???? ?????????), ??? ????, ????? ???????????? ????????????? ?????? ????????? ? ???? ??????????? ???? ?? ???????, ?? ? ??????(? ???????, ???????????? ?????? ?????????) ???????????? ??? ??????? ????????(???? name) ??????? ???, ??????? ?????? ?? ?????? ??????? ? ? ????? ??????, ????????? ????????? ????????: "aaabbbccceeeddd" (??????). ????? ???? ?????????? ????? ???? ?????? ? Console.
2.3. ???????? ??? ?????????(C#)
?????? ???? ConsoleApplication:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication3
{
class Process
{
public string name;//??? ???????? Gname
public int priority;//????????? Gpriority
public int startTime;//????? ??????? ???????? GStart
public int executeTime;//???????????? ??????? ???????? GexecTime
public Process(string name, int startTime, int priority, int executeTime)//???????????
{
this.startTime = startTime;
this.executeTime = executeTime;
this.name = name;
this.priority = priority;
}
public Process()
{
}
public override string ToString()//????? ??????
{
return String.Format("{0} {1} {2} {3}", name, priority, startTime, executeTime);
}
}
class Program
{
static void Main(string[] args)
{
//??????? 4 ???????
Queue<Process> Queue1 = new Queue<Process>();
Queue<Process> Queue2 = new Queue<Process>();
Queue<Process> Queue3 = new Queue<Process>();
Queue<Process> Queue4 = new Queue<Process>();
Console.WriteLine("\t\t\t???????? ??????:");
Console.WriteLine();
//????????? ?? ?????
StreamReader koren = new StreamReader("test.txt", Encoding.GetEncoding(1251));
int number = int.Parse(koren.ReadLine());
int length = 0;
int start = 0;
for (int i = 0; i < number; i++)
{
string newLine = koren.ReadLine();
string[] proc = newLine.Split(' ');
Process DoProc = new Process(proc[0], int.Parse(proc[1]), int.Parse(proc[2]), int.Parse(proc[3]));
length += DoProc.executeTime;
start = DoProc.startTime;
//??????????? ?? ??????????? ????????
if (DoProc.priority >= 15)
{
Queue4.Enqueue(DoProc);
}
if (DoProc.priority >= 10 && DoProc.priority < 15)
{
Queue3.Enqueue(DoProc);
}
if (DoProc.priority >= 5 && DoProc.priority < 10)
{
Queue2.Enqueue(DoProc);
}
if (DoProc.priority >= 0 && DoProc.priority < 5)
{
Queue1.Enqueue(DoProc);
}
}
int[] graph = new int[(length + start) * 10];
string[] name = new string[(length + start) * 10];
for (int i = 0; i < graph.Length; i++)
{
graph[i] = -1;
}
Console.WriteLine("______________________________________________________________________________");
for (int currentStep = 0; Queue1.Count != 0 || Queue2.Count != 0 || Queue3.Count != 0 || Queue4.Count != 0; currentStep++)
{
graph[currentStep] = 0;
Process process4 = new Process();
Process process3 = new Process();
Process process2 = new Process();
Process process1 = new Process();
if (Queue4.Count != 0) process4 = Queue4.Peek();
if (Queue3.Count != 0) process3 = Queue3.Peek();
if (Queue2.Count != 0) process2 = Queue2.Peek();
if (Queue1.Count != 0) process1 = Queue1.Peek();
if (process4.startTime < currentStep && Queue4.Count > 0)
{
int busyTime = process4.executeTime;
Console.WriteLine("??? ????????: {0} \t ?????: {1}\t ????? ??????: {2}\t ?????????: {3} ", process4.name, process4.startTime, process4.executeTime, process4.priority);
Console.WriteLine("_______________________________________________________________________________");
for (int i = currentStep; i < currentStep + busyTime; i++)
{
graph[i] = 4;
name[i] = process4.name;
}
Queue4.Dequeue();
currentStep += busyTime;
continue;
}
if (process3.startTime < currentStep && Queue3.Count > 0)
{
int busyTime = process3.executeTime;
Console.WriteLine("??? ????????: {0} \t ?????: {1}\t ????? ??????: {2}\t ?????????: {3} ", process3.name, process3.startTime, process3.executeTime, process3.priority);
Console.WriteLine("_______________________________________________________________________________");
for (int i = currentStep; i < currentStep + busyTime; i++)
{
graph[i] = 3;
name[i] = process3.name;
}
Queue3.Dequeue();
currentStep += busyTime;
continue;
}
if (process2.startTime < currentStep && Queue2.Count > 0)
{
int busyTime = process2.executeTime;
Console.WriteLine("??? ????????: {0} \t ?????: {1}\t ????? ??????: {2}\t ?????????: {3} ", process2.name, process2.startTime, process2.executeTime, process2.priority);
Console.WriteLine("______________________________________________________________________________");
for (int i = currentStep; i < currentStep + busyTime; i++)
{
graph[i] = 2;
name[i] = process2.name;
}
Queue2.Dequeue();
currentStep += busyTime;
continue;
}
if (process1.startTime < currentStep && Queue1.Count > 0)
{
int busyTime = process1.executeTime;
Console.WriteLine("??? ????????: {0} \t ?????: {1}\t ????? ??????: {2}\t ?????????: {3} ", process1.name, process1.startTime, process1.executeTime, process1.priority);
Console.WriteLine("_______________________________________________________________________________");
for (int i = currentStep; i < currentStep + busyTime; i++)
{
graph[i] = 1;
name[i] = process1.name;
}
Queue1.Dequeue();
currentStep += busyTime;
continue;
}
}
Console.WriteLine();
string graphik = ""; //?????????? ? ??????? ???????? ????????, ??? ??????????
for (int current = 0; current < graph.Length; current++)
{
if (graph[current] == 1)
{
graphik += name[current];
}
if (graph[current] == 2)
{
graphik += name[current];
}
if (graph[current] == 3)
{
graphik += name[current];
}
if (graph[current] == 4)
{
graphik += name[current];
}
}
Console.WriteLine("\n");
Console.WriteLine("\t\t\t????????? ?????? ?????????: ");
Console.WriteLine();
Console.WriteLine(" \t\t\t{" + graphik + "}");
Console.ReadKey();
}
}
}
2.4. ?????????? ?????? ?????????
?????? ?1:
?????? ?2. ?????????? ??????????:
?????? ?3:
3. ?????? ???????????? ??????????
1. http://citforum.ru/operating_systems/sos/glava_6.shtml
2. ??????? ????. "???????????? ? ?????????????? ????????????????"
3. ??????? ?????. ????????? 4. ????????? ?. ??????????? ???????????? ???????. ???-? 4. ???.: ?????, 2010
1
Документ
Категория
Без категории
Просмотров
6
Размер файла
109 Кб
Теги
1_kursovaya_rabota_po_os, rubaev_erik_mm
1/--страниц
Пожаловаться на содержимое документа