common.c revision 00c76d6fcc0e3d5821ed5ac5165f1835f8151454
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" * Sleep until *wakeup + interval, keeping cadence where desired * *wakeup - The time we last wanted to wake up. Updated. * interval - We want to sleep until *wakeup + interval * forever - Running for infinite periods, so cadence not important * *caught_cont - Global set by signal handler if we got a SIGCONT /* Reset our cadence (see comment below) */ * If we got here, then the time between the * output we just did, and the scheduled time * for the next output is < 1/4 of our requested * interval AND the number of intervals has been * requested AND we have never caught a SIGCONT * (so we have never been suspended). In this * case, we'll try to stay to the desired * cadence, and we will pause for 1/2 the normal /* Now do the actual sleep */ fail(
1,
"nanosleep failed");
* Signal handler - so we can be aware of SIGCONT /* Re-set the signal handler */