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 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Check to see if anyone is waiting for this semaphore. 2N/A * This should be at the beginning of the function, 2N/A * but for the sake of old broken applications that 2N/A * do not have proper alignment for their semaphores 2N/A * (and don't check the return code from sema_init), 2N/A * we put it here, after initializing the semaphore regardless. 2N/A * All variations of sema_wait() are cancellation points. 2N/A /* just a guess, but it looks like we will sleep */ 2N/A else /* we changed our mind */ 2N/A /* the kernel always does FIFO queueing */ 2N/A * Since we are single-threaded, we don't need the 2N/A * protection of queue_lock(). However, we do need 2N/A * to block signals while modifying the count. 2N/A }
else {
/* multithreaded or blocking */ 2N/A * SUSV3 requires FIFO queueing for semaphores, 2N/A * at least for SCHED_FIFO and SCHED_RR scheduling. 2N/A * We may have received SIGCANCEL before we 2N/A * called queue_lock(). If so and we are 2N/A * cancelable we should return EINTR. 2N/A /* we just decremented the count */ 2N/A }
else {
/* multithreaded */ 2N/A /* we just decremented the count */ 2N/A }
else {
/* multithreaded */ 2N/A /* we just incremented the count */