示例#1
0
/** 
 * Execute the PAUSE command to pause.
 *    The command sends a message to the terminal and then pauses 
 *    and waits for a return message
 * 
 * @param nerr 
 *    Error Return Flag
 *    - 0 on Success
 *
 * @date   860925:  Added PERIOD option.
 * @date   840206:  Original version.
 *
 */
void 
xpause(int *nerr) {

	char kret[9];
	int nc;
	double fperio;

	*nerr = 0;
    fperio = cmexm.nperio / 1000.0;
	while ( lcmore( nerr ) ){

		/* -- "PERIOD ON|OFF|v":  set period of time to pause. */
		if( lklogr( "PERIOD$",8, &cmexm.lperio, &fperio ) ){
			cmexm.nperio = (int)( 1000.0*fperio );
			if( cmexm.nperio <= 0 )
				cmexm.lperio = FALSE;
		}

		/* -- Determine text of pause message. */
		else if( lkchar( "MESSAG$",8, MCMSG - 2, kmexm.kpause,MCMSG+1, 
		 &nc ) ){
			subscpy( kmexm.kpause, nc, -1, MCMSG, " $" );
		}

		/* -- Bad syntax. */
		else{
			cfmt( "ILLEGAL OPTION:",17 );
			cresp();
		}
	}
	if( cmexm.lperio ){
		nc = indexb( kmexm.kpause,MCMSG+1 );
		if( nc > 2 ) {
      int n = 1;
      char *p = &kmexm.kpause[0];
      while(*p && *p != '$' && n < nc-1) {
        fprintf(stdout, "%c", *p);
        p++;
        n++;
      }
      fflush(stdout);
    }
		zsleep( cmexm.nperio );
	}
	else{
		zgtmsg( kmexm.kpause,MCMSG+1, kret,9 );
	}


	return;
}
示例#2
0
static
void *
lwkt_serialize_waitport(lwkt_port_t port, int flags)
{
    lwkt_msg_t msg;
    int error;

    ASSERT_SERIALIZED(port->mpu_serialize);

    while ((msg = _lwkt_pollmsg(port)) == NULL) {
        port->mp_flags |= MSGPORTF_WAITING;
        error = zsleep(port, port->mpu_serialize, flags, "waitport", 0);
        /* see note at the top on the MSGPORTF_WAITING flag */
        if (error)
            return(NULL);
    }
    _lwkt_pullmsg(port, msg);
    return(msg);
}
示例#3
0
static
int
lwkt_serialize_waitmsg(lwkt_msg_t msg, int flags)
{
    lwkt_port_t port;
    int sentabort;
    int error;

    KASSERT((msg->ms_flags & MSGF_DROPABLE) == 0,
            ("can't wait dropable message"));

    if ((msg->ms_flags & MSGF_DONE) == 0) {
        port = msg->ms_reply_port;

        ASSERT_SERIALIZED(port->mpu_serialize);

        sentabort = 0;
        while ((msg->ms_flags & MSGF_DONE) == 0) {
            void *won;

            /*
             * If message was sent synchronously from the beginning
             * the wakeup will be on the message structure, else it
             * will be on the port structure.
             */
            if (msg->ms_flags & MSGF_SYNC) {
                won = msg;
            } else {
                won = port;
                port->mp_flags |= MSGPORTF_WAITING;
            }

            /*
             * Only messages which support abort can be interrupted.
             * We must still wait for message completion regardless.
             */
            if ((flags & PCATCH) && sentabort == 0) {
                error = zsleep(won, port->mpu_serialize, PCATCH, "waitmsg", 0);
                if (error) {
                    sentabort = error;
                    lwkt_serialize_exit(port->mpu_serialize);
                    lwkt_abortmsg(msg);
                    lwkt_serialize_enter(port->mpu_serialize);
                }
            } else {
                error = zsleep(won, port->mpu_serialize, 0, "waitmsg", 0);
            }
            /* see note at the top on the MSGPORTF_WAITING flag */
        }
        /*
         * Turn EINTR into ERESTART if the signal indicates.
         */
        if (sentabort && msg->ms_error == EINTR)
            msg->ms_error = sentabort;
        if (msg->ms_flags & MSGF_QUEUED)
            _lwkt_pullmsg(port, msg);
    } else {
        if (msg->ms_flags & MSGF_QUEUED) {
            port = msg->ms_reply_port;

            ASSERT_SERIALIZED(port->mpu_serialize);
            _lwkt_pullmsg(port, msg);
        }
    }
    return(msg->ms_error);
}