Пример #1
0
ChatMessageDelegate::ChatMessageDelegate(QObject *parent) :
    QItemDelegate(parent)
{
    m_parent = (ChatMessageView* )parent;
    connect(&m_timerCheck, SIGNAL(timeout()), this, SLOT(timerCheck()));
    m_timerCheck.start(1000);
    setClipping(false);
    m_createInRealTime = false;
    //m_createInRealTime = true;
}
Пример #2
0
void cpu() {
	genProcesses();

		printf("\r\nBegin Simulation:\r\n\r\n");

		int simCounter = 0;

		while (simCounter <= SIMULATION_END) {

			//check for timer interrupt, if so, call timerISR()
			if (timerCheck() == 1) {
				//printf("Timer interrupt: PID %d was running, ", PCBGetID(currProcess));
//				if (PCBGetState(currProcess) != terminated) {
				genProcesses();
				if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) {
					printf("Timer interrupt: PID %d was running, ", PCBGetID(currProcess));
				} else {
					printf("Timer interrupt: no current process is running, ");
				}

				timerIsr();
			}

/****Checking for IO interrupts*****/
			//check if there has been an IO interrupt, if so call appropriate ioISR
			if (checkIOInterrupt(device1) == 1) {
				if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) {
					printf("I/O 1 Completion interrupt: PID %d is running, ", PCBGetID(currProcess));
				} else {
					printf("I/O 1 Completion interrupt: no current process is running, ");
				}
				//call the IO service routine
				IO_ISR(1);
			}

			if (checkIOInterrupt(device2) == 1) {
				if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/) {
					printf("I/O 1 Completion interrupt: PID %d is running, ", PCBGetID(currProcess));
				} else {
					printf("I/O 1 Completion interrupt: no current process is running.");
				}
				//call the IO service routine
				IO_ISR(2);
			}

			//check the current process's PC, if it is MAX_PC, set to 0 and increment TERM_COUNT
			if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/
					&& sysStackPC >= PCBGetMaxPC(currProcess)) {
				PCBSetTermCount(currProcess, PCBGetTermCount(currProcess) + 1);
				printf("\r\n");
				//if TERM_COUNT = TERMINATE, then call terminateISR to put this process in the terminated list
				if (PCBGetTermCount(currProcess) == PCBGetTerminate(currProcess)) {

					terminateIsr();
					continue;	//currProcess has been terminated, we don't want to execute the rest of the loop, instead jump to next iteration
				}
				//PCBSetPC(currProcess, 0);
				sysStackPC = 0;
			}

			sysStackPC++;

/***Checking traps*****/
			if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/
					&& checkIORequest(1) != 0) {
				printf("I/O trap request: I/O device 1, ");
				IOTrapHandler(device1);
			}

			if (currProcess/*PCBGetState(currProcess) != blocked && PCBGetState(currProcess) != terminated*/
					&& checkIORequest(2) != 0) {
				printf("I/O trap request: I/O device 2, ");
				IOTrapHandler(device2);
			}


			//at end
			simCounter++;
		}
}