4. API 比较细节 |
#include <thread.h>
#include <signal.h>
void thr_exit (int *status)
thread_t thr_self ()
int thr_sigsetmask (int how, const sigset_t *new, sigset_t *old)
int thr_yield ()
int thr_kill (thread_t, int sig)
#include <pthread.h>
#include <signal.h>
void pthread_exit (int *status)
thread_t thread_self ()
int pthread_sigmask (int how, const sigset_t *newp, sigset_t *oldp)
int pthread_yield ()
int pthread_kill (pthread_t, int sig)
在Solaris 中
int status;
thr_exit (&status); /* exit with status */
在pthreads 中
int status;
pthread_exit (&status); /* exit with status */
在Solaris 中
thread_t tid;
tid = thr_self();
在pthreads 中
pthread_t tid;
tid = pthread_self();
在Solaris 中
int ret;
sigset_t old, new;
ret = thr_sigsetmask (SIG_SETMASK, &new, &old); /* setting a new mask */
ret = thr_sigsetmask (SIG_BLOCK, &new, &old); /* blocking mask */
re = thr_sigsetmask (SIG_UNBLCOK, &new, &old); /* unblocking mask */
在pthreads 中
int ret;
sigset_t old, new;
ret = pthread_sigmask (SIG_SETMASK, &new, &old); /* setting a new mask */
ret = pthread_sigmask (SIG_BLOCK, &new, &old); /* blocking mask */
ret = pthread_sigmask (SIG_UNBLCOK, &new, &old); /* unblocking mask */
在Solaris 中
thr_yield();
在pthreads 中
pthread_yield();
在Solaris 中
int sig;
thread_t tid;
thr_kill (tid, sig); /* kill target thread with sig signal */
在pthreads 中
int sig;
pthread_t tid;
pthread_kill (tid, sig); /* kill target thread with sig signal */
Copyright: NPACT |