Ejemplo n.º 1
0
MainWindow::~MainWindow()
{
    delete ui;
    deleteProcess();
    if(socket_)
        socket_->deleteLater();
}
Ejemplo n.º 2
0
/*===================================================
                Class Player.
====================================================*/
Player::Player(QObject *parent)
    :QObject(parent), m_is_started(false), m_is_alive(false), m_process(NULL) {
    //Set up the QProcess deletion timer.
    m_processDeletionTimer = new QTimer(this);
    m_processDeletionTimer->setSingleShot(true);
    QObject::connect(m_processDeletionTimer, SIGNAL(timeout()), this, SLOT(deleteProcess()));
}
Ejemplo n.º 3
0
void ChildForm::runProcess()
{
    RunProcessDialog rpd(this);
    // If the process failed to start, then it
    // cannot be deleted from the processError call
    // because it may be called from within the call to
    // _proc->start()... so _proc cannot be deleted...
    if ((_proc != nullptr) && (_procError == true))
    {
        deleteProcess();
    }
    if (_proc == nullptr)
    {
        if (rpd.exec() == RunProcessDialog::Accepted)
        {
            _procError = false;
            _redirectStdout = rpd.isStdoutRedirected();
            _redirectStderr = rpd.isStderrRedirected();

            _proc = new QProcess(this);
            connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
            connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
            connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
            connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this,
                    SLOT(processDone(int,QProcess::ExitStatus)));
            _proc->setWorkingDirectory(rpd.getWorkingDirectory());
            QStringList args = rpd.getArguments();
            suppressOutput(rpd.isOutputSuppressed());
            MainWindow::getMainWindow()->swapProcessIcon(true);
            _proc->start(rpd.getProgram(), args);
        }
    }
Ejemplo n.º 4
0
static int replyHandler(ExHttp *pHttp)
{
  int rType ;
  int ret = -1 ;

  rType = checkpath( pHttp ) ;

  if ( strcmp( pHttp->method, "PUT" )==0 )
    ret = putProcess( pHttp, rType ) ;
  else if ( *pHttp->method=='D' )
    ret = deleteProcess( pHttp, rType ) ;
  else {
    switch ( rType ) {
      case 0: /* static file */
        ret = staticProcess( pHttp ) ;
        break ;
      case 1: /* dyanamic page: '.cgi' extension */
        ret = cgiProcess( pHttp ) ;
        break ;
      default:
        ex_error_reply( pHttp, rType ) ;
    }
  }
  clearHttp( pHttp ) ;
  return ret ;
}
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);
}
Ejemplo n.º 6
0
void processCleanup(void) {
    dictIterator *di = dictGetIterator(server.process);
    dictEntry *de;
    while ((de = dictNext(di)) != NULL) {
        struct ProcessInfo *p = dictGetEntryVal(de);
        if (p->time_stamp != g_time) deleteProcess(p->pid);
    }
    dictReleaseIterator(di);
}
Ejemplo n.º 7
0
void ChatSession::executeShellCommand(const QString& com) {
    //    if (!proc->isRunning()) {
    proc = new QProcess(this);
    QStringList list = QStringList::split(" ",com);
    proc->setArguments(list);
    proc->start();
    connect(proc, SIGNAL(processExited()),
            this, SLOT(deleteProcess()));
    //    }
}
Ejemplo n.º 8
0
/*Implementierung des FCFS

head:Kopfelement der Liste der Prozesse
current:aktuelles Element
tStep:aktueller Zeitschritt
*/
LINK fcfs(LINK head,LINK current,int tStep)
{
 updateProcess(current,tStep);

/*TODO: Implementieren Sie den First Come First Serve Algorithmus
		Beachten Sie den Rueckgabewert der deleteProcess Methode
*/
  if(current->sTime <= 0){
    current = deleteProcess(current);
  }

 return current;
}
Ejemplo n.º 9
0
LINK roundRobin(LINK head,LINK current,int tStep)
{
 updateProcess(current,tStep);

/*TODO: Implementieren Sie den Round Robin Algorithmus
		Unterscheiden Sie die Faelle, falls der Prozess fertig ist
		oder eben noch nicht.
*/
  //nachgucken, ob der Prozess fertig ist und falls ja loeschen
  if(current->sTime<=0){
    deleteProcess(current);
  }
  current = current->next;

 return current;
}
Ejemplo n.º 10
0
/*Implementierung des spn
head:Kopfelement der Liste der Prozesse
current:aktuelles Element
tStep:aktueller Zeitschritt
*/
LINK spn(LINK head,LINK current,int tStep)
{
 updateProcess(current,tStep);

/*TODO: Implementieren Sie die Shortest Job Next Algorithmus
		Nutzen Sie die untere Hilfsfunktion!
*/
  //ueberpruefen, ob der Prozess fertig ist
  if(current->sTime <= 0){
    deleteProcess(current);
    //nach dem naechsten kuerzesten Prozess gucken
    current = findShortestPr(head);
  }

 return current;
}
Ejemplo n.º 11
0
void MainWindow::on_create_local_server_clicked()
{
    deleteProcess();

    server_name_ = ui->server_name->text();
    if(server_name_.isEmpty())
    {
        qCritical()<<"Please input a server name";
        return;
    }
    QStringList param_list;
    param_list<<server_name_;
    process_ = new QProcess(this);
    process_->start(SERVER_BIN, param_list);
    connect(process_, SIGNAL(started()), this, SLOT(slotProcessStarted()));
    connect(process_, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(slotProcessHasError(QProcess::ProcessError)));
}
Ejemplo n.º 12
0
int main(void)
{
    LINK next = 0;
    LINK head = 0;

    /*TODO:head initialisieren*/
    head = (LINK)malloc(sizeof(PROCESS));
    head->pId = 0;
    head->next = head;
    head->prev = head;

    readProcesses(head);

    while(head->next!=head)
    {
        printList(head);
        next=findNextProcess(head);
        deleteProcess(next);
    }

    return 0;
}
Ejemplo n.º 13
0
Archivo: touchup.c Proyecto: bol/boc
/* Set up links between parents, children and siblings */
int touchupProcs () {
	struct Process *proc;
	struct Process *pproc;

	for (proc = first_process; proc->next_process; proc = proc->next_process) {
		/* Dummy process only used for finding siblings to init, like kthreadd */
		if (proc->pid == 0) {
				continue;
		}

		pproc = getProcByPid(proc->ppid);

		if (pproc) {
			addChildProc(pproc, proc);
		}
	}

	/* Siblings added, don't need the dummy anymore */
	deleteProcess(first_process);
	
	return 0;
}
Ejemplo n.º 14
0
void TgtProcessIntf::processDone(int, QProcess::ExitStatus)
{
    deleteProcess();
}
Ejemplo n.º 15
0
TgtProcessIntf::~TgtProcessIntf()
{
    tgtDisconnect();
    deleteProcess();
}
Ejemplo n.º 16
0
void
WriteHandle::deferredDeleteProcess(ProcessId processId)
{
  scheduler.schedule(PROCESS_DELETE_TIME, [=] { deleteProcess(processId); });
}
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{
    //Initialize variables to be used later
    simulatorStructure simulator;
    taskInfoBlock test;
    processControlBlock *process = NULL, *currentProcess = NULL, *tempPCB = NULL;
    interrupted = 0;
    int maxTimeProcessing = 0;
    List log;
    char logBuffer [100];
    FILE *output;
    ListNode *tempNode = NULL;
    
    // initializes log to print info to
    // log will print to file or terminal -at the end of the program- depending on the config file
    init(&log);
    
    // Check if configuration file isn't provided
    if(argc != 2) 
    {
        // Display error
        puts("Error: Invalid parameters");
        
        // End program with error
        return 1;
    }
    
    // Read into simulator configuration struct
    // Check if getting simulator configuration failed
    if(!getSimulatorConfiguration(&simulator, argv[1])) 
    {
        // Display error
        puts("Error: Invalid configuration file");
        
        // End program with error
        return 1;
    }
    
    // assign maximum allowed processing time from the simulator configuration
    maxTimeProcessing = (simulator.quantum * simulator.processorCycleTime * 1000);

    // Create process queue
    // Check if creating process queue failed
    if(!createProcessQueue(&process, simulator.processFilePath)) 
    {
        // Display error
        puts("Error: Failed to create job queue");
        
        // End program with error
        return 1;
    }
    
    // Set current process
    currentProcess = &process[0];
    
    // begin writing to log
    insert(&log, "System Start 0 (microsec)\n");
    
    // Begin Simulation Loop and go until no processes remain
    while(currentProcess != NULL)
    {
        // Set process's arrival time if not already set
        if(currentProcess->arrivalTime == 0)
        {
            currentProcess->arrivalTime = time(NULL);
        }

        // if a thread throws an interrupt
        if(interrupted == 1)
        {
            tempPCB = currentProcess;

            //search for the process whose I/O just finished
            while(tempPCB->ioInterrupted == false)
            {
                tempPCB = tempPCB->nextPCB;
            }

            //reset Finished and Interrupted so that the process can continue being processed
            tempPCB->ioFinished = true;
            tempPCB->ioInterrupted = false;

            //reset interrupt flag
            interrupted = 0;
        }

        //Process current task by busy waiting
        // if not blocked for I/O wait, continue to process next job
        if( currentProcess->ioFinished && currentProcess->currentJob < currentProcess->numberOfJobs)
        {
            // if a process has a CPU operation
            if(currentProcess->jobs[currentProcess->currentJob].operation == 'P') 
            {
                // Sleep
                //if the quantum time is less than the remaining job time, take the entire quantum
                if(simulator.quantum < currentProcess->jobs[currentProcess->currentJob].cyclesRemaining)
                {
                    //write to log
                    sprintf(logBuffer, "PID %d: CPU Process %d (microsec)", currentProcess->pid, maxTimeProcessing);
                    insert(&log, logBuffer);

                    //sleep for maximum time
                    usleep(maxTimeProcessing);
                    
                    // Subtract quantum time from process
                    currentProcess->timeRemaining -= simulator.quantum;
                    currentProcess->jobs[currentProcess->currentJob].cyclesRemaining -= simulator.quantum;
                }
                //if the quantum is greater than required time, finish the job
                else
                {
                     // write to log
                     sprintf(logBuffer, "PID %d: CPU Process %d (microsec)", currentProcess->pid, currentProcess->jobs[currentProcess->currentJob].cyclesRemaining * simulator.processorCycleTime * 1000);
                     insert(&log, logBuffer);

                     // sleep for remaining job time
                     usleep(currentProcess->jobs[currentProcess->currentJob].cyclesRemaining * simulator.processorCycleTime * 1000);
                     
                     // Subtract time run from process
                     currentProcess->timeRemaining -= currentProcess->jobs[currentProcess->currentJob].cyclesRemaining;
                     currentProcess->jobs[currentProcess->currentJob].cyclesRemaining -= currentProcess->jobs[currentProcess->currentJob].cyclesRemaining;
                }
            }

            // if a process has an I/O operation
            else
            {
                
                // output to log
                sprintf(logBuffer, "PID %d: Began %s I/O Process", currentProcess->pid, currentProcess->jobs[currentProcess->currentJob].name);
                insert(&log, logBuffer);

                // set ioFinished to false so this process will be skipped in the queue
                currentProcess->ioFinished = false;

                // write reassurance the program is working to the terminal
                printf("Working...\n");

                currentProcess->threadBeingCreated = true;

                // create thread
                threadCreate(&currentProcess, simulator, &log);

                // wait for thread to finish creating itself
                // weird errors happen to process if not made to wait for thread creation
                while(currentProcess->threadBeingCreated);

            }
        }
        
        //If the currentProcess's job is finished, delete it
        if( currentProcess->jobs[currentProcess->currentJob].cyclesRemaining <= 0 )
        {
            if(currentProcess->currentJob < currentProcess->numberOfJobs)
            {
                currentProcess->currentJob++;
            }
        }
        
        //Delete the process if it is done
        if( currentProcess->timeRemaining <= 0 && currentProcess->ioInterrupted == false && currentProcess->ioFinished == true)
        {
            sprintf(logBuffer, "PID %d: finished", currentProcess->pid);
            insert(&log, logBuffer);
            currentProcess = deleteProcess( currentProcess );  
        } 
            
        //Get the next process, context switch
        //context switches do not get printed because they happen so many times in larger processes that it takes up the entire log file
        else
        {
            setCurrentProcess(&currentProcess, simulator);
        }         
    }

    //last log output
    insert(&log, "\nSystem End 0 (microsec)");

    //Print output to monitor if specified by the configuration file
    if(strcmp(simulator.logType, "Log to Monitor") == 0 || strcmp(simulator.logType, "Log to Both") == 0)
    {
        print(&log);
    }
    
    //Print output to log file if specified by the configuration file
    if(strcmp(simulator.logType, "Log to File") == 0 || strcmp(simulator.logType, "Log to Both") == 0)
    {
        //Open the output log file
        output = fopen("Log.txt", "w");

        //Check to see that the linked list is not empty
        if(!empty(&log))
        {
            //Print the first node
            tempNode = log.head;
            fprintf(output, "%s\n", tempNode->dataItem);
    
            //Iterate through the linked list
            while(tempNode->next != 0)
            {
                //Go to the next node
                tempNode = tempNode->next;
    
                //Print the next node
                fprintf(output, "%s\n", tempNode->dataItem);
            }
        }
        
        //Close the output file
        fclose(output);
    }

    // Free memory
    free(simulator.version);
    free(simulator.processorScheduling);
    free(simulator.processFilePath);
    free(simulator.memoryType);
    free(simulator.logType);
    
    //End the program
    return 0;
}
Ejemplo n.º 18
0
void ChildForm::closeEvent(QCloseEvent*)
{
    deleteProcess();
    emit closeWindowSignal();
}
Ejemplo n.º 19
0
void TgtProcessIntf::closeEvent(QCloseEvent*)
{
    deleteProcess();
}
Ejemplo n.º 20
0
void MainWindow::slotProcessHasError(const QProcess::ProcessError & process_error)
{
    qDebug()<<"Process has error: [ error"<<process_error<<"]";
    deleteProcess();
}