srv0srv.h
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:7k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /******************************************************
  2. The server main program
  3. (c) 1995 Innobase Oy
  4. Created 10/10/1995 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef srv0srv_h
  7. #define srv0srv_h
  8. #include "univ.i"
  9. #include "sync0sync.h"
  10. #include "os0sync.h"
  11. #include "com0com.h"
  12. #include "que0types.h"
  13. /* Server parameters which are read from the initfile */
  14. extern char* srv_data_home;
  15. extern char* srv_logs_home;
  16. extern char* srv_arch_dir;
  17. extern ulint srv_n_data_files;
  18. extern char** srv_data_file_names;
  19. extern ulint* srv_data_file_sizes;
  20. extern char** srv_log_group_home_dirs;
  21. extern ulint srv_n_log_groups;
  22. extern ulint srv_n_log_files;
  23. extern ulint srv_log_file_size;
  24. extern ibool srv_log_archive_on;
  25. extern ulint srv_log_buffer_size;
  26. extern ibool srv_flush_log_at_trx_commit;
  27. extern ibool srv_use_native_aio;
  28. extern ulint srv_pool_size;
  29. extern ulint srv_mem_pool_size;
  30. extern ulint srv_lock_table_size;
  31. extern ulint srv_n_file_io_threads;
  32. extern ibool srv_archive_recovery;
  33. extern dulint srv_archive_recovery_limit_lsn;
  34. extern ulint srv_lock_wait_timeout;
  35. /*-------------------------------------------*/
  36. extern ulint srv_n_spin_wait_rounds;
  37. extern ulint srv_spin_wait_delay;
  38. extern ibool srv_priority_boost;
  39. extern ulint srv_pool_size;
  40. extern ulint srv_mem_pool_size;
  41. extern ulint srv_lock_table_size;
  42. extern ulint srv_sim_disk_wait_pct;
  43. extern ulint srv_sim_disk_wait_len;
  44. extern ibool srv_sim_disk_wait_by_yield;
  45. extern ibool srv_sim_disk_wait_by_wait;
  46. extern ibool srv_measure_contention;
  47. extern ibool srv_measure_by_spin;
  48. extern ibool srv_print_thread_releases;
  49. extern ibool srv_print_lock_waits;
  50. extern ibool srv_print_buf_io;
  51. extern ibool srv_print_log_io;
  52. extern ibool srv_print_parsed_sql;
  53. extern ibool srv_print_latch_waits;
  54. extern ibool srv_test_nocache;
  55. extern ibool srv_test_cache_evict;
  56. extern ibool srv_test_extra_mutexes;
  57. extern ibool srv_test_sync;
  58. extern ulint srv_test_n_threads;
  59. extern ulint srv_test_n_loops;
  60. extern ulint srv_test_n_free_rnds;
  61. extern ulint srv_test_n_reserved_rnds;
  62. extern ulint srv_test_n_mutexes;
  63. extern ulint srv_test_array_size;
  64. extern ulint srv_activity_count;
  65. extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
  66. query threads, and lock table: we allocate
  67. it from dynamic memory to get it to the
  68. same DRAM page as other hotspot semaphores */
  69. #define kernel_mutex (*kernel_mutex_temp)
  70. typedef struct srv_sys_struct srv_sys_t;
  71. /* The server system */
  72. extern srv_sys_t* srv_sys;
  73. /*************************************************************************
  74. Boots Innobase server. */
  75. ulint
  76. srv_boot(void);
  77. /*==========*/
  78. /* out: DB_SUCCESS or error code */
  79. /*************************************************************************
  80. Gets the number of threads in the system. */
  81. ulint
  82. srv_get_n_threads(void);
  83. /*===================*/
  84. /*************************************************************************
  85. Returns the calling thread type. */
  86. ulint
  87. srv_get_thread_type(void);
  88. /*=====================*/
  89. /* out: SRV_COM, ... */
  90. /*************************************************************************
  91. Releases threads of the type given from suspension in the thread table.
  92. NOTE! The server mutex has to be reserved by the caller! */
  93. ulint
  94. srv_release_threads(
  95. /*================*/
  96. /* out: number of threads released: this may be
  97. < n if not enough threads were suspended at the
  98. moment */
  99. ulint type, /* in: thread type */
  100. ulint n); /* in: number of threads to release */
  101. /*************************************************************************
  102. The master thread controlling the server. */
  103. #ifndef __WIN__
  104. void*
  105. #else
  106. ulint
  107. #endif
  108. srv_master_thread(
  109. /*==============*/
  110. /* out: a dummy parameter */
  111. void* arg); /* in: a dummy parameter required by
  112. os_thread_create */
  113. /*************************************************************************
  114. Reads a keyword and a value from a file. */
  115. ulint
  116. srv_read_init_val(
  117. /*==============*/
  118. /* out: DB_SUCCESS or error code */
  119. FILE* initfile, /* in: file pointer */
  120. char* keyword, /* in: keyword before value(s), or NULL if
  121. no keyword read */
  122. char* str_buf, /* in/out: buffer for a string value to read,
  123. buffer size must be 10000 bytes, if NULL
  124. then not read */
  125. ulint* num_val, /* out: numerical value to read, if NULL
  126. then not read */
  127. ibool print_not_err); /* in: if TRUE, then we will not print
  128. error messages to console */
  129. /***********************************************************************
  130. Tells the Innobase server that there has been activity in the database
  131. and wakes up the master thread if it is suspended (not sleeping). Used
  132. in the MySQL interface. Note that there is a small chance that the master
  133. thread stays suspended (we do not protect our operation with the kernel
  134. mutex, for performace reasons). */
  135. void
  136. srv_active_wake_master_thread(void);
  137. /*===============================*/
  138. /*******************************************************************
  139. Puts a MySQL OS thread to wait for a lock to be released. */
  140. ibool
  141. srv_suspend_mysql_thread(
  142. /*=====================*/
  143. /* out: TRUE if the lock wait timeout was
  144. exceeded */
  145. que_thr_t* thr); /* in: query thread associated with
  146. the MySQL OS thread */
  147. /************************************************************************
  148. Releases a MySQL OS thread waiting for a lock to be released, if the
  149. thread is already suspended. */
  150. void
  151. srv_release_mysql_thread_if_suspended(
  152. /*==================================*/
  153. que_thr_t* thr); /* in: query thread associated with the
  154. MySQL OS thread  */
  155. /*************************************************************************
  156. A thread which wakes up threads whose lock wait may have lasted too long. */
  157. #ifndef __WIN__
  158. void*
  159. #else
  160. ulint
  161. #endif
  162. srv_lock_timeout_monitor_thread(
  163. /*============================*/
  164. /* out: a dummy parameter */
  165. void* arg); /* in: a dummy parameter required by
  166. os_thread_create */
  167. /* Types for the threads existing in the system. Threads of types 4 - 9
  168. are called utility threads. Note that utility threads are mainly disk
  169. bound, except that version threads 6 - 7 may also be CPU bound, if
  170. cleaning versions from the buffer pool. */
  171. #define SRV_COM 1 /* threads serving communication and queries */
  172. #define SRV_CONSOLE 2 /* thread serving console */
  173. #define SRV_WORKER 3 /* threads serving parallelized queries and
  174. queries released from lock wait */
  175. #define SRV_BUFFER 4 /* thread flushing dirty buffer blocks,
  176. not currently in use */
  177. #define SRV_RECOVERY 5 /* threads finishing a recovery,
  178. not currently in use */
  179. #define SRV_INSERT 6 /* thread flushing the insert buffer to disk,
  180. not currently in use */
  181. #define SRV_MASTER 7       /* the master thread, (whose type number must
  182. be biggest) */
  183. /* Thread slot in the thread table */
  184. typedef struct srv_slot_struct srv_slot_t;
  185. /* Thread table is an array of slots */
  186. typedef srv_slot_t srv_table_t;
  187. /* The server system struct */
  188. struct srv_sys_struct{
  189. os_event_t operational; /* created threads must wait for the
  190. server to become operational by
  191. waiting for this event */
  192. com_endpoint_t* endpoint; /* the communication endpoint of the
  193. server */
  194. srv_table_t* threads; /* server thread table */
  195. UT_LIST_BASE_NODE_T(que_thr_t)
  196. tasks; /* task queue */
  197. };
  198. extern ulint srv_n_threads_active[];
  199. #endif