2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
16 #include <sys/cmn_err.h>
17 #include <sys/thread.h>
20 #define _SYNCH_H /* keep out <synch.h> */
24 * Get the current kthread_t pointer.
32 return ((kthread_t
*)(uintptr_t)tid
);
38 * thread_create() blocks for memory if necessary. It never fails.
52 void * (*thr_func
)(void *);
57 thr_flags
= THR_BOUND
;
64 thr_flags
|= THR_SUSPENDED
;
67 cmn_err(CE_PANIC
, "thread_create: invalid state");
71 thr_func
= (void *(*)(void *))func
;
72 rc
= thr_create(NULL
, 0, thr_func
, arg
, thr_flags
, &newtid
);
74 cmn_err(CE_PANIC
, "thread_create failed, rc=%d", rc
);
76 return ((void *)(uintptr_t)newtid
);
86 thread_join(kt_did_t id
)
90 thr_id
= (thread_t
)id
;
91 (void) thr_join(thr_id
, NULL
, NULL
);
95 tsignal(kthread_t
*kt
, int sig
)
97 thread_t tid
= (thread_t
)(uintptr_t)kt
;
99 (void) thr_kill(tid
, sig
);
115 t
= thread_create(stk
, stksize
, func
, arg
, len
, NULL
, TS_RUN
, pri
);