1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
34
#include "sge_ijs_threads.h"
36
int thread_init_lib(THREAD_LIB_HANDLE **thread_lib_handle)
38
return cl_thread_list_setup(thread_lib_handle, "thread list");
41
int thread_cleanup_lib(THREAD_LIB_HANDLE **thread_lib_handle)
43
return cl_thread_list_cleanup(thread_lib_handle);
46
int create_thread(THREAD_LIB_HANDLE *thread_lib_handle,
47
THREAD_HANDLE **thread,
48
cl_raw_list_t *log_list,
49
const char *thread_name,
51
void* thread_func(void*))
53
return cl_thread_list_create_thread(thread_lib_handle, thread, log_list,
54
thread_name, thread_id,
55
thread_func, NULL, NULL);
58
int register_thread(THREAD_LIB_HANDLE *thread_lib_handle,
59
THREAD_HANDLE *thread,
60
const char *thread_name)
63
ret = cl_thread_setup(thread,
65
thread_name, 0, NULL, NULL, NULL);
66
if (ret == CL_RETVAL_OK) {
67
ret = cl_thread_func_startup(thread);
72
int thread_func_startup(void *t_conf)
74
cl_thread_settings_t *thread_config;
76
/* get pointer to cl_thread_settings_t struct */
77
thread_config = (cl_thread_settings_t*)t_conf;
78
return cl_thread_func_startup(thread_config);
81
int thread_func_cleanup(void *t_conf)
83
cl_thread_settings_t *thread_config;
85
/* get pointer to cl_thread_settings_t struct */
86
thread_config = (cl_thread_settings_t*)t_conf;
87
return cl_thread_func_cleanup(thread_config);
91
int thread_shutdown(THREAD_HANDLE *thread)
93
return cl_thread_shutdown(thread);
96
int thread_trigger_event(THREAD_HANDLE *thread)
98
return cl_thread_trigger_event(thread);
101
int thread_wait_for_event(THREAD_HANDLE *thread, int sec, int msec)
103
return cl_thread_wait_for_event(thread, sec, msec);
106
int thread_join(THREAD_HANDLE *thread)
108
return cl_thread_join(thread);
112
int thread_setcancelstate(int enabled)
114
int state = enabled != 0 ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE;
115
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
116
return pthread_setcancelstate(state, NULL);
119
int thread_testcancel(void *t_conf)
121
cl_thread_settings_t *thread_config;
122
/* get pointer to cl_thread_settings_t struct */
123
thread_config = (cl_thread_settings_t*)t_conf;
124
return cl_thread_func_testcancel(thread_config);