]>
Commit | Line | Data |
---|---|---|
9bccf70c | 1 | <h2>semaphore_create</h2>\r<hr>\r<p>\r<strong>Function</strong> - Create a new semaphore.\r<h3>SYNOPSIS</h3>\r<pre>\r<strong>kern_return_t semaphore_create</strong>\r <strong>(task_t</strong> <var>task</var>,\r <strong>semaphore_t</strong> <var>*semaphore</var>,\r <strong>int</strong> <var>policy</var>,\r <strong>int</strong> <var>value</var><strong>);</strong>\r</pre>\r<h3>PARAMETERS</h3>\r<dl>\r<dt> <var>task</var>\r<dd>\r[in task port] The task receiving the send right of the newly created semaphore.\r<p>\r<dt> <var>semaphore</var>\r<dd>\r[out send right] The port naming the created semaphore.\r<p>\r<dt> <var>policy</var>\r<dd>\r[in scalar] The blocked thread wakeup policy for the newly created semaphore. Valid policies are:\r<dl>\r<p>\r <dt> SYNC_POLICY_FIFO\r<dd>\ra first-in-first-out policy for scheduling thread wakeup.\r <p>\r <dt> SYNC_POLICY_FIXED_PRIORITY\r<dd>\ra fixed priority policy for scheduling thread wakeup.\r </dl>\r <p>\r<dt> <var>value</var>\r<dd>\r[in scalar] The initial value of the semaphore count.\r</dl>\r<h3>DESCRIPTION</h3>\r<p>\rThe <strong>semaphore_create</strong> function creates a new semaphore, associates the\rcreated semaphore with the specified task, and returns a send right\rnaming the new semaphore. In order to support a robust\rproducer/consumer communication service, Interrupt Service Routines\r(ISR) must be able to signal semaphores. The semaphore synchronizer\rservice is designed to allow user-level device drivers to perform\rsignal operations, eliminating the need for event counters. Device\rdrivers which utilize semaphores are responsible for creating (via\r<strong>semaphore_create</strong>) and exporting (via <strong>device_get_status</strong>)\rsemaphores for\ruser level access. Device driver semaphore creation is done at device\rinitialization time. Device drivers may support multiple semaphores.\r<h3>RETURN VALUES</h3>\r<dl>\r <p>\r<dt> <strong>KERN_INVALID_ARGUMENT</strong>\r<dd>\rThe task argument or the policy argument was invalid,\r or the initial value of the semaphore was invalid.\r <p>\r<dt> <strong>KERN_RESOURCE_SHORTAGE</strong>\r<dd>\rThe kernel could not allocate the semaphore.\r <p>\r<dt> <strong>KERN_SUCCESS</strong>\r<dd>\rThe semaphore was successfully created.\r</dl>\r<h3>RELATED INFORMATION</h3>\r<p>\rFunctions:\r<a href="semaphore_destroy.html"><strong>semaphore_destroy</strong></a>,\r<a href="semaphore_signal.html"><strong>semaphore_signal</strong></a>,\r<a href="semaphore_signal_all.html"><strong>semaphore_signal_all</strong></a>,\r<a href="semaphore_wait.html"><strong>semaphore_wait</strong></a>,\r<a href="device_get_status.html"><strong>device_get_status</strong></a>.\r |