#include "univ.i"#include "ut0lst.h"Include dependency graph for os0sync.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define OS_SYNC_INFINITE_TIME ((ulint)(-1)) |
| #define OS_SYNC_TIME_EXCEEDED 1 |
| typedef struct os_event_struct os_event_struct_t |
| typedef os_event_struct_t* os_event_t |
| typedef pthread_mutex_t os_fast_mutex_t |
| typedef struct os_mutex_struct os_mutex_str_t |
| typedef os_mutex_str_t* os_mutex_t |
| os_event_t os_event_create | ( | const char * | name | ) |
Definition at line 110 of file os0sync.c.
References os_event_struct::cond_var, FALSE, os_event_struct::is_set, NULL, os_event_count, os_fast_mutex_init(), os_event_struct::os_mutex, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, os_event_struct::signal_count, TRUE, ut_a, UT_LIST_ADD_FIRST, ut_malloc(), and UT_NOT_USED.
Referenced by buf_pool_init(), ib_wqueue_create(), log_init(), os_aio_array_create(), os_aio_init(), srv_init(), sync_array_create(), and sync_init().
00112 : the event handle */ 00113 const char* name) /* in: the name of the event, if NULL 00114 the event is created without a name */ 00115 { 00116 #ifdef __WIN__ 00117 os_event_t event; 00118 00119 event = ut_malloc(sizeof(struct os_event_struct)); 00120 00121 event->handle = CreateEvent(NULL,/* No security attributes */ 00122 TRUE, /* Manual reset */ 00123 FALSE, /* Initial state nonsignaled */ 00124 (LPCTSTR) name); 00125 if (!event->handle) { 00126 fprintf(stderr, 00127 "InnoDB: Could not create a Windows event semaphore; Windows error %lu\n", 00128 (ulong) GetLastError()); 00129 } 00130 #else /* Unix */ 00131 os_event_t event; 00132 00133 UT_NOT_USED(name); 00134 00135 event = ut_malloc(sizeof(struct os_event_struct)); 00136 00137 os_fast_mutex_init(&(event->os_mutex)); 00138 00139 #if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10) 00140 ut_a(0 == pthread_cond_init(&(event->cond_var), 00141 pthread_condattr_default)); 00142 #else 00143 ut_a(0 == pthread_cond_init(&(event->cond_var), NULL)); 00144 #endif 00145 event->is_set = FALSE; 00146 event->signal_count = 0; 00147 #endif /* __WIN__ */ 00148 00149 /* Put to the list of events */ 00150 os_mutex_enter(os_sync_mutex); 00151 00152 UT_LIST_ADD_FIRST(os_event_list, os_event_list, event); 00153 00154 os_event_count++; 00155 00156 os_mutex_exit(os_sync_mutex); 00157 00158 return(event); 00159 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_event_free | ( | os_event_t | event | ) |
Definition at line 262 of file os0sync.c.
References os_event_struct::cond_var, os_event_count, os_fast_mutex_free(), os_event_struct::os_mutex, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, ut_a, ut_free(), and UT_LIST_REMOVE.
Referenced by ib_wqueue_free(), os_sync_free(), and sync_array_free().
00264 : event to free */ 00265 00266 { 00267 #ifdef __WIN__ 00268 ut_a(event); 00269 00270 ut_a(CloseHandle(event->handle)); 00271 #else 00272 ut_a(event); 00273 00274 os_fast_mutex_free(&(event->os_mutex)); 00275 ut_a(0 == pthread_cond_destroy(&(event->cond_var))); 00276 #endif 00277 /* Remove from the list of events */ 00278 00279 os_mutex_enter(os_sync_mutex); 00280 00281 UT_LIST_REMOVE(os_event_list, os_event_list, event); 00282 00283 os_event_count--; 00284 00285 os_mutex_exit(os_sync_mutex); 00286 00287 ut_free(event); 00288 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_event_reset | ( | os_event_t | event | ) |
Definition at line 235 of file os0sync.c.
References FALSE, os_event_struct::is_set, os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, and ut_a.
Referenced by buf_flush_try_page(), ib_wqueue_wait(), log_write_up_to(), os_aio_array_free_slot(), os_aio_simulated_put_read_threads_to_sleep(), srv_suspend_mysql_thread(), srv_suspend_thread(), and sync_array_reserve_cell().
00237 : event to reset */ 00238 { 00239 #ifdef __WIN__ 00240 ut_a(event); 00241 00242 ut_a(ResetEvent(event->handle)); 00243 #else 00244 ut_a(event); 00245 00246 os_fast_mutex_lock(&(event->os_mutex)); 00247 00248 if (!event->is_set) { 00249 /* Do nothing */ 00250 } else { 00251 event->is_set = FALSE; 00252 } 00253 00254 os_fast_mutex_unlock(&(event->os_mutex)); 00255 #endif 00256 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_event_set | ( | os_event_t | event | ) |
Definition at line 206 of file os0sync.c.
References os_event_struct::cond_var, os_event_struct::is_set, os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, os_event_struct::signal_count, TRUE, and ut_a.
Referenced by buf_flush_batch(), buf_flush_write_complete(), buf_LRU_get_free_block(), ib_wqueue_add(), innobase_shutdown_for_mysql(), log_flush_do_unlocks(), log_init(), os_aio_array_create(), os_aio_array_free_slot(), os_aio_wake_all_threads_at_shutdown(), row_create_table_for_mysql(), srv_conc_force_exit_innodb(), srv_release_mysql_thread_if_suspended(), srv_release_threads(), srv_suspend_mysql_thread(), sync_arr_wake_threads_if_sema_free(), and sync_array_signal_object().
00208 : event to set */ 00209 { 00210 #ifdef __WIN__ 00211 ut_a(event); 00212 ut_a(SetEvent(event->handle)); 00213 #else 00214 ut_a(event); 00215 00216 os_fast_mutex_lock(&(event->os_mutex)); 00217 00218 if (event->is_set) { 00219 /* Do nothing */ 00220 } else { 00221 event->is_set = TRUE; 00222 event->signal_count += 1; 00223 ut_a(0 == pthread_cond_broadcast(&(event->cond_var))); 00224 } 00225 00226 os_fast_mutex_unlock(&(event->os_mutex)); 00227 #endif 00228 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_event_wait | ( | os_event_t | event | ) |
Definition at line 297 of file os0sync.c.
References os_event_struct::cond_var, err, os_event_struct::is_set, NULL, os_fast_mutex_lock(), os_fast_mutex_unlock(), os_event_struct::os_mutex, os_thread_exit(), os_event_struct::signal_count, SRV_SHUTDOWN_EXIT_THREADS, srv_shutdown_state, TRUE, and ut_a.
Referenced by buf_flush_wait_batch_end(), ib_wqueue_wait(), log_write_up_to(), os_aio_array_reserve_slot(), os_aio_wait_until_no_pending_writes(), os_event_wait_time(), srv_master_thread(), srv_suspend_mysql_thread(), sync_array_free_cell_protected(), and sync_array_wait_event().
00299 : event to wait */ 00300 { 00301 #ifdef __WIN__ 00302 DWORD err; 00303 00304 ut_a(event); 00305 00306 /* Specify an infinite time limit for waiting */ 00307 err = WaitForSingleObject(event->handle, INFINITE); 00308 00309 ut_a(err == WAIT_OBJECT_0); 00310 00311 if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { 00312 os_thread_exit(NULL); 00313 } 00314 #else 00315 ib_longlong old_signal_count; 00316 00317 os_fast_mutex_lock(&(event->os_mutex)); 00318 00319 old_signal_count = event->signal_count; 00320 00321 for (;;) { 00322 if (event->is_set == TRUE 00323 || event->signal_count != old_signal_count) { 00324 00325 os_fast_mutex_unlock(&(event->os_mutex)); 00326 00327 if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { 00328 00329 os_thread_exit(NULL); 00330 } 00331 /* Ok, we may return */ 00332 00333 return; 00334 } 00335 00336 pthread_cond_wait(&(event->cond_var), &(event->os_mutex)); 00337 00338 /* Solaris manual said that spurious wakeups may occur: we 00339 have to check if the event really has been signaled after 00340 we came here to wait */ 00341 } 00342 #endif 00343 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint os_event_wait_time | ( | os_event_t | event, | |
| ulint | time | |||
| ) |
Definition at line 350 of file os0sync.c.
References err, os_event_wait(), OS_SYNC_INFINITE_TIME, OS_SYNC_TIME_EXCEEDED, ut_a, ut_error, and UT_NOT_USED.
00352 : 0 if success, OS_SYNC_TIME_EXCEEDED if 00353 timeout was exceeded */ 00354 os_event_t event, /* in: event to wait */ 00355 ulint time) /* in: timeout in microseconds, or 00356 OS_SYNC_INFINITE_TIME */ 00357 { 00358 #ifdef __WIN__ 00359 DWORD err; 00360 00361 ut_a(event); 00362 00363 if (time != OS_SYNC_INFINITE_TIME) { 00364 err = WaitForSingleObject(event->handle, (DWORD) time / 1000); 00365 } else { 00366 err = WaitForSingleObject(event->handle, INFINITE); 00367 } 00368 00369 if (err == WAIT_OBJECT_0) { 00370 00371 return(0); 00372 } else if (err == WAIT_TIMEOUT) { 00373 00374 return(OS_SYNC_TIME_EXCEEDED); 00375 } else { 00376 ut_error; 00377 return(1000000); /* dummy value to eliminate compiler warn. */ 00378 } 00379 #else 00380 UT_NOT_USED(time); 00381 00382 /* In Posix this is just an ordinary, infinite wait */ 00383 00384 os_event_wait(event); 00385 00386 return(0); 00387 #endif 00388 }
Here is the call graph for this function:

| void os_fast_mutex_free | ( | os_fast_mutex_t * | fast_mutex | ) |
Definition at line 625 of file os0sync.c.
References os_fast_mutex_count, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, os_sync_mutex_inited, pthread_mutex_destroy, ut_a, ut_print_buf(), and ut_print_timestamp().
Referenced by innobase_start_or_create_for_mysql(), mutex_free(), os_event_free(), os_mutex_free(), srv_free(), and ut_free_all_mem().
00627 : mutex to free */ 00628 { 00629 #ifdef __WIN__ 00630 ut_a(fast_mutex); 00631 00632 DeleteCriticalSection((LPCRITICAL_SECTION) fast_mutex); 00633 #else 00634 int ret; 00635 00636 ret = pthread_mutex_destroy(fast_mutex); 00637 00638 if (ret != 0) { 00639 ut_print_timestamp(stderr); 00640 fprintf(stderr, 00641 " InnoDB: error: return value %lu when calling\n" 00642 "InnoDB: pthread_mutex_destroy().\n", (ulint)ret); 00643 fprintf(stderr, 00644 "InnoDB: Byte contents of the pthread mutex at %p:\n", (void*) fast_mutex); 00645 ut_print_buf(stderr, fast_mutex, sizeof(os_fast_mutex_t)); 00646 fprintf(stderr, "\n"); 00647 } 00648 #endif 00649 if (os_sync_mutex_inited) { 00650 /* When freeing the last mutexes, we have 00651 already freed os_sync_mutex */ 00652 00653 os_mutex_enter(os_sync_mutex); 00654 } 00655 00656 os_fast_mutex_count--; 00657 00658 if (os_sync_mutex_inited) { 00659 os_mutex_exit(os_sync_mutex); 00660 } 00661 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_fast_mutex_init | ( | os_fast_mutex_t * | fast_mutex | ) |
Definition at line 562 of file os0sync.c.
References MY_MUTEX_INIT_FAST, os_fast_mutex_count, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, os_sync_mutex_inited, pthread_mutex_init, and ut_a.
Referenced by innobase_start_or_create_for_mysql(), mutex_create_func(), os_event_create(), os_mutex_create(), srv_init(), and UT_LIST_BASE_NODE_T().
00564 : fast mutex */ 00565 { 00566 #ifdef __WIN__ 00567 ut_a(fast_mutex); 00568 00569 InitializeCriticalSection((LPCRITICAL_SECTION) fast_mutex); 00570 #else 00571 #if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10) 00572 ut_a(0 == pthread_mutex_init(fast_mutex, pthread_mutexattr_default)); 00573 #else 00574 ut_a(0 == pthread_mutex_init(fast_mutex, MY_MUTEX_INIT_FAST)); 00575 #endif 00576 #endif 00577 if (os_sync_mutex_inited) { 00578 /* When creating os_sync_mutex itself (in Unix) we cannot 00579 reserve it */ 00580 00581 os_mutex_enter(os_sync_mutex); 00582 } 00583 00584 os_fast_mutex_count++; 00585 00586 if (os_sync_mutex_inited) { 00587 os_mutex_exit(os_sync_mutex); 00588 } 00589 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_fast_mutex_lock | ( | os_fast_mutex_t * | fast_mutex | ) |
Definition at line 595 of file os0sync.c.
References pthread_mutex_lock.
Referenced by innobase_start_or_create_for_mysql(), os_event_reset(), os_event_set(), os_event_wait(), os_mutex_enter(), srv_conc_enter_innodb(), srv_conc_force_enter_innodb(), srv_conc_force_exit_innodb(), ut_free(), and ut_malloc_low().
00597 : mutex to acquire */ 00598 { 00599 #ifdef __WIN__ 00600 EnterCriticalSection((LPCRITICAL_SECTION) fast_mutex); 00601 #else 00602 pthread_mutex_lock(fast_mutex); 00603 #endif 00604 }
Here is the caller graph for this function:

| UNIV_INLINE ulint os_fast_mutex_trylock | ( | os_fast_mutex_t * | fast_mutex | ) |
| void os_fast_mutex_unlock | ( | os_fast_mutex_t * | fast_mutex | ) |
Definition at line 610 of file os0sync.c.
References pthread_mutex_unlock.
Referenced by innobase_start_or_create_for_mysql(), os_event_reset(), os_event_set(), os_event_wait(), os_mutex_exit(), srv_conc_enter_innodb(), srv_conc_force_enter_innodb(), srv_conc_force_exit_innodb(), ut_free(), and ut_malloc_low().
00612 : mutex to release */ 00613 { 00614 #ifdef __WIN__ 00615 LeaveCriticalSection(fast_mutex); 00616 #else 00617 pthread_mutex_unlock(fast_mutex); 00618 #endif 00619 }
Here is the caller graph for this function:

| os_mutex_t os_mutex_create | ( | const char * | name | ) |
Definition at line 431 of file os0sync.c.
References os_mutex_struct::count, FALSE, HANDLE, os_mutex_struct::handle, mutex, NULL, os_fast_mutex_init(), os_mutex_count, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, os_sync_mutex_inited, ut_a, UT_LIST_ADD_FIRST, ut_malloc(), and UT_NOT_USED.
Referenced by os_aio_array_create(), os_io_init_simple(), sync_array_create(), and UT_LIST_BASE_NODE_T().
00433 : the mutex handle */ 00434 const char* name) /* in: the name of the mutex, if NULL 00435 the mutex is created without a name */ 00436 { 00437 #ifdef __WIN__ 00438 HANDLE mutex; 00439 os_mutex_t mutex_str; 00440 00441 mutex = CreateMutex(NULL, /* No security attributes */ 00442 FALSE, /* Initial state: no owner */ 00443 (LPCTSTR) name); 00444 ut_a(mutex); 00445 #else 00446 os_fast_mutex_t* mutex; 00447 os_mutex_t mutex_str; 00448 00449 UT_NOT_USED(name); 00450 00451 mutex = ut_malloc(sizeof(os_fast_mutex_t)); 00452 00453 os_fast_mutex_init(mutex); 00454 #endif 00455 mutex_str = ut_malloc(sizeof(os_mutex_str_t)); 00456 00457 mutex_str->handle = mutex; 00458 mutex_str->count = 0; 00459 00460 if (os_sync_mutex_inited) { 00461 /* When creating os_sync_mutex itself we cannot reserve it */ 00462 os_mutex_enter(os_sync_mutex); 00463 } 00464 00465 UT_LIST_ADD_FIRST(os_mutex_list, os_mutex_list, mutex_str); 00466 00467 os_mutex_count++; 00468 00469 if (os_sync_mutex_inited) { 00470 os_mutex_exit(os_sync_mutex); 00471 } 00472 00473 return(mutex_str); 00474 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_mutex_enter | ( | os_mutex_t | mutex | ) |
Definition at line 480 of file os0sync.c.
References err, mutex, os_fast_mutex_lock(), and ut_a.
Referenced by innobase_shutdown_for_mysql(), os_aio_array_free_slot(), os_aio_array_reserve_slot(), os_aio_array_validate(), os_aio_print(), os_aio_simulated_handle(), os_aio_simulated_wake_handler_thread(), os_event_create(), os_event_free(), os_fast_mutex_free(), os_fast_mutex_init(), os_file_pread(), os_file_pwrite(), os_file_read(), os_file_read_no_error_handling(), os_file_write(), os_mutex_create(), os_mutex_free(), os_thread_create(), os_thread_exit(), and sync_array_enter().
00482 : mutex to acquire */ 00483 { 00484 #ifdef __WIN__ 00485 DWORD err; 00486 00487 ut_a(mutex); 00488 00489 /* Specify infinite time limit for waiting */ 00490 err = WaitForSingleObject(mutex->handle, INFINITE); 00491 00492 ut_a(err == WAIT_OBJECT_0); 00493 00494 (mutex->count)++; 00495 ut_a(mutex->count == 1); 00496 #else 00497 os_fast_mutex_lock(mutex->handle); 00498 00499 (mutex->count)++; 00500 00501 ut_a(mutex->count == 1); 00502 #endif 00503 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_mutex_exit | ( | os_mutex_t | mutex | ) |
Definition at line 509 of file os0sync.c.
References mutex, os_fast_mutex_unlock(), and ut_a.
Referenced by innobase_shutdown_for_mysql(), os_aio_array_free_slot(), os_aio_array_reserve_slot(), os_event_create(), os_event_free(), os_fast_mutex_free(), os_fast_mutex_init(), os_file_pread(), os_file_pwrite(), os_file_read(), os_file_read_no_error_handling(), os_file_write(), os_mutex_create(), os_mutex_free(), os_thread_create(), os_thread_exit(), and sync_array_exit().
00511 : mutex to release */ 00512 { 00513 ut_a(mutex); 00514 00515 ut_a(mutex->count == 1); 00516 00517 (mutex->count)--; 00518 #ifdef __WIN__ 00519 ut_a(ReleaseMutex(mutex->handle)); 00520 #else 00521 os_fast_mutex_unlock(mutex->handle); 00522 #endif 00523 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_mutex_free | ( | os_mutex_t | mutex | ) |
Definition at line 529 of file os0sync.c.
References mutex, os_fast_mutex_free(), os_mutex_count, os_mutex_enter(), os_mutex_exit(), os_sync_mutex, os_sync_mutex_inited, ut_a, ut_free(), and UT_LIST_REMOVE.
Referenced by os_sync_free(), and sync_array_free().
00531 : mutex to free */ 00532 { 00533 ut_a(mutex); 00534 00535 if (os_sync_mutex_inited) { 00536 os_mutex_enter(os_sync_mutex); 00537 } 00538 00539 UT_LIST_REMOVE(os_mutex_list, os_mutex_list, mutex); 00540 00541 os_mutex_count--; 00542 00543 if (os_sync_mutex_inited) { 00544 os_mutex_exit(os_sync_mutex); 00545 } 00546 00547 #ifdef __WIN__ 00548 ut_a(CloseHandle(mutex->handle)); 00549 00550 ut_free(mutex); 00551 #else 00552 os_fast_mutex_free(mutex->handle); 00553 ut_free(mutex->handle); 00554 ut_free(mutex); 00555 #endif 00556 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_sync_free | ( | void | ) |
Definition at line 73 of file os0sync.c.
References FALSE, mutex, os_event_free(), os_mutex_free(), os_sync_mutex, os_sync_mutex_inited, and UT_LIST_GET_FIRST.
Referenced by innobase_shutdown_for_mysql().
00075 { 00076 os_event_t event; 00077 os_mutex_t mutex; 00078 00079 event = UT_LIST_GET_FIRST(os_event_list); 00080 00081 while (event) { 00082 00083 os_event_free(event); 00084 00085 event = UT_LIST_GET_FIRST(os_event_list); 00086 } 00087 00088 mutex = UT_LIST_GET_FIRST(os_mutex_list); 00089 00090 while (mutex) { 00091 if (mutex == os_sync_mutex) { 00092 /* Set the flag to FALSE so that we do not try to 00093 reserve os_sync_mutex any more in remaining freeing 00094 operations in shutdown */ 00095 os_sync_mutex_inited = FALSE; 00096 } 00097 00098 os_mutex_free(mutex); 00099 00100 mutex = UT_LIST_GET_FIRST(os_mutex_list); 00101 } 00102 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void os_sync_init | ( | void | ) |
Referenced by innobase_shutdown_for_mysql(), os_event_create(), and os_event_free().
Referenced by innobase_shutdown_for_mysql(), os_fast_mutex_free(), and os_fast_mutex_init().
Referenced by innobase_shutdown_for_mysql(), os_mutex_create(), and os_mutex_free().
Definition at line 36 of file os0sync.c.
Referenced by innobase_shutdown_for_mysql(), os_event_create(), os_event_free(), os_fast_mutex_free(), os_fast_mutex_init(), os_mutex_create(), os_mutex_free(), os_sync_free(), os_thread_create(), os_thread_exit(), and UT_LIST_BASE_NODE_T().
Definition at line 41 of file os0sync.c.
Referenced by innobase_shutdown_for_mysql(), os_thread_create(), and os_thread_exit().
1.4.7

