55
57
/* Define a function pointer type to use in a typecast */
56
58
typedef void* (*os_posix_f_t) (void*);
58
/*******************************************************************
59
Compares two thread ids for equality. */
60
/***************************************************************//**
61
Compares two thread ids for equality.
62
@return TRUE if equal */
64
/* out: TRUE if equal */
65
os_thread_id_t a, /* in: OS thread or thread id */
66
os_thread_id_t b); /* in: OS thread or thread id */
67
/********************************************************************
67
os_thread_id_t a, /*!< in: OS thread or thread id */
68
os_thread_id_t b); /*!< in: OS thread or thread id */
69
/****************************************************************//**
68
70
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
69
unique for the thread though! */
71
unique for the thread though!
72
@return thread identifier as a number */
74
/* out: unsigned long int */
75
os_thread_id_t a); /* in: thread or thread id */
76
/********************************************************************
77
os_thread_id_t a); /*!< in: OS thread identifier */
78
/****************************************************************//**
77
79
Creates a new thread of execution. The execution starts from
78
80
the function given. The start function takes a void* parameter
79
81
and returns a ulint.
80
82
NOTE: We count the number of threads in os_thread_exit(). A created
81
thread should always use that to exit and not use return() to exit. */
83
thread should always use that to exit and not use return() to exit.
84
@return handle to the thread */
86
/* out: handle to the thread */
88
90
os_posix_f_t start_f,
90
ulint (*start_f)(void*), /* in: pointer to function
92
ulint (*start_f)(void*), /*!< in: pointer to function
91
93
from which to start */
93
void* arg, /* in: argument to start
95
void* arg, /*!< in: argument to start
95
os_thread_id_t* thread_id); /* out: id of the created
97
os_thread_id_t* thread_id); /*!< out: id of the created
98
/*********************************************************************
100
/*****************************************************************//**
99
101
Exits the current thread. */
104
void* exit_value); /* in: exit value; in Windows this void*
106
void* exit_value); /*!< in: exit value; in Windows this void*
105
107
is cast as a DWORD */
106
/*********************************************************************
107
Returns the thread identifier of current thread. */
108
/*****************************************************************//**
109
Returns the thread identifier of current thread.
110
@return current thread identifier */
110
113
os_thread_get_curr_id(void);
111
114
/*========================*/
112
/*********************************************************************
113
Returns handle to the current thread. */
115
/*****************************************************************//**
116
Returns handle to the current thread.
117
@return current thread handle */
116
120
os_thread_get_curr(void);
117
121
/*====================*/
118
/*********************************************************************
122
/*****************************************************************//**
119
123
Advises the os to give up remainder of the thread's time slice. */
122
126
os_thread_yield(void);
123
127
/*=================*/
124
/*********************************************************************
128
/*****************************************************************//**
125
129
The thread sleeps at least the time given in microseconds. */
130
ulint tm); /* in: time in microseconds */
131
/**********************************************************************
132
Gets a thread priority. */
134
ulint tm); /*!< in: time in microseconds */
135
/******************************************************************//**
136
Gets a thread priority.
135
140
os_thread_get_priority(
136
141
/*===================*/
138
os_thread_t handle);/* in: OS handle to the thread */
139
/**********************************************************************
142
os_thread_t handle);/*!< in: OS handle to the thread */
143
/******************************************************************//**
140
144
Sets a thread priority. */
143
147
os_thread_set_priority(
144
148
/*===================*/
145
os_thread_t handle, /* in: OS handle to the thread */
146
ulint pri); /* in: priority: one of OS_PRIORITY_... */
147
/**********************************************************************
148
Gets the last operating system error code for the calling thread. */
149
os_thread_t handle, /*!< in: OS handle to the thread */
150
ulint pri); /*!< in: priority: one of OS_PRIORITY_... */
151
/******************************************************************//**
152
Gets the last operating system error code for the calling thread.
153
@return last error on Windows, 0 otherwise */
151
156
os_thread_get_last_error(void);