1
/*****************************************************************************
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
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
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/os0thread.h
1
/******************************************************
21
2
The interface to the operating system
22
3
process and thread control primitives
24
7
Created 9/8/1995 Heikki Tuuri
25
8
*******************************************************/
57
39
/* Define a function pointer type to use in a typecast */
58
40
typedef void* (*os_posix_f_t) (void*);
60
#ifdef HAVE_PSI_INTERFACE
61
/* Define for performance schema registration key */
62
typedef unsigned int mysql_pfs_key_t;
65
/***************************************************************//**
66
Compares two thread ids for equality.
67
@return TRUE if equal */
42
/*******************************************************************
43
Compares two thread ids for equality. */
72
os_thread_id_t a, /*!< in: OS thread or thread id */
73
os_thread_id_t b); /*!< in: OS thread or thread id */
74
/****************************************************************//**
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
/********************************************************************
75
52
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
76
unique for the thread though!
77
@return thread identifier as a number */
53
unique for the thread though! */
82
os_thread_id_t a); /*!< in: OS thread identifier */
83
/****************************************************************//**
58
/* out: unsigned long int */
59
os_thread_id_t a); /* in: thread or thread id */
60
/********************************************************************
84
61
Creates a new thread of execution. The execution starts from
85
62
the function given. The start function takes a void* parameter
86
63
and returns a ulint.
87
64
NOTE: We count the number of threads in os_thread_exit(). A created
88
thread should always use that to exit and not use return() to exit.
89
@return handle to the thread */
65
thread should always use that to exit and not use return() to exit. */
70
/* out: handle to the thread */
97
ulint (*start_f)(void*), /*!< in: pointer to function
74
ulint (*start_f)(void*), /* in: pointer to function
98
75
from which to start */
100
void* arg, /*!< in: argument to start
77
void* arg, /* in: argument to start
102
os_thread_id_t* thread_id); /*!< out: id of the created
79
os_thread_id_t* thread_id); /* out: id of the created
103
80
thread, or NULL */
105
/*****************************************************************//**
82
/*********************************************************************
106
83
Exits the current thread. */
111
void* exit_value); /*!< in: exit value; in Windows this void*
88
void* exit_value); /* in: exit value; in Windows this void*
112
89
is cast as a DWORD */
113
/*****************************************************************//**
114
Returns the thread identifier of current thread.
115
@return current thread identifier */
90
/*********************************************************************
91
Returns the thread identifier of current thread. */
118
94
os_thread_get_curr_id(void);
119
95
/*========================*/
120
/*****************************************************************//**
121
Returns handle to the current thread.
122
@return current thread handle */
96
/*********************************************************************
97
Returns handle to the current thread. */
125
100
os_thread_get_curr(void);
126
101
/*====================*/
127
/*****************************************************************//**
102
/*********************************************************************
128
103
Advises the os to give up remainder of the thread's time slice. */
131
106
os_thread_yield(void);
132
107
/*=================*/
133
/*****************************************************************//**
108
/*********************************************************************
134
109
The thread sleeps at least the time given in microseconds. */
139
ulint tm); /*!< in: time in microseconds */
140
/******************************************************************//**
141
Gets a thread priority.
114
ulint tm); /* in: time in microseconds */
115
/**********************************************************************
116
Gets a thread priority. */
145
119
os_thread_get_priority(
146
120
/*===================*/
147
os_thread_t handle);/*!< in: OS handle to the thread */
148
/******************************************************************//**
122
os_thread_t handle);/* in: OS handle to the thread */
123
/**********************************************************************
149
124
Sets a thread priority. */
152
127
os_thread_set_priority(
153
128
/*===================*/
154
os_thread_t handle, /*!< in: OS handle to the thread */
155
ulint pri); /*!< in: priority: one of OS_PRIORITY_... */
156
/******************************************************************//**
157
Gets the last operating system error code for the calling thread.
158
@return last error on Windows, 0 otherwise */
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. */
161
135
os_thread_get_last_error(void);