JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Realtime Library Functions     Oracle Solaris 10 8/11 Information Library
search filter icon
search icon

Document Information

Preface

Realtime Library Functions

aiocancel(3AIO)

aio_cancel(3RT)

aio_error(3RT)

aio_fsync(3RT)

aioread(3AIO)

aio_read(3RT)

aio_return(3RT)

aio_suspend(3RT)

aiowait(3AIO)

aio_waitn(3RT)

aiowrite(3AIO)

aio_write(3RT)

clock_getres(3RT)

clock_gettime(3RT)

clock_nanosleep(3RT)

clock_settime(3RT)

door_bind(3DOOR)

door_call(3DOOR)

door_create(3DOOR)

door_cred(3DOOR)

door_info(3DOOR)

door_return(3DOOR)

door_revoke(3DOOR)

door_server_create(3DOOR)

door_ucred(3DOOR)

door_unbind(3DOOR)

door_xcreate(3DOOR)

fdatasync(3RT)

lio_listio(3RT)

mq_close(3RT)

mq_getattr(3RT)

mq_notify(3RT)

mq_open(3RT)

mq_receive(3RT)

mq_reltimedreceive_np(3RT)

mq_reltimedsend_np(3RT)

mq_send(3RT)

mq_setattr(3RT)

mq_timedreceive(3RT)

mq_timedsend(3RT)

mq_unlink(3RT)

nanosleep(3RT)

proc_service(3PROC)

ps_kill(3PROC)

ps_lcontinue(3PROC)

ps_lgetfpregs(3PROC)

ps_lgetregs(3PROC)

ps_lgetxregs(3PROC)

ps_lgetxregsize(3PROC)

ps_lrolltoaddr(3PROC)

ps_lsetfpregs(3PROC)

ps_lsetregs(3PROC)

ps_lsetxregs(3PROC)

ps_lstop(3PROC)

ps_pcontinue(3PROC)

ps_pdread(3PROC)

ps_pdwrite(3PROC)

ps_pglobal_lookup(3PROC)

ps_pglobal_sym(3PROC)

ps_pread(3PROC)

ps_pstop(3PROC)

ps_ptread(3PROC)

ps_ptwrite(3PROC)

ps_pwrite(3PROC)

sched_getparam(3RT)

sched_get_priority_max(3RT)

sched_get_priority_min(3RT)

sched_getscheduler(3RT)

sched_rr_get_interval(3RT)

sched_setparam(3RT)

sched_setscheduler(3RT)

sched_yield(3RT)

sem_close(3RT)

sem_destroy(3RT)

sem_getvalue(3RT)

sem_init(3RT)

sem_open(3RT)

sem_post(3RT)

sem_reltimedwait_np(3RT)

sem_timedwait(3RT)

sem_trywait(3RT)

sem_unlink(3RT)

sem_wait(3RT)

shm_open(3RT)

shm_unlink(3RT)

sigqueue(3RT)

sigtimedwait(3RT)

sigwaitinfo(3RT)

timer_create(3RT)

timer_delete(3RT)

timer_getoverrun(3RT)

timer_gettime(3RT)

timer_settime(3RT)

door_bind

, door_unbind

- bind or unbind the current thread with the door server pool

Synopsis

cc -mt [ flag... ] file... -ldoor  [ library... ]
#include <door.h>

int door_bind(int did);
int door_unbind(void);

Description

The door_bind() function associates the current thread with a door server pool. A door server pool is a private pool of server threads that is available to serve door invocations associated with the door did.

The door_unbind() function breaks the association of door_bind() by removing any private door 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 a door invocation. A door that has been created with DOOR_PRIVATE only uses server threads that have been associated with the door by door_bind(). It is therefore necessary to bind at least one server thread to doors created with DOOR_PRIVATE.

The server thread create function, door_server_create(), is initially called by the system during a door_create() operation. See door_server_create(3DOOR) and door_create(3DOOR).

The current thread is added to the private pool of server threads associated with a door during the next door_return() (that has been issued by the current thread after an associated door_bind()). See door_return(3DOOR). A server thread performing a door_bind() on a door that is already bound to a different door performs an implicit door_unbind() of the previous door.

If a process containing threads that have been bound to a door calls fork(2), the threads in the child process will be bound to an invalid door, and any calls to door_return(3DOOR) will result in an error.

Return Values

Upon successful completion, a 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.

Errors

The door_bind() and door_unbind() functions fail if:

EBADF

The did argument is not a valid door.

EBADF

The door_unbind() function was called by a thread that is currently not bound.

EINVAL

did was not created with the DOOR_PRIVATE attribute.

Examples

Example 1 Use door_bind() to create private server pools for two doors.

The following example shows the use of door_bind() to create private server pools for two doors, d1 and d2. Function my_create() is called when a 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 void
my_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();
}

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Architecture
all
Availability
SUNWcsu
Interface Stability
Evolving
MT-Level
Safe

See Also

fork(2),door_create(3DOOR), door_return(3DOOR), door_server_create(3DOOR), libdoor(3LIB), attributes(5)