| 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)
- bind or unbind the current thread with the door server pool
cc-mt [flag... ]file... [library... ]#include <door.h>intdoor_bind(intdid);
intdoor_unbind(void);
Thedoor_bind() function associates the current thread with a door server pool.A door server pool is a private pool of server threads thatis available to serve door invocations associated with the doordid.
Thedoor_unbind() function breaks the association ofdoor_bind() by removing any privatedoor pool binding that is associated with the current thread.
Normally, door server threads are placed in a global pool of available threads that invocations on any door can use to dispatch adoor invocation. A door that has been created withDOOR_PRIVATE only usesserver threads that have been associated with the door bydoor_bind(). It istherefore necessary to bind at least one server thread to doorscreated withDOOR_PRIVATE.
The server thread create function,door_server_create(), is initially called by the systemduring adoor_create() operation. Seedoor_server_create(3C) anddoor_create(3C).
The current thread is added to the private pool of server threads associated with a door during the nextdoor_return() (that has beenissued by the current thread after an associateddoor_bind()). Seedoor_return(3C).A server thread performing adoor_bind() on a door that isalready bound to a different door performs an implicitdoor_unbind() of theprevious door.
If a process containing threads that have been bound to a doorcallsfork(2), the threads in the child process will be bound toan invalid door, and any calls todoor_return(3C) will result in an error.
Upon successful completion, a0 is returned. Otherwise,-1 is returned anderrno is set to indicate the error.
Thedoor_bind() anddoor_unbind() functions fail if:
Thedid argument is not a valid door.
Thedoor_unbind() function was called by a thread that is currently not bound.
did was not created with theDOOR_PRIVATE attribute.
Example 1 Usedoor_bind() to create private server pools for two doors.
The following example shows the use ofdoor_bind() to create private serverpools for two doors,d1 andd2. Functionmy_create() is called whena new server thread is needed; it creates a thread running function,my_server_create(), which binds itself to one of the two doors.
#include <door.h>#include <thread.h>#include <pthread.h>thread_key_t door_key;int d1 = -1;int d2 = -1;cond_t cv; /* statically initialized to zero */mutex_t lock; /* statically initialized to zero */extern void foo(void *, char *, size_t, door_desc_t *, uint_t);extern void bar(void *, char *, size_t, door_desc_t *, uint_t);static void *my_server_create(void *arg){ /* wait for d1 & d2 to be initialized */ mutex_lock(&lock); while (d1 == -1 || d2 == -1) cond_wait(&cv, &lock); mutex_unlock(&lock); if (arg == (void *)foo){ /* bind thread with pool associated with d1 */ thr_setspecific(door_key, (void *)foo); if (door_bind(d1) < 0) { perror("door_bind"); exit (-1); } } else if (arg == (void *)bar) { /* bind thread with pool associated with d2 */ thr_setspecific(door_key, (void *)bar); if (door_bind(d2) < 0) { /* bind thread to d2 thread pool */ perror("door_bind"); exit (-1); } } pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); door_return(NULL, 0, NULL, 0); /* Wait for door invocation */}static voidmy_create(door_info_t *dip){ /* Pass the door identity information to create function */ thr_create(NULL, 0, my_server_create, (void *)dip->di_proc, THR_BOUND | THR_DETACHED, NULL);}main(){ (void) door_server_create(my_create); if (thr_keycreate(&door_key, NULL) != 0) { perror("thr_keycreate"); exit(1); } mutex_lock(&lock); d1 = door_create(foo, NULL, DOOR_PRIVATE); /* Private pool */ d2 = door_create(bar, NULL, DOOR_PRIVATE); /* Private pool */ cond_signal(&cv); mutex_unlock(&lock); while (1) pause();}Seeattributes(5) for descriptions of the following attributes:
|
fork(2),door_create(3C),door_return(3C),door_server_create(3C),attributes(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |