Esempio n. 1
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;
}
Esempio n. 2
0
int XXp1(char *arg)
{
    int i, result;
    char buffer[20];
    int  msgNum = 0;

    USLOSS_Console("\nXXp1(): started\n");

    for (i = 0; i < 8; i++) {
        USLOSS_Console("\nXXp1(): conditionally sending message #%d ", msgNum);
        USLOSS_Console("to mailbox %d\n", mbox_id);
        sprintf(buffer, "hello there, #%d", msgNum);
        result = MboxCondSend(mbox_id, buffer, strlen(buffer)+1);
        USLOSS_Console("XXp1(): after conditional send of message ");
        USLOSS_Console("#%d, result = %d\n", msgNum, result);
        msgNum++;
    }

    MboxReceive(pause_mbox, NULL, 0); // should block on mail box

    for (i = 0; i < 8; i++) {
        USLOSS_Console("\nXXp1(): conditionally sending message #%d ", msgNum);
        USLOSS_Console("to mailbox %d\n", mbox_id);
        sprintf(buffer, "good-bye, #%d", i);
        result = MboxCondSend(mbox_id, buffer, strlen(buffer)+1);
        USLOSS_Console("XXp1(): after conditional send of message ");
        USLOSS_Console("#%d, result = %d\n", msgNum, result);
        msgNum++;
    }

    quit(-3);
    return 0; /* so gcc will not complain about its absence... */
} /* XXp1 */
Esempio n. 3
0
int Child1(char *arg)
{
    int result;

    USLOSS_Console("\n%s(): starting, blocking on a mailbox receive\n", arg);
    result = MboxReceive(mailbox, NULL, 0);
    USLOSS_Console("%s(): result = %d\n", arg, result);

    return 1;
} /* Child1 */
Esempio n. 4
0
int XXp2(char *arg)
{
    int result;
    char buffer[20];

    result = MboxReceive(mbox_id, buffer, 20);
    USLOSS_Console("%s(): after recv of message '%s', result = %d\n",
           arg, buffer, result);

    if (result == -3)
        USLOSS_Console("%s(): zap'd by MboxReceive() call\n", arg);

    quit(-3);
    return 0;

} /* XXp2 */
Esempio n. 5
0
int XXp2(char *arg)
{
    char buffer[100];
    int i, result;

    USLOSS_Console("XXp2(): started\n");

    for (i = 0; i <= 1; i++) {
        USLOSS_Console("XXp2(): receiving message #%d from mailbox %d\n", i, mbox_id);
        result = MboxReceive(mbox_id, buffer, 100);
        USLOSS_Console("XXp2(): after receipt of message #%d, result = %d\n", i, result);
        USLOSS_Console("        message = `%s'\n", buffer);
    }

    quit(-4);
    return 0;
} /* XXp2 */
Esempio n. 6
0
int XXp2(char *arg)
{
    int result;
    char buffer[20];

    USLOSS_Console("%s(): receiving message from mailbox %d, msg_size = %d\n",
                   arg, mbox_id, strlen(buffer)+1);
    result = MboxReceive(mbox_id, buffer, strlen(buffer)+1);
    USLOSS_Console("%s(): after receive of message, result = %d\n",
                   arg, result);

    if (result == -3)
        USLOSS_Console("%s(): zap'd by MboxReceive() call\n", arg);

    quit(-3);
    return 0;

} /* XXp2 */