~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/os/os0thread.c

Imported InnoDB plugin with changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
/*******************************************************************
22
22
Compares two thread ids for equality. */
23
 
 
 
23
UNIV_INTERN
24
24
ibool
25
25
os_thread_eq(
26
26
/*=========*/
46
46
/********************************************************************
47
47
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
48
48
unique for the thread though! */
49
 
 
 
49
UNIV_INTERN
50
50
ulint
51
51
os_thread_pf(
52
52
/*=========*/
66
66
Returns the thread identifier of current thread. Currently the thread
67
67
identifier in Unix is the thread handle itself. Note that in HP-UX
68
68
pthread_t is a struct of 3 fields. */
69
 
 
 
69
UNIV_INTERN
70
70
os_thread_id_t
71
71
os_thread_get_curr_id(void)
72
72
/*=======================*/
82
82
Creates a new thread of execution. The execution starts from
83
83
the function given. The start function takes a void* parameter
84
84
and returns an ulint. */
85
 
 
 
85
UNIV_INTERN
86
86
os_thread_t
87
87
os_thread_create(
88
88
/*=============*/
152
152
                exit(1);
153
153
        }
154
154
#endif
 
155
#ifdef __NETWARE__
 
156
        ret = pthread_attr_setstacksize(&attr,
 
157
                                        (size_t) NW_THD_STACKSIZE);
 
158
        if (ret) {
 
159
                fprintf(stderr,
 
160
                        "InnoDB: Error: pthread_attr_setstacksize"
 
161
                        " returned %d\n", ret);
 
162
                exit(1);
 
163
        }
 
164
#endif
155
165
        os_mutex_enter(os_sync_mutex);
156
166
        os_thread_count++;
157
167
        os_mutex_exit(os_sync_mutex);
171
181
        pthread_attr_destroy(&attr);
172
182
#endif
173
183
        if (srv_set_thread_priorities) {
 
184
 
174
185
                  struct sched_param tmp_sched_param;
175
186
 
176
187
                  memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
188
199
 
189
200
/*********************************************************************
190
201
Exits the current thread. */
191
 
 
 
202
UNIV_INTERN
192
203
void
193
204
os_thread_exit(
194
205
/*===========*/
210
221
#endif
211
222
}
212
223
 
213
 
#ifdef HAVE_PTHREAD_JOIN
214
 
int
215
 
os_thread_join(
216
 
/*===========*/
217
 
  os_thread_id_t  thread_id)    /* in: id of the thread to join */
218
 
{
219
 
        return(pthread_join(thread_id, NULL));
220
 
}
221
 
#endif
222
224
/*********************************************************************
223
225
Returns handle to the current thread. */
224
 
 
 
226
UNIV_INTERN
225
227
os_thread_t
226
228
os_thread_get_curr(void)
227
229
/*====================*/
235
237
 
236
238
/*********************************************************************
237
239
Advises the os to give up remainder of the thread's time slice. */
238
 
 
 
240
UNIV_INTERN
239
241
void
240
242
os_thread_yield(void)
241
243
/*=================*/
255
257
 
256
258
/*********************************************************************
257
259
The thread sleeps at least the time given in microseconds. */
258
 
 
 
260
UNIV_INTERN
259
261
void
260
262
os_thread_sleep(
261
263
/*============*/
263
265
{
264
266
#ifdef __WIN__
265
267
        Sleep((DWORD) tm / 1000);
 
268
#elif defined(__NETWARE__)
 
269
        delay(tm / 1000);
266
270
#else
267
271
        struct timeval  t;
268
272
 
275
279
 
276
280
/**********************************************************************
277
281
Sets a thread priority. */
278
 
 
 
282
UNIV_INTERN
279
283
void
280
284
os_thread_set_priority(
281
285
/*===================*/
304
308
 
305
309
/**********************************************************************
306
310
Gets a thread priority. */
307
 
 
 
311
UNIV_INTERN
308
312
ulint
309
313
os_thread_get_priority(
310
314
/*===================*/
336
340
 
337
341
/**********************************************************************
338
342
Gets the last operating system error code for the calling thread. */
339
 
 
 
343
UNIV_INTERN
340
344
ulint
341
345
os_thread_get_last_error(void)
342
346
/*==========================*/