コード例 #1
0
ファイル: Loader.cs プロジェクト: ICanHaz/Os-model
 private void Load(Task taskSource)
 {
     int currentBlock = 0;
     int currentWord = 0;
     for (int i = 0; i < 40; i++)
     {
         string line = taskSource[i];
         switch (line.Substring(0, 2))
         {
             case "$0":
                 {
                     currentBlock = Convert.ToInt32(line[2].ToString());
                     currentWord = 0;
                     break;
                 }
             case null:
                 {
                     break;
                 }
             default:
                 {
                     virtualMemory[currentBlock, currentWord].Value = line.Length >= 4 ? line.Substring(0, 4) : line;
                     virtualMemory[currentBlock, currentWord].IsOccupied = true;
                     currentWord++;
                     break;
                 }
         }
     }
 }
コード例 #2
0
ファイル: Loader.cs プロジェクト: ICanHaz/Os-model
 public override void Execute()
 {
     switch (Checkpoint)
     {
         case 1:
             task = (Task) RequestResource("Task");
             if (task == null)
             {
                 break;
             }
             Checkpoint++;
             goto case 2;
         case 2:
             userMemory = (UserMemory) RequestResource("UserMemory");
             if (userMemory == null)
             {
                 break;
             }
             Checkpoint++;
             goto case 3;
         case 3:
             Load(task);
             MapBlocks(1);
             CreateResource(new TaskReady(this, Resources.State.Free, virtualMemory, "TaskReady" ,
                            new List<string> { "MainProc"}));
             State = Processes.State.Blocked;
             Checkpoint = 1;
             break;
     }
 }