[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


msleep Subroutine

Purpose

Puts a process to sleep when a semaphore is busy.

Library

Standard C Library (libc.a)

Syntax


#include <sys/mman.h>


int msleep (Sem)
msemaphore * Sem;

Description

The msleep subroutine puts a calling process to sleep when a semaphore is busy. The semaphore should be located in a shared memory region. Use the mmap subroutine to create the shared memory section.

All of the values in the msemaphore structure must result from a msem_init subroutine call. This call may or may not be followed by a sequence of calls to the msem_lock subroutine or the msem_unlock subroutine. If the msemaphore structure value originates in another manner, the results of the msleep subroutine are undefined.

The address of the msemaphore structure is significant. You should be careful not to modify the structure's address. If the structure contains values copied from a msemaphore structure at another address, the results of the msleep subroutine are undefined.

Parameters


Sem Points to the msemaphore structure that specifies the semaphore.

Error Codes

If the msleep subroutine is unsuccessful, the errno global variable is set to one of the following values:

EFAULT Indicates that the Sem parameter points to an invalid address or the address does not contain a valid msemaphore structure.
EINTR Indicates that the process calling the msleep subroutine was interrupted by a signal while sleeping.

Implementation Specifics

The msleep subroutine is part of the Base Operating System (BOS) Runtime calls.

Related Information

The mmap (mmap or mmap64 Subroutine) subroutine, msem_init (msem_init Subroutine) subroutine, msem_lock (msem_lock Subroutine) subroutine, msem_unlock (msem_unlock Subroutine) subroutine, mwakeup (mwakeup Subroutine) subroutine.

Understanding Memory Mapping in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]