OperatingSystem::OperatingSystem() { lastProcessId_ = 0; addLibrary("kernel32.dll"); addLibrary("openAL32.dll"); addLibrary("foundation.dll"); addProcess("explorer.exe"); addProcess("winlogon.exe"); addProcess("taskeng.exe"); addProcess("test.exe"); /*auto proc = processes_[1]; proc->createNewThread(); proc->createNewThread(); proc->loadLibrary(getLibraryByName("kernel32.dll")); proc->killThread(2); if (!proc->killThread(0)) { delete proc; processes_.erase(1); } killProcess("test.exe");*/ // <--- ето работаит auto proc = processes_[0]; proc->loadLibrary(getLibraryByName("kernel32.dll")); deleteLibrary("kernel32.dll"); }
void test_adds_process_that_have_high_priority_rather_than_first(){ Schedular expected = {NULL,0}; Status status = {0,1,0}; Process sublime = {"sublime",3000,status,7,NULL}; Process browser = {"browser",900,status,1,NULL}; Schedular* pSchedular = create(); ASSERT(1 == addProcess(pSchedular, &sublime,compareInt)); ASSERT(2 == addProcess(pSchedular, &browser,compareInt)); ASSERT(pSchedular -> front == &browser); ASSERT(pSchedular -> front->next == &sublime); };
void test_removes_the_last_process_from_the_schedular(){ Status status = {0,1,0}; Process browser = {"browser",1000,status,1,NULL}; Process paint = {"paint",10,status,5,NULL}; Process taskManager = {"taskManager",0,status,7,NULL}; Schedular* pSchedular = create(); addProcess(pSchedular, &browser,compareInt); addProcess(pSchedular, &paint,compareInt); addProcess(pSchedular, &taskManager,compareInt); ASSERT(2 == removeProcess(pSchedular)); ASSERT(pSchedular -> front->next->next == NULL); };
void test_adds_a_new_process_into_Scheduler_according_to_its_priority(){ Process* process1 = generateProcess("Mozila", 50, 2); Process* process2 = generateProcess("chrome", 100, 1); Queue_element* element; scheduler = createScheduler(); addProcess(scheduler, process1); addProcess(scheduler, process2); element = (Queue_element*)scheduler->head->data; ASSERT(areProcessEqual(*process2, *(Process*)element->data)); element = (Queue_element*)scheduler->head->next->data; ASSERT(areProcessEqual(*process1, *(Process*)element->data)); }
// // main - The simulator's main routine // int main(int argc, char **argv){ int processes[14]; init(); int i; for(i=0;i<10;i++){ processes[i]=100; int priority = i%4; printf("Scheduled Process: %d, Priority:%d\n", i, priority); PCB* proc = (PCB *) malloc(sizeof(PCB)); proc->pid = i; proc->priority=priority; addProcess(proc); } PCB* process = NULL; int count = 0; int time = 0; while(hasProcess()){ process = nextProcess(&time); if(!process){ printf("NULL Process, something went wrong in your code.\n"); exit(1); } for(;time>0;time--){ printf("Process %d executed\n", process->pid); processes[process->pid]--; if(processes[process->pid]<0){ printf("Process %d Finished\n", process->pid); } count++; } if(processes[process->pid]>=0){ addProcess(process); } if(count==400){ for(;i<14;i++){ processes[i]=100; int priority = i%4; printf("Scheduled Process: %d, Priority:%d\n", i, priority); PCB* proc = (PCB *) malloc(sizeof(PCB)); proc->pid = i; proc->priority=priority; addProcess(proc); } } } exit(0); //control never reaches here }
// // main - The simulator's main routine // int main(int argc, char **argv){ int processes[10]; init(); int i; for(i=0;i<10;i++){ processes[i]=100; printf("Scheduled Process: %d\n", i); addProcess(i); } int process = 0; while(hasProcess()){ process = nextProcess(); for(;;){ printf("Process %d executed\n", process); processes[process]--; if(processes[process]<0){ printf("Process %d Finished\n", process); break; } } } exit(0); //control never reaches here }
void test_adds_a_high_priority_process_first_in_the_list(){ Process* processes = malloc(sizeof(Process)*2); Node* result; strcpy(processes[0].name, "chrome"); processes[0].priority = 2;processes[0].runTime = 40; strcpy(processes[1].name, "mozila"); processes[1].priority = 1;processes[1].runTime = 20; process_list = create(); addProcess(process_list, &processes[0]); ASSERT(areProcessesEqual(processes[0], *(Process*)process_list->head->data)); ASSERT(1 == process_list->length); addProcess(process_list, &processes[1]); ASSERT(areProcessesEqual(processes[1], *(Process*)process_list->head->data)); ASSERT(areProcessesEqual(processes[0], *(Process*)process_list->head->next->data)); ASSERT(2 == process_list->length); };
/*Diese Methode ist fuer das eigentliche schedulen einr Methode zustaendig die die angegebene Signatur hat.Als Argumente erhaelt sie einen Zeiger auf die verkettete Prozessliste,die auszufuehrenden Prozess und einen Zeiger auf die auszufuehrende Funktion */ void schedule(LINK head,int processes[PMAX][2] ,LINK (*sAlgo) (LINK,LINK,int)) { LINK current=head; int nextPrcs=0; int tStep=0;//aktueller Zeitschritt,der nach jeder Iteration erhoeht wird /*Fuehre das scheduling durch,solange noch Prozesse kommen werden oder noch Prozesse laufen */ while(nextPrcs<PMAX||head->next!=head) { if(current==head) current=current->next; /*Hole alle Prozesse ab,die im aktuellen Zeitschritt starten*/ while((nextPrcs<PMAX)&&(processes[nextPrcs][0]==tStep)) { addProcess(head,processes[nextPrcs][1],processes[nextPrcs][0],nextPrcs); if(current==head) current=head->prev; nextPrcs++; } if(current!=head) current=sAlgo(head,current,tStep); tStep++; usleep(TINT); } }
/** * Complete add process method. Adds tree node, sets * properties, adds edge to parent. */ bool ProcessTree::addConnectProcesses( pid_t pid, ProcessMap & procMap ) { /// Lock boost::recursive_mutex::scoped_lock lock(m_accessMutex); // Add this process ProcId newProc; // Invalid PID? if( !addProcess( pid, procMap, newProc ) ) { return false; } // For special pid 0 it is all done // Don't add any edge connected to any parent if( 0 == m_procTreeGraph[newProc].pid ) { return true; } // If parent does not exist in graph, add him first pid_t ppid = m_procTreeGraph[ newProc ].ppid; if( 0 == m_pidToIdMap.count(ppid) ) { addConnectProcesses(ppid, procMap); } // Add edge parent -> newProc add_edge(m_pidToIdMap[ppid], newProc, m_procTreeGraph); return true; }
GuiEditBoundaryConditions::GuiEditBoundaryConditions() { connect(m_Ui.pushButtonAdd, SIGNAL(clicked()), this, SLOT(addVol())); connect(m_Ui.pushButtonDelete, SIGNAL(clicked()), this, SLOT(delVol())); connect(m_Ui.pushButtonAddBoundaryType, SIGNAL(clicked()), this, SLOT(addBoundaryType())); connect(m_Ui.pushButtonDeleteBoundaryType, SIGNAL(clicked()), this, SLOT(deleteBoundaryType())); connect(m_Ui.listWidgetBoundaryType, SIGNAL(itemSelectionChanged()), this, SLOT(changePhysicalValues())); connect(m_Ui.pushButton_AddProcess, SIGNAL(clicked()), this, SLOT(addProcess())); connect(m_Ui.pushButton_RemoveProcess, SIGNAL(clicked()), this, SLOT(deleteProcess())); connect(m_Ui.pushButton_ImportHostFile, SIGNAL(clicked()), this, SLOT(importHostFile())); connect(m_Ui.pushButton_ExportHostFile, SIGNAL(clicked()), this, SLOT(exportHostFile())); connect(m_Ui.pushButtonAllA, SIGNAL(clicked()), this, SLOT(allA())); connect(m_Ui.pushButtonAllB, SIGNAL(clicked()), this, SLOT(allB())); connect(m_Ui.pushButtonAllOff, SIGNAL(clicked()), this, SLOT(allOff())); setupSolvers(); loadMpiParameters(); m_BcMap = NULL; delegate = new GuiVolumeDelegate(); delegate->setFirstCol(3); //set initial tab m_Ui.tabWidget->setCurrentIndex(0); }
/* Allocate this many bytes to a process with pid. Return 0 if external fragementation occured, -1 if insufficient memory or process is already defined, or 1 if successful*/ int allocate(int bytes, int pid) { if(bytes > (totalBytes - allocatedBytes)) //not enough memory { fprintf(stderr, "Error: Insufficient Memory, cannot allocate space for process %d\n", pid); return -1; } if(isProcessDefined(pid)) //process is already defined { fprintf(stderr, "Error: Process %d already defined\n", pid); return -1; } //Find the best fitting hole Hole * bestFit; if(bytes > midPoint -> size) //need to go right bestFit = traverseRight(bytes, pid); else bestFit = traverseLeft(bytes, pid); //need to go left if(bestFit == NULL) { fprintf(stderr, "Error: External Fragmentation occured\n"); return 0; } //no external fragmentation and process has a hole to fit into, add to process chain addProcess(bestFit, bytes, pid); //reorganized the holes so that they are sorted in ascending order, may need to move bestFit in the chain sortHoles(bestFit, bytes); return 0; }
int waitDevice(int type, int unit, int *status) { mailbox *mbox; switch (type) { case USLOSS_CLOCK_DEV : mbox = &clockBox; break; case USLOSS_DISK_INT : mbox = &diskBoxes[unit]; break; case USLOSS_TERM_INT : mbox = &termBoxes[unit]; break; } if (debugflag2 && DEBUG2) { USLOSS_Console("waitDevice(): receiving from %d\n", mbox->mboxID); } //notify p1.c that there is another process waiting on a device, then receive/block addProcess(); MboxReceive(mbox->mboxID, status, sizeof(long)); releaseProcess(); if (debugflag2 && DEBUG2) { USLOSS_Console("waitDevice(): received %s from mailbox %d\n", status, mbox->mboxID); } if (isZapped()) { return -1; } return 0; }
void AgentThread::processCMDSTART_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing CMDSTART_REQUEST\n"); // read the serialized TestObject which we will execute TestObject *test = new TestObject(); test->readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // execute the test ExecProcess *startedProcess = addProcess(new ExecProcess(test, debugLevel, showOutput)); startedProcess->run(); ConsoleServer::debugMsg(1, "Added pid %d to process pool (total %d processes)\n", startedProcess->getPid(), getProcessCount()); // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } catch (char *message) { ConsoleServer::debugMsg(1,"Error processing CMDSTART_REQUEST execute request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
void test_removes_the_only_process_in_schedular(){ Status status = {0,1,0}; Process browser = {"browser",0,status,5,NULL}; Schedular* pSchedular = create(); addProcess(pSchedular, &browser,compareInt); ASSERT(0 == removeProcess(pSchedular)); ASSERT(NULL == pSchedular -> front); };
void test_executes_processes_of_available_in_scheduler(){ Process* process1 = generateProcess("Mozila", 50, 5); Process* expected1 = generateProcess("Mozila", 0, 5); Process* process2 = generateProcess("chrome", 100, 3); Process* expected2 = generateProcess("chrome", 0, 3); Queue_element* element; scheduler = createScheduler(); addProcess(scheduler, process1); addProcess(scheduler, process2); executeProcess(scheduler, 10); element = (Queue_element*)scheduler->head->data; ASSERT(areProcessEqual(*expected2, *(Process*)element->data)); element = (Queue_element*)scheduler->head->next->data; ASSERT(areProcessEqual(*expected1, *(Process*)element->data)); free(expected1); free(expected2); }
void test_adds_a_process_to_the_process_list(){ Process* newProcess = malloc(sizeof(Process)); strcpy(newProcess->name, "chrome"); newProcess->priority = 1;newProcess->runTime = 20; process_list = create(); addProcess(process_list, newProcess); ASSERT(areProcessesEqual(*newProcess, *(Process*)process_list->head->data)); ASSERT(1 == process_list->length); }
void NewProcessDialog::accept() { ProcessInfo* info = new ProcessInfo(); info->setProcessType(static_cast<FiniteElement::ProcessType>(this->processTypeBox->currentIndex() + 1)); info->setProcessPrimaryVariable(static_cast<FiniteElement::PrimaryVariable>(this->pvTypeBox->currentIndex() + 1)); emit addProcess(info); this->done(QDialog::Accepted); }
void test_adds_front_process(){ Schedular expected = {NULL,0}; Status status = {0,1,0}; Process sublime = {"sublime",3000,status,10,NULL}; Schedular* pSchedular = create(); ASSERT(1 == addProcess(pSchedular, &sublime,compareInt)); ASSERT(pSchedular -> front == &sublime); ASSERT(pSchedular -> front->next == NULL); };
void test_adds_process_with_priority_in_between_process_queue(){ Schedular expected = {NULL,0}; Status status = {0,1,0}; Process *_2,*_3; Process sublime = {"sublime",3000,status,7,NULL}; Process browser = {"browser",900,status,1,NULL}; Process paint = {"paint",400,status,2,NULL}; Schedular* pSchedular = create(); ASSERT(1 == addProcess(pSchedular, &sublime,compareInt)); ASSERT(2 == addProcess(pSchedular, &browser,compareInt)); ASSERT(3 == addProcess(pSchedular, &paint,compareInt)); ASSERT(pSchedular -> front == &browser); _2 = pSchedular -> front->next; _3 = _2->next; ASSERT(_2 == &paint); ASSERT(_3 == &sublime); ASSERT(_3->next == NULL); };
ConstraintModel::ConstraintModel( const ConstraintModel& source, const id_type<ConstraintModel>& id, QObject* parent): IdentifiedObject<ConstraintModel> {id, "ConstraintModel", parent}, pluginModelList{source.pluginModelList, this} { metadata = source.metadata; // consistency = source.consistency; // TODO : no necessary because it should be compute m_startState = source.startState(); m_endState = source.endState(); m_defaultDuration = source.defaultDuration(); m_minDuration = source.minDuration(); m_maxDuration = source.maxDuration(); m_startDate = source.m_startDate; m_heightPercentage = source.heightPercentage(); // For an explanation of this, see CopyConstraintContent command std::map<const ProcessModel*, ProcessModel*> processPairs; // Clone the processes for(const auto& process : source.processes()) { auto newproc = process->clone(process->id(), this); processPairs.insert(std::make_pair(process, newproc)); addProcess(newproc); // We don't need to resize them since the new constraint will have the same duration. } for(const auto& rack : source.racks()) { addRack(new RackModel { *rack, rack->id(), [&] (const SlotModel& source, SlotModel& target) { for(auto& lm : source.layerModels()) { // We can safely reuse the same id since it's in a different slot. auto proc = processPairs[&lm->sharedProcessModel()]; // TODO harmonize the order of parameters (source first, then new id) target.addLayerModel(proc->cloneLayer(lm->id(), *lm, &target)); } }, this}); } // NOTE : we do not copy the view models on which this constraint does not have ownership, // this is the job of a command. // However, the full view constraint must be copied since we have ownership of it. m_fullViewModel = source.fullView()->clone(source.fullView()->id(), *this, this); }
void test_adds_a_new_process_into_Scheduler(){ Process* process = generateProcess("Mozila", 10, 1); int result; Queue_element* element; scheduler = createScheduler(); result = addProcess(scheduler, process); ASSERT(1 == result); element = (Queue_element*)scheduler->head->data; ASSERT(areProcessEqual(*process, *(Process*)element->data)); }
Process *startRunProcess(Process *process, int priority) { if (process!=null && (*process).status == STATUS_PROCESS_USING) { if (priority>0) { (*process).priority = priority; } addProcess(process); } return process; }
void test_adds_process_with_lowest_priority(){ Status status = {0,1,0}; Process *_2,*_3,*_4,*_5; Process browser = {"browser",1000,status,5,NULL}; Process paint = {"paint",500,status,1,NULL}; Process taskManager = {"taskManager",400,status,3,NULL}; Process sublime = {"sublime",400,status,2,NULL}; Process git = {"git",400,status,8,NULL}; Schedular* pSchedular = create(); ASSERT(1 == addProcess(pSchedular, &browser,compareInt)); ASSERT(2 == addProcess(pSchedular, &paint,compareInt)); ASSERT(3 == addProcess(pSchedular, &taskManager,compareInt)); ASSERT(4 == addProcess(pSchedular, &sublime,compareInt)); ASSERT(5 == addProcess(pSchedular, &git,compareInt)); _2 = pSchedular -> front->next; _3 = _2->next; _4 = _3->next; _5 = _4->next; ASSERT(_5 == &git); ASSERT(NULL == _5->next); };
TDV_NAMESPACE_BEGIN void ArrayProcessGroup::addProcess(Process **procs) { size_t procCount = 0; while ( procs[procCount] != NULL ) { addProcess(procs[procCount]); procCount++; } }
int read_proc(char *buf,char **start,off_t offset,int count,int *eof,void *data ) { char outputBuffer[1001]; int len = 0; struct processInfo* curProcess; struct threadInfo* curThread; if(DEBUG) printk("Entering read_proc\n"); if (offset>0){ return 0; } //Find if current process exists; if not create it curProcess = findProcess(current); // if (DEBUG) curProcess = headProcess; // if (DEBUG) current->pid = headProcess->headThread->pid; if (curProcess==NULL){ if(DEBUG) printk("current process does not exist\n"); curProcess=addProcess(current); curProcess->seed = A_PRNG; if(DEBUG) printk("numThreads:%lu", curProcess->numThreads); }else{ printk("Process already exists. Process not being reseeded"); } //Find if current thread exists; if not create it curThread = findThread(curProcess,current); if (curThread==NULL){ if(DEBUG) printk("creating curret thread\n"); curThread=addThread(curProcess,current); } len = sprintf(outputBuffer, "%ld\n", curThread->nextRandom); if(DEBUG) printk("nextRandom: %lu\n",curThread->nextRandom); curThread->nextRandom = nextRandomGen(curThread->nextRandom, curProcess->numThreads); if (DEBUG) printk("nextnextRandom %lu\n", curThread->nextRandom); if (DEBUG) printk("thread %d\n", curThread->pid); memcpy(buf, outputBuffer, len); /*if()){*/ /*if(DEBUG) printk("copy to user failed\n");*/ /*return -EFAULT; */ /*}*/ *eof = 1; if(DEBUG) printk("Leaving read_proc\n"); return len; }
int main() { srand(time(0)); Process* arrivalQueue = randomProcessQueue(PROCESS_COUNT); sortProcessesByArrival(arrivalQueue, 0, PROCESS_COUNT - 1); Process* readyQueue = (Process*) malloc(PROCESS_COUNT * sizeof(Process)); int i = 0, size = 0; int shortestProcessIndex = 0; int currentProcessIndex = 0; bool okToEnd = false; Record record = newRecord(); while(!okToEnd) { Timeslice* timeslice = (Timeslice*) malloc(sizeof(Timeslice)); (*timeslice).index = i; updateReadyQueue(arrivalQueue, readyQueue, i, &size); findShortestProcessIndex(readyQueue, &shortestProcessIndex, size); if(size > 0 && (readyQueue[shortestProcessIndex].timeRemaining > 0)) { (*timeslice).pid = (char) (65 + shortestProcessIndex); readyQueue[shortestProcessIndex].id = (*timeslice).pid; if(readyQueue[shortestProcessIndex].runtime == readyQueue[shortestProcessIndex].timeRemaining) { readyQueue[shortestProcessIndex].responseTime = ((float) i) - readyQueue[shortestProcessIndex].arrival; } readyQueue[shortestProcessIndex].timeRemaining = readyQueue[shortestProcessIndex].timeRemaining - 1.0f; int j; for(j = 0; j < size; j++) { if(j != shortestProcessIndex) readyQueue[j].waitTime += 1.0f; } if(readyQueue[shortestProcessIndex].timeRemaining <= 0) { readyQueue[shortestProcessIndex].timeFinished = i + 1; readyQueue[shortestProcessIndex].turnaroundTime = ((float) i + 1) - readyQueue[shortestProcessIndex].arrival + readyQueue[shortestProcessIndex].timeRemaining; addProcess(&record, readyQueue[shortestProcessIndex]); if(i >= SIMULATION_LENGTH) { okToEnd = true; } } } else { (*timeslice).pid = '-'; } addTimeslice(&record, (*timeslice)); i++; } printRecord(record); return 0; }
void CDlgDebug::UpdateData() { WORD address = m_pCPU->getRegPC(); int i; for(i=0; i < 10; i++){ if(address==m_aiAddrs[i]){ m_listProcess.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); // m_listProcess.SetSelectionMark(i); break; } } // could not find the address in process list; if(i==10){ m_listProcess.DeleteAllItems(); for(i=0; i < 10; i++){ addProcess(i, address); m_aiAddrs[i] = address; address+=operators_65c02[m_pMemory->ReadMem8(address)].len; } m_listProcess.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); // m_listProcess.SetSelectionMark(0); } // redraw Flags m_flagN.RedrawWindow(); m_flagV.RedrawWindow(); m_flagX.RedrawWindow(); m_flagB.RedrawWindow(); m_flagD.RedrawWindow(); m_flagI.RedrawWindow(); m_flagZ.RedrawWindow(); m_flagC.RedrawWindow(); CString value; value.Format("$%04X", m_pCPU->getRegPC()); m_listRegisters.SetItemText(0, 1, value); value.Format("$%02X", m_pCPU->m_regA); m_listRegisters.SetItemText(1, 1, value); value.Format("$%02X", m_pCPU->m_regX); m_listRegisters.SetItemText(2, 1, value); value.Format("$%02X", m_pCPU->m_regY); m_listRegisters.SetItemText(3, 1, value); value.Format("$%02X", m_pCPU->m_regS); m_listRegisters.SetItemText(4, 1, value); value.Format("$%02X", m_pCPU->m_regF); m_listRegisters.SetItemText(5, 1, value); }
int main(int argc, char *argv[]) { short int nport=4000; // nport num port utilisé pour la connexion int ecoute; // Descripteur de la socket d'ecoute char *ufname, uxml[SIZE]; ufname = (char*)malloc(sizeof "users"); strcpy(ufname,"users"); /* Lecture des arguments de la commande */ #ifdef DEBUG printf("======= Lecture ======"); #endif // On verifie que le arguments sont bons if((analyseArg(argc,argv,&nport,ufname))==-1) {display_right_syntax(); return -1;} // Test sur l'ouverture du fichier des logins if((users = fopen(ufname,"r"))==NULL) {perror("Echec fopen:"); return -1;} #ifdef DEBUG printf("======= Fin Lecture ======"); #endif /* Creation du process */ printf("Entrez le nom du fichier à parser:"); scanf("%s",uxml); if(addProcess(&t_process, uxml)!=0) {printf("Erreur de parsing fichier %s",uxml); return -1;} /* Initialisation du serveur */ ecoute = initialisationServeur(&nport); /* Lancement de la boucle d'ecoute */ //if(boucleServeur(ecoute,dummy,gestionClient)==-1) perror("Echec serveur"); if(boucleServeur(ecoute,lanceClientLeger,gestionClient)==-1) {perror("Echec serveur"); return -1;} fclose(users); free(ufname); return 0; }
/* Creates a new process and runs the program specified by args[0] */ void newProcess(char * const *args, int terminalPid) { int pid; struct timespec tm; M_LOCK(&mutexRunningProcesses); while(runningProcesses==MAXPAR) { C_WAIT(&condFreeSlots, &mutexRunningProcesses); } M_UNLOCK(&mutexRunningProcesses); pid = fork(); if (pid == 0) { signal(SIGINT, SIG_IGN); FILE * outFile; char outFileName[30]; sprintf(outFileName, "par-shell-out-%d", getpid()); unlink(outFileName); if ((outFile = fopen(outFileName, "w")) == NULL) { fprintf(stderr, "Erro a abrir ficheiro: %s\n", outFileName); exit(EXIT_FAILURE); } fflush(stdout); if ((dup2(fileno(outFile), STDOUT_FILENO)) < 0) { fprintf(stderr, "Erro a fazer dup2\n"); exit(EXIT_FAILURE); } fclose(outFile); //nao testamos pois n faz mal se nao consegirmos fechar o ficheiro execv(args[0], args); fprintf(stderr, "Erro no carregamento do programa %s\n", args[0]); exit(EXIT_FAILURE); } else if (pid == -1) { //if fork failed M_LOCK(&mutexRunningProcesses); processesWaitingToRun--; C_SIGNAL(&condRunningProcesses); M_UNLOCK(&mutexRunningProcesses); perror("Erro na criação do processo-filho:\n"); } else { //fork worked and we are in the parent process clock_gettime( CLOCK_MONOTONIC, &tm); addProcess(pid, terminalPid, tm); M_LOCK(&mutexRunningProcesses); runningProcesses++; processesWaitingToRun--; C_SIGNAL(&condRunningProcesses); M_UNLOCK(&mutexRunningProcesses); } }
//Liest die Prozesse ein und erstellt die Liste void readProcesses(LINK head) { /*TODO:implementieren*/ char linebuffer[256]; int i = 0; FILE *f = fopen("prcs.dat","r"); if(f != 0) { while(fgets(linebuffer,256,f)) { int a,b,c; if(sscanf(linebuffer,"%i,%i,%i",&a,&b,&c) == 3) { LINK h = (LINK)malloc(sizeof(PROCESS)); h->pId = a; h->aTime = b; h->sTime = c; addProcess(head,h); } } fclose(f); } }