Пример #1
0
//
// Read characters from the terminals and puts them in the buffers.
// When a buffer is full verify its content against the inputs.
//
void 
term_handler(int type, void *arg) {
    int 	result;
    int 	status;
    char 	ch;
    int		unit = (int) arg;
    int     i;

    // Get the device status for the terminal.
    result = USLOSS_DeviceInput(USLOSS_TERM_DEV, unit, &status);
    if (result != USLOSS_DEV_OK) {
	   USLOSS_Console("Something is wrong with terminal %d!!", unit);
	   USLOSS_Halt(1);
    }
    // If the status is "USLOSS_DEV_BUSY" then a character has been received.
    if (USLOSS_TERM_STAT_RECV(status) == USLOSS_DEV_BUSY) {
	   ch = USLOSS_TERM_STAT_CHAR(status);	// Get the characte
	   USLOSS_Console("%d: %c\n", unit, ch);
       i = counts[unit]++;
       buffers[unit][i] = ch;
       if (i == NUMCHARS-1) {
            assert(!strncmp(inputs[unit], buffers[unit], NUMCHARS));
            done++;
        }
    }
}
Пример #2
0
static void terminalHandler(int dev, void *arg) {

    long unit = (long) arg;

    if (debugflag2 && DEBUG2) {
        USLOSS_Console("terminalHandler(): dev = %d\n", dev);
        USLOSS_Console("terminalHandler(): unit = %d\n", unit);
    }
    int termResult;

    // check for valid values
    if (dev != USLOSS_TERM_DEV || unit < 0 || unit > USLOSS_TERM_UNITS) {
        USLOSS_Console("termHandler(): Bad values\n");
        USLOSS_Halt(1);
    }

    // make sure our box still exists
    if (termBoxes[unit].mboxID == -1) {
        USLOSS_Console("Term mailbox does not exist, unit\n");
        USLOSS_Halt(1); // might need to reutn instead
    }

    int result = USLOSS_DeviceInput(USLOSS_TERM_DEV, unit, &termResult);

    // if (debugflag2 && DEBUG2) {
    //     USLOSS_Console("terminalHandler(): sending now from dev %d to mbox %d value %s\n", dev, termBoxes[unit].mboxID, termResult);
    // }
    MboxCondSend(termBoxes[unit].mboxID, &termResult, sizeof(termResult));

    if (result != USLOSS_DEV_OK) {
        USLOSS_Console("termHandler(): USLOSS_DeviceInput is not ok.\n");
        USLOSS_Halt(1);
    }
}
Пример #3
0
static void clockHandler2(int dev, void *arg) {
    long unit = (long) arg;
    int clockResult;

    // check if dispatcher should be called
    if (readCurStartTime() >= 80000) {
        timeSlice();
    }

    // inc that a clock interrupt happened
    clockTicks++;

    USLOSS_DeviceInput(dev, unit, &clockResult);

    
    // every fith interrupt do a conditional send to its mailbox
    if (clockTicks % 5 == 0) {

        if (debugflag2 && DEBUG2) {
            USLOSS_Console("clockHandler2: sending message %s to mbox %d\n", clockResult, clockBox.mboxID);
        }

        int sendResult = MboxCondSend(clockBox.mboxID, &clockResult, sizeof(clockResult));

        if (debugflag2 && DEBUG2) {
            USLOSS_Console("clockHandler2: send returned %d\n", sendResult);
            USLOSS_Halt(1);
        }
    }
}
Пример #4
0
void termHandler(int dev, void* unit)
{

   if (DEBUG2 && debugflag2)
      USLOSS_Console("termHandler(): called\n");
   int status =0;
   USLOSS_DeviceInput(dev, (int) unit, &status);
   MboxCondSend(1 + (int) unit, &status, 0);
} /* termHandler */
Пример #5
0
static void diskHandler(int dev, void *arg) {
    long unit = (long) arg;
    int diskResult;

    // check for valid values
    if (dev != USLOSS_DISK_DEV || unit < 0 || unit > USLOSS_DISK_UNITS) {
        USLOSS_Console("diskHandler(): Bad values\n");
        USLOSS_Halt(1);
    }

    // make sure our box still exists
    if (diskBoxes[unit].mboxID == -1) {
        USLOSS_Console("Disk mailbox does not exist, unit = %d\n", unit);
        USLOSS_Halt(1); // might need to reutn instead
    }

    USLOSS_DeviceInput(USLOSS_DISK_DEV, unit, &diskResult);
    MboxCondSend(diskBoxes[unit].mboxID, &diskResult, sizeof(diskResult));
}
Пример #6
0
//
// Read characters from terminal 0 and writes them to the USLOSS_Console.
//
void 
term_handler(int type, void *arg) {
    int 	result;
    int 	status;
    char 	ch;
    int		unit = (int) arg;

    if (unit != 0) {
	return;
    }
    // Get the device status for terminal 0.
    result = USLOSS_DeviceInput(USLOSS_TERM_DEV, 0, &status);
    if (result != USLOSS_DEV_OK) {
	USLOSS_Console("Something is wrong with terminal 0!!");
	USLOSS_Halt(1);
    }
    // If the status is "USLOSS_DEV_BUSY" then a character has been received.
    if (USLOSS_TERM_STAT_RECV(status) == USLOSS_DEV_BUSY) {
	ch = USLOSS_TERM_STAT_CHAR(status);	// Get the character
	USLOSS_Console("%c", ch);
    }
}