~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge trunk and resolve all conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
12
 
13
13
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
17
*****************************************************************************/
18
18
 
30
30
 
31
31
#ifdef __WIN__
32
32
#include <windows.h>
33
 
#else
34
 
#include <sys/select.h>
35
33
#endif
36
34
 
37
35
#ifndef UNIV_HOTBACKUP
135
133
                              0,        /* thread runs immediately */
136
134
                              &win_thread_id);
137
135
 
 
136
        if (srv_set_thread_priorities) {
 
137
 
 
138
                /* Set created thread priority the same as a normal query
 
139
                in MYSQL: we try to prevent starvation of threads by
 
140
                assigning same priority QUERY_PRIOR to all */
 
141
 
 
142
                ut_a(SetThreadPriority(thread, srv_query_thread_priority));
 
143
        }
 
144
 
138
145
        if (thread_id) {
139
146
                *thread_id = win_thread_id;
140
147
        }
165
172
                exit(1);
166
173
        }
167
174
#endif
 
175
#ifdef __NETWARE__
 
176
        ret = pthread_attr_setstacksize(&attr,
 
177
                                        (size_t) NW_THD_STACKSIZE);
 
178
        if (ret) {
 
179
                fprintf(stderr,
 
180
                        "InnoDB: Error: pthread_attr_setstacksize"
 
181
                        " returned %d\n", ret);
 
182
                exit(1);
 
183
        }
 
184
#endif
168
185
        os_mutex_enter(os_sync_mutex);
169
186
        os_thread_count++;
170
187
        os_mutex_exit(os_sync_mutex);
183
200
#ifndef UNIV_HPUX10
184
201
        pthread_attr_destroy(&attr);
185
202
#endif
 
203
        if (srv_set_thread_priorities) {
 
204
 
 
205
                  struct sched_param tmp_sched_param;
 
206
 
 
207
                  memset(&tmp_sched_param, 0, sizeof(tmp_sched_param));
 
208
                  tmp_sched_param.sched_priority= srv_query_thread_priority;
 
209
                  (void)pthread_setschedparam(pthread, SCHED_OTHER, &tmp_sched_param);
 
210
        }
186
211
 
187
212
        if (thread_id) {
188
213
                *thread_id = pthread;
205
230
        fprintf(stderr, "Thread exits, id %lu\n",
206
231
                os_thread_pf(os_thread_get_curr_id()));
207
232
#endif
208
 
 
209
 
#ifdef UNIV_PFS_THREAD
210
 
        pfs_delete_thread();
211
 
#endif
212
 
 
213
233
        os_mutex_enter(os_sync_mutex);
214
234
        os_thread_count--;
215
235
        os_mutex_exit(os_sync_mutex);
217
237
#ifdef __WIN__
218
238
        ExitThread((DWORD)exit_value);
219
239
#else
220
 
        pthread_detach(pthread_self());
221
240
        pthread_exit(exit_value);
222
241
#endif
223
242
}
245
264
/*=================*/
246
265
{
247
266
#if defined(__WIN__)
248
 
        SwitchToThread();
 
267
        Sleep(0);
249
268
#elif (defined(HAVE_SCHED_YIELD) && defined(HAVE_SCHED_H))
250
269
        sched_yield();
251
270
#elif defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
268
287
{
269
288
#ifdef __WIN__
270
289
        Sleep((DWORD) tm / 1000);
 
290
#elif defined(__NETWARE__)
 
291
        delay(tm / 1000);
271
292
#else
272
293
        struct timeval  t;
273
294