Пример #1
0
u32int* sys_call(context *registers) {
  if (cop == NULL) {
    copContext = registers;
  }
  else {
    if (params.op_code == IDLE) {
      cop->stackTop = (u32int*)registers;
      cop->readyState = 0;
      addReady(cop);
      cop = NULL;
    }
    else if (params.op_code == EXIT) {
      FreePCB(cop);
      cop = NULL;
    }
  }
  PCB* readyUnsuspendedProcess = getNextUnsuspended();
  if (readyUnsuspendedProcess != NULL) {
    cop = readyUnsuspendedProcess;
    cop->readyState = 1;
    //serial_println(cop->name);
    return cop->stackTop;
  } else {
    return (u32int*)copContext;
  }
}
Пример #2
0
void DeleteQueue(ProcessControlBlock *head)
{
    ProcessControlBlock *tmp = head;
    while(head != NULL) {
        head = head->nextPCB;
        FreePCB(tmp);
        tmp = head;
    }
}
Пример #3
0
void	RemoveLinkedList(ProcessControlBlock *head)
{
    ProcessControlBlock *tmp = head;
    while(head!=NULL) {
        head = head->nextPCB;
        FreePCB(tmp);
    }

    return;
}
Пример #4
0
int removePCB(PCB* proc)
{
  PCB *delPCB;
  int readyIndex = indexByNameReady(proc->name);
  int blockedIndex = indexByNameBlocked(proc->name);
  if (readyIndex >= 0) {
    delPCB = removePCBAtIndexReady(readyIndex);
  } else if (blockedIndex >= 0) {
    delPCB = removePCBAtIndexBlocked(blockedIndex);
  } else {
    delPCB = NULL;
  }
  return FreePCB(delPCB);
}
Пример #5
0
void KillProc(PCB *pcb) {
    TracePrintf(2, "KillProc\n");

    if (1 == current_process->id) {
        TracePrintf(1, "KillProc: init program being killed. Now calling halt.\n");
        Halt();
    }

    PCB *parent = pcb->parent;

    if (parent) {
        if (parent->status == WAITING) {
            queueRemove(wait_queue, parent);
            queuePush(ready_queue, parent);
        }
        ZCB *zombie = (ZCB *) malloc(sizeof(ZCB));
        zombie->id = pcb->id;
        zombie->status = DEAD;
        zombie->exit_status = pcb->status;
        queuePush(parent->deadChildren, zombie);
        queuePush(process_queue, zombie);

    }


    for (List *child = current_process->children->head; child; child = child->next)
        ((PCB *) child->data)->parent = NULL;

    if (pcb->parent) {
        queueRemove(pcb->parent->children, pcb);
    }

    // Update process queue
    queueRemove(process_queue, pcb);



    FreePCB(pcb);
}
Пример #6
0
u32int* sys_call(context *registers) {
  if (cop == NULL) {
    copContext = registers;
  }
  else {
    if (params.op_code == IDLE) {
      cop->stackTop = (u32int*)registers;
      cop->readyState = 0;
      addReady(cop);
      cop = NULL;
    }
    else if (params.op_code == EXIT) {
      FreePCB(cop);
      cop = NULL;
    }
  }
  if (peekReady() != NULL) {
    cop = pollReady();
    cop->readyState = 1;
    return cop->stackTop;
  } else {
    return (u32int*)copContext;
  }
}
Пример #7
0
void deletePCB()
{
	serial_print("Please enter the name of the process to delete: ");
	char* name = polling();
	PCB* target = findPCB(name);
	if(target == NULL)
	{
		if(strlen(name) == 0) {
			serial_print("Process not found: \"");
			serial_print(name);
			serial_println("\" does not appear to exist");
		}
	}
	else
	{
		int readyIndex = indexByNameReady(name);
		int blockedIndex = indexByNameBlocked(name);
		PCB* removedPCB = NULL;
		if (readyIndex >- 0) {
			removedPCB = removePCBAtIndexReady(readyIndex);
		} else {
			removedPCB = removePCBAtIndexBlocked(blockedIndex);
		}
		FreePCB(removedPCB);
		// if (!FreePCB(removedPCB)) {
			serial_print("The process \"");
			serial_print(name);
			serial_print("\" has been deleted successfully");
		// } else {
		//	serial_print("An error occurred while attempting to remove the process \"");
		//	serial_print(name);
		//	serial_println("\"");
		//}
	}
	serial_println("");
}