Chapter 4. AIX
81
Sleep and wake-up primitives (thread_wait and thread_post)
AIX provides proprietary
thread_wait()
and
thread_post()
APIs that can be used to
optimize thread synchronization and communication (IPC) operations. AIX also provides
several standard APIs that can be used for thread synchronization and communication.
These APIs include
pthread_cond_wait()
,
pthread_cond_signal()
, and
semop()
. Although
many applications use these standard APIs, the low-level primitives are available to optimize
these operations.
thread_wait()
and
thread_post()
can be used to optimize critical
applications services, such as user-mode locking or message passing. They are more
efficient than the portable/standard APIs.
Here is more information about the associated subroutines:
thread_wait
The
thread_wait
subroutine allows a thread to wait or block until another thread posts it
with the
thread_post
or the
thread_post_many
subroutine or until the time limit specified
by the timeout value expires.
If the event for which the thread is waiting and for which it is posted occurs only in the
future, the
thread_wait
subroutine can be called with a timeout value of 0 to clear any
pending posts by running the following command:
thread_wait (timeout)
thread_post
The
thread_post
subroutine posts the thread whose thread ID is indicated by the value of
the
tid
parameter, of the occurrence of an event. If the posted thread is waiting in
thread_wait
, it is awakened immediately. If it is not waiting in
thread_wait
, the next call to
thread_wait
is not blocked, but returns with success immediately.
Multiple posts to the same thread without an intervening wait by the specified thread
counts only as a single post. The posting remains in effect until the indicated thread calls
the
thread_wait
subroutine, upon which the posting is cleared.
thread_post_many
The
thread_post_many
subroutine posts one or more threads of the occurrence of the
event. The number of threads to be posted is specified by the value of the
nthreads
parameter, while the
tidp
parameter points to an array of thread IDs of threads that must
be posted. The subroutine works just like the
thread_post
subroutine, but can be used to
post to multiple threads at the same time. A maximum of 512 threads can be posted in one
call to the
thread_post_many
subroutine.
For more information about this topic, see 4.4, “Related publications” on page 94.
Shared versus private loads
You can use AIX to share text for libraries and dynamically loaded modules. File permissions
can be used to enable and disable sharing of loaded text.
Documentation
AIX provides optimizations that enable sharing of loaded text (libraries and dynamically
loaded modules). Sharing text among processes often improves performance because it
reduces resource usage (memory and disk space). It also allows unrelated software-threads
to share cache space when they run concurrently. Lastly, it can reduce load times when the
code is already loaded by a previous program.
Applications can control if private or shared loads are performed to shared text regions.
Shared loads require that execute permissions be set for group/other on the text files. As a
preferred practice, you should enable sharing.
Содержание Power System POWER7 Series
Страница 2: ......
Страница 36: ...20 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 70: ...54 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 112: ...96 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 140: ...124 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 162: ...146 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 170: ...154 POWER7 and POWER7 Optimization and Tuning Guide...
Страница 222: ...POWER7 and POWER7 Optimization and Tuning Guide POWER7 and POWER7 Optimization and Tuning Guide...
Страница 223: ......