~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to storage/innobase/include/os0thread.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The interface to the operating system
 
3
process and thread control primitives
 
4
 
 
5
(c) 1995 Innobase Oy
 
6
 
 
7
Created 9/8/1995 Heikki Tuuri
 
8
*******************************************************/
 
9
 
 
10
#ifndef os0thread_h
 
11
#define os0thread_h
 
12
 
 
13
#include "univ.i"
 
14
 
 
15
/* Maximum number of threads which can be created in the program;
 
16
this is also the size of the wait slot array for MySQL threads which
 
17
can wait inside InnoDB */
 
18
 
 
19
#define OS_THREAD_MAX_N         srv_max_n_threads
 
20
 
 
21
 
 
22
/* Possible fixed priorities for threads */
 
23
#define OS_THREAD_PRIORITY_NONE         100
 
24
#define OS_THREAD_PRIORITY_BACKGROUND   1
 
25
#define OS_THREAD_PRIORITY_NORMAL       2
 
26
#define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
 
27
 
 
28
#ifdef __WIN__
 
29
typedef void*                   os_thread_t;
 
30
typedef ulint                   os_thread_id_t; /* In Windows the thread id
 
31
                                                is an unsigned long int */
 
32
#else
 
33
typedef pthread_t               os_thread_t;
 
34
typedef os_thread_t             os_thread_id_t; /* In Unix we use the thread
 
35
                                                handle itself as the id of
 
36
                                                the thread */
 
37
#endif
 
38
 
 
39
/* Define a function pointer type to use in a typecast */
 
40
typedef void* (*os_posix_f_t) (void*);
 
41
 
 
42
/*******************************************************************
 
43
Compares two thread ids for equality. */
 
44
 
 
45
ibool
 
46
os_thread_eq(
 
47
/*=========*/
 
48
                                /* out: TRUE if equal */
 
49
        os_thread_id_t  a,      /* in: OS thread or thread id */
 
50
        os_thread_id_t  b);     /* in: OS thread or thread id */
 
51
/********************************************************************
 
52
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
 
53
unique for the thread though! */
 
54
 
 
55
ulint
 
56
os_thread_pf(
 
57
/*=========*/
 
58
                                /* out: unsigned long int */
 
59
        os_thread_id_t  a);     /* in: thread or thread id */
 
60
/********************************************************************
 
61
Creates a new thread of execution. The execution starts from
 
62
the function given. The start function takes a void* parameter
 
63
and returns a ulint.
 
64
NOTE: We count the number of threads in os_thread_exit(). A created
 
65
thread should always use that to exit and not use return() to exit. */
 
66
 
 
67
os_thread_t
 
68
os_thread_create(
 
69
/*=============*/
 
70
                                                /* out: handle to the thread */
 
71
#ifndef __WIN__
 
72
                 os_posix_f_t            start_f,
 
73
#else
 
74
        ulint (*start_f)(void*),                /* in: pointer to function
 
75
                                                from which to start */
 
76
#endif
 
77
        void*                   arg,            /* in: argument to start
 
78
                                                function */
 
79
        os_thread_id_t*         thread_id);     /* out: id of the created
 
80
                                                thread, or NULL */
 
81
int
 
82
os_thread_join(
 
83
/*===========*/
 
84
  os_thread_id_t  thread_id);   /* in: id of the thread to join */
 
85
/*********************************************************************
 
86
Exits the current thread. */
 
87
 
 
88
void
 
89
os_thread_exit(
 
90
/*===========*/
 
91
        void*   exit_value);    /* in: exit value; in Windows this void*
 
92
                                is cast as a DWORD */
 
93
/*********************************************************************
 
94
Returns the thread identifier of current thread. */
 
95
 
 
96
os_thread_id_t
 
97
os_thread_get_curr_id(void);
 
98
/*========================*/
 
99
/*********************************************************************
 
100
Returns handle to the current thread. */
 
101
 
 
102
os_thread_t
 
103
os_thread_get_curr(void);
 
104
/*====================*/
 
105
/*********************************************************************
 
106
Advises the os to give up remainder of the thread's time slice. */
 
107
 
 
108
void
 
109
os_thread_yield(void);
 
110
/*=================*/
 
111
/*********************************************************************
 
112
The thread sleeps at least the time given in microseconds. */
 
113
 
 
114
void
 
115
os_thread_sleep(
 
116
/*============*/
 
117
        ulint   tm);    /* in: time in microseconds */
 
118
/**********************************************************************
 
119
Gets a thread priority. */
 
120
 
 
121
ulint
 
122
os_thread_get_priority(
 
123
/*===================*/
 
124
                                /* out: priority */
 
125
        os_thread_t     handle);/* in: OS handle to the thread */
 
126
/**********************************************************************
 
127
Sets a thread priority. */
 
128
 
 
129
void
 
130
os_thread_set_priority(
 
131
/*===================*/
 
132
        os_thread_t     handle, /* in: OS handle to the thread */
 
133
        ulint           pri);   /* in: priority: one of OS_PRIORITY_... */
 
134
/**********************************************************************
 
135
Gets the last operating system error code for the calling thread. */
 
136
 
 
137
ulint
 
138
os_thread_get_last_error(void);
 
139
/*==========================*/
 
140
 
 
141
#ifndef UNIV_NONINL
 
142
#include "os0thread.ic"
 
143
#endif
 
144
 
 
145
#endif