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
82
/*********************************************************************
83
Exits the current thread. */
88
void* exit_value); /* in: exit value; in Windows this void*
90
/*********************************************************************
91
Returns the thread identifier of current thread. */
94
os_thread_get_curr_id(void);
95
/*========================*/
96
/*********************************************************************
97
Returns handle to the current thread. */
100
os_thread_get_curr(void);
101
/*====================*/
102
/*********************************************************************
103
Advises the os to give up remainder of the thread's time slice. */
106
os_thread_yield(void);
107
/*=================*/
108
/*********************************************************************
109
The thread sleeps at least the time given in microseconds. */
114
ulint tm); /* in: time in microseconds */
115
/**********************************************************************
116
Gets a thread priority. */
119
os_thread_get_priority(
120
/*===================*/
122
os_thread_t handle);/* in: OS handle to the thread */
123
/**********************************************************************
124
Sets a thread priority. */
127
os_thread_set_priority(
128
/*===================*/
129
os_thread_t handle, /* in: OS handle to the thread */
130
ulint pri); /* in: priority: one of OS_PRIORITY_... */
131
/**********************************************************************
132
Gets the last operating system error code for the calling thread. */
135
os_thread_get_last_error(void);
136
/*==========================*/
139
#include "os0thread.ic"