1
/******************************************************
2
The interface to the operating system
3
process and thread control primitives
7
Created 9/8/1995 Heikki Tuuri
8
*******************************************************/
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 */
19
#define OS_THREAD_MAX_N srv_max_n_threads
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
29
typedef void* os_thread_t;
30
typedef ulint os_thread_id_t; /* In Windows the thread id
31
is an unsigned long int */
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
39
/* Define a function pointer type to use in a typecast */
40
typedef void* (*os_posix_f_t) (void*);
42
/*******************************************************************
43
Compares two thread ids for equality. */
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! */
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
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. */
70
/* out: handle to the thread */
74
ulint (*start_f)(void*), /* in: pointer to function
75
from which to start */
77
void* arg, /* in: argument to start
79
os_thread_id_t* thread_id); /* out: id of the created
84
os_thread_id_t thread_id); /* in: id of the thread to join */
85
/*********************************************************************
86
Exits the current thread. */
91
void* exit_value); /* in: exit value; in Windows this void*
93
/*********************************************************************
94
Returns the thread identifier of current thread. */
97
os_thread_get_curr_id(void);
98
/*========================*/
99
/*********************************************************************
100
Returns handle to the current thread. */
103
os_thread_get_curr(void);
104
/*====================*/
105
/*********************************************************************
106
Advises the os to give up remainder of the thread's time slice. */
109
os_thread_yield(void);
110
/*=================*/
111
/*********************************************************************
112
The thread sleeps at least the time given in microseconds. */
117
ulint tm); /* in: time in microseconds */
118
/**********************************************************************
119
Gets a thread priority. */
122
os_thread_get_priority(
123
/*===================*/
125
os_thread_t handle);/* in: OS handle to the thread */
126
/**********************************************************************
127
Sets a thread priority. */
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. */
138
os_thread_get_last_error(void);
139
/*==========================*/
142
#include "os0thread.ic"