~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/common/sge_ijs_threads.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
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
 
16
 *
 
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.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
 
 
33
 
 
34
#include "sge_ijs_threads.h"
 
35
 
 
36
int thread_init_lib(THREAD_LIB_HANDLE **thread_lib_handle)
 
37
{
 
38
   return cl_thread_list_setup(thread_lib_handle, "thread list");
 
39
}
 
40
 
 
41
int thread_cleanup_lib(THREAD_LIB_HANDLE **thread_lib_handle)
 
42
{
 
43
   return cl_thread_list_cleanup(thread_lib_handle);
 
44
}
 
45
 
 
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,
 
50
                  int thread_id,
 
51
                  void* thread_func(void*))
 
52
{
 
53
   return cl_thread_list_create_thread(thread_lib_handle, thread, log_list, 
 
54
                                       thread_name, thread_id,
 
55
                                       thread_func, NULL, NULL);
 
56
}
 
57
 
 
58
int register_thread(THREAD_LIB_HANDLE *thread_lib_handle,
 
59
                    THREAD_HANDLE     *thread,
 
60
                    const char *thread_name)
 
61
{
 
62
   int ret;
 
63
   ret = cl_thread_setup(thread,
 
64
                         thread_lib_handle, 
 
65
                         thread_name, 0, NULL, NULL, NULL);
 
66
   if (ret == CL_RETVAL_OK) {
 
67
      ret = cl_thread_func_startup(thread);
 
68
   }
 
69
   return ret;
 
70
}
 
71
 
 
72
int thread_func_startup(void *t_conf)
 
73
{
 
74
   cl_thread_settings_t *thread_config;
 
75
 
 
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);
 
79
}
 
80
 
 
81
int thread_func_cleanup(void *t_conf)
 
82
{
 
83
   cl_thread_settings_t *thread_config;
 
84
 
 
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);
 
88
}
 
89
 
 
90
 
 
91
int thread_shutdown(THREAD_HANDLE *thread)
 
92
{
 
93
   return cl_thread_shutdown(thread);
 
94
}
 
95
 
 
96
int thread_trigger_event(THREAD_HANDLE *thread)
 
97
{
 
98
   return cl_thread_trigger_event(thread);
 
99
}
 
100
 
 
101
int thread_wait_for_event(THREAD_HANDLE *thread, int sec, int msec)
 
102
{
 
103
   return cl_thread_wait_for_event(thread, sec, msec);
 
104
}
 
105
 
 
106
int thread_join(THREAD_HANDLE *thread)
 
107
{
 
108
   return cl_thread_join(thread);
 
109
}
 
110
 
 
111
 
 
112
int thread_setcancelstate(int enabled)
 
113
{
 
114
   int state = enabled != 0 ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE;
 
115
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
 
116
   return pthread_setcancelstate(state, NULL);
 
117
}
 
118
 
 
119
int thread_testcancel(void *t_conf)
 
120
{
 
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);
 
125
}
 
126