| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- retrieve event information from a port
#include <port.h>intport_get(intport,port_event_t *pe,const timespec_t *timeout);
intport_getn(intport,port_event_tlist[],uint_tmax,uint_t *nget,const timespec_t *timeout);
Theport_get() andport_getn() functions retrieve events from a port. Theport_get()function retrieves at most a single event. Theport_getn() function can retrievemultiple events.
Thepe argument points to an uninitializedport_event_t structure that is filledin by the system when theport_get() function returns successfully.
Theport_event_t structure contains the following members:
int portev_events; /* detected events */ushort_t portev_source; /* event source */uintptr_t portev_object; /* specific to event source */void *portev_user; /* user defined cookie */
Theportev_events andportev_object members are specific to the event source. Theportev_events denotes the delivered events. Theportev_object refers to the associated object(seeport_create(3C)). Theportev_source member specifies the source of the event. Theportev_user member is a user-specified value.
If thetimeout pointer isNULL, theport_get() function blocks until anevent is available. To poll for an event without waiting,timeout shouldpoint to a zeroedtimespec. A non-zeroedtimespec specifies the desired time towait for events. Theport_get() function returns before the timeout elapses ifan event is available, a signal occurs, a port is closed byanother thread, or the port is in or enters alert mode. Seeport_alert(3C) for details on alert mode.
Theport_getn() function can retrieve multiple events from a port. Thelistargument is an array of uninitializedport_event_t structures that is filled inby the system when theport_getn() function returns successfully. Thenget argument pointsto the desired number of events to be retrieved. Themax parameterspecifies the maximum number of events that can be returned inlist[].Ifmax is 0, the value pointed to bynget is set tothe number of events available on the port. Theport_getn() function returnsimmediately but no events are retrieved.
Theport_getn() function block until the desired number of events are available,the timeout elapses, a signal occurs, a port is closed by anotherthread, or the port is in or enters alert mode.
On return, the value pointed to bynget is updated to theactual number of events retrieved in list.
Threads calling theport_get() function might starve threads waiting in theport_getn()function for more than one event. Similarly, threads calling theport_getn()function forn events might starve threads waiting in theport_getn() function formore thann events.
Theport_get() and theport_getn() functions ignore non-shareable events (seeport_create(3C)) generatedby other processes.
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errnois set to indicate the error.
Theport_get() andport_getn() functions will fail if:
Theport identifier is not valid.
Theport argument is not an event port file descriptor.
Event or event list can not be delivered (list[] pointer and/or user space reserved to accomodate the list of events is not reasonable), or thetimeout argument is not reasonable.
A signal was caught during the execution of the function.
Thetimeout elementtv_sec is < 0 or thetimeout elementtv_nsec is < 0 or > 1000000000.
The time interval expired before the expected number of events have been posted to the port.
Theport_getn() function will fail if:
Thelist[] argument isNULL, thenget argument isNULL, or the content ofnget is >max andmax is > 0.
Thetimeout argument is not reasonable.
The time interval expired before any events were posted to the port.
Example 1 Send a user event (PORT_SOURCE_USER) to a port and retrieve it withport_get().
The following example sends a user event (PORT_SOURCE_USER) to a port andretrieves it withport_get(). Theportev_user andportev_events members of theport_event_tstructure are the same as the corresponding user and events arguments of theport_send(3C) function.
#include <port.h>int myport;port_event_t pe;struct timespec timeout;int ret;void *user;uintptr_t object;myport = port_create();if (myport < 0) { /* port creation failed ... */ ... return(...);}...events = 0x01; /* own event definition(s) */object = <myobject>;user = <my_own_value>;ret = port_send(myport, events, user);if (ret == -1) { /* error detected ... */ ... close(myport); return (...);}/* * The following code could also be executed in another thread or * process. */timeout.tv_sec = 1; /* user defined */timeout.tv_nsec = 0;ret = port_get(myport, &pe, &timeout);if (ret == -1) { /* * error detected : * - EINTR or ETIME : log error code and try again ... * - Other kind of errors : may have to close the port ... */ return(...);}/* * After port_get() returns successfully, the port_event_t * structure will be filled with: * pe.portev_source = PORT_SOURCE_USER * pe.portev_events = 0x01 * pe.portev_object = <myobject> * pe.portev_user = <my_own_value> */...close(myport);Seeattributes(5) for descriptions of the following attributes:
|
port_alert(3C),port_associate(3C),port_create(3C),port_send(3C),attributes(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |