CUBRID Engine  latest
critical_section.c File Reference
#include "critical_section.h"
#include "connection_defs.h"
#include "connection_error.h"
#include "config.h"
#include "critical_section_tracker.hpp"
#include "dbtype.h"
#include "numeric_opfunc.h"
#include "perf_monitor.h"
#include "porting.h"
#include "resource_tracker.hpp"
#include "show_scan.h"
#include "system_parameter.h"
#include "thread_entry.hpp"
#include "thread_manager.hpp"
#include "tsc_timer.h"
#include <stdio.h>
#include <assert.h>
Include dependency graph for critical_section.c:

Go to the source code of this file.

Classes

struct  sync_stats_chunk
 

Macros

#define TOTAL_AND_MAX_TIMEVAL(total, max, elapsed)
 
#define NUM_ENTRIES_OF_SYNC_STATS_BLOCK   256
 

Typedefs

typedef struct sync_stats_chunk SYNC_STATS_CHUNK
 

Functions

static const char * csect_name (SYNC_CRITICAL_SECTION *c)
 
const char * csect_name_at (int cs_index)
 
static int csect_wait_on_writer_queue (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int timeout, struct timespec *to)
 
static int csect_wait_on_promoter_queue (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int timeout, struct timespec *to)
 
static int csect_wakeup_waiting_writer (SYNC_CRITICAL_SECTION *csect)
 
static int csect_wakeup_waiting_promoter (SYNC_CRITICAL_SECTION *csect)
 
static int csect_demote_critical_section (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int wait_secs)
 
static int csect_promote_critical_section (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int wait_secs)
 
static int csect_check_own_critical_section (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect)
 
static SYNC_STATS_CHUNKsync_allocate_sync_stats_chunk (void)
 
static int sync_initialize_sync_stats_chunk (SYNC_STATS_CHUNK *sync_stats_chunk)
 
static SYNC_STATSsync_consume_sync_stats_from_pool (SYNC_STATS_CHUNK *sync_stats_chunk, int idx, SYNC_PRIMITIVE_TYPE sync_prim_type, const char *name)
 
static int sync_return_sync_stats_to_pool (SYNC_STATS_CHUNK *sync_stats_chunk, int idx)
 
static SYNC_STATSsync_allocate_sync_stats (SYNC_PRIMITIVE_TYPE sync_prim_type, const char *name)
 
static int sync_deallocate_sync_stats (SYNC_STATS *stats)
 
static void sync_reset_stats_metrics (SYNC_STATS *stats)
 
int csect_initialize_critical_section (SYNC_CRITICAL_SECTION *csect, const char *name)
 
int csect_finalize_critical_section (SYNC_CRITICAL_SECTION *csect)
 
int csect_initialize_static_critical_sections (void)
 
int csect_finalize_static_critical_sections (void)
 
int csect_enter_critical_section (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int wait_secs)
 
int csect_enter (THREAD_ENTRY *thread_p, int cs_index, int wait_secs)
 
int csect_enter_critical_section_as_reader (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect, int wait_secs)
 
int csect_enter_as_reader (THREAD_ENTRY *thread_p, int cs_index, int wait_secs)
 
int csect_demote (THREAD_ENTRY *thread_p, int cs_index, int wait_secs)
 
int csect_promote (THREAD_ENTRY *thread_p, int cs_index, int wait_secs)
 
int csect_exit_critical_section (THREAD_ENTRY *thread_p, SYNC_CRITICAL_SECTION *csect)
 
int csect_exit (THREAD_ENTRY *thread_p, int cs_index)
 
void csect_dump_statistics (FILE *fp)
 
int csect_check_own (THREAD_ENTRY *thread_p, int cs_index)
 
int csect_start_scan (THREAD_ENTRY *thread_p, int show_type, DB_VALUE **arg_values, int arg_cnt, void **ptr)
 
int rwlock_initialize (SYNC_RWLOCK *rwlock, const char *name)
 
int rwlock_finalize (SYNC_RWLOCK *rwlock)
 
int rwlock_read_lock (SYNC_RWLOCK *rwlock)
 
int rwlock_read_unlock (SYNC_RWLOCK *rwlock)
 
int rwlock_write_lock (SYNC_RWLOCK *rwlock)
 
int rwlock_write_unlock (SYNC_RWLOCK *rwlock)
 
void rwlock_dump_statistics (FILE *fp)
 
int rmutex_initialize (SYNC_RMUTEX *rmutex, const char *name)
 
int rmutex_finalize (SYNC_RMUTEX *rmutex)
 
int rmutex_lock (THREAD_ENTRY *thread_p, SYNC_RMUTEX *rmutex)
 
int rmutex_unlock (THREAD_ENTRY *thread_p, SYNC_RMUTEX *rmutex)
 
int sync_initialize_sync_stats (void)
 
int sync_finalize_sync_stats (void)
 
void rmutex_dump_statistics (FILE *fp)
 
void sync_dump_statistics (FILE *fp, SYNC_PRIMITIVE_TYPE type)
 

Variables

SYNC_CRITICAL_SECTION csectgl_Critical_sections [CRITICAL_SECTION_COUNT]
 
static const char * csect_Names []
 
SYNC_STATS_CHUNK sync_Stats
 
pthread_mutex_t sync_Stats_lock
 

Macro Definition Documentation

#define TOTAL_AND_MAX_TIMEVAL (   total,
  max,
  elapsed 
)
Value:
do \
{ \
(total).tv_sec += elapsed.tv_sec; \
(total).tv_usec += elapsed.tv_usec; \
(total).tv_sec += (total).tv_usec / 1000000; \
(total).tv_usec %= 1000000; \
if (((max).tv_sec < elapsed.tv_sec) || ((max).tv_sec == elapsed.tv_sec && (max).tv_usec < elapsed.tv_usec)) \
{ \
(max).tv_sec = elapsed.tv_sec; \
(max).tv_usec = elapsed.tv_usec; \
} \
} \
while (0)
if(extra_options)
Definition: dynamic_load.c:958
#define max(a, b)
while(1)
Definition: cnvlex.c:816

Definition at line 56 of file critical_section.c.

Referenced by csect_demote_critical_section(), csect_enter_critical_section(), csect_enter_critical_section_as_reader(), csect_promote_critical_section(), rmutex_lock(), rwlock_read_lock(), and rwlock_write_lock().

Typedef Documentation

Definition at line 113 of file critical_section.c.

Function Documentation

int csect_check_own ( THREAD_ENTRY thread_p,
int  cs_index 
)
static int csect_check_own_critical_section ( THREAD_ENTRY thread_p,
SYNC_CRITICAL_SECTION csect 
)
static
int csect_demote ( THREAD_ENTRY thread_p,
int  cs_index,
int  wait_secs 
)

Definition at line 1147 of file critical_section.c.

References assert, CRITICAL_SECTION_COUNT, and csect_demote_critical_section().

Referenced by LOG_CS_DEMOTE().

Here is the caller graph for this function:

void csect_dump_statistics ( FILE *  fp)
int csect_enter ( THREAD_ENTRY thread_p,
int  cs_index,
int  wait_secs 
)
int csect_enter_as_reader ( THREAD_ENTRY thread_p,
int  cs_index,
int  wait_secs 
)
int csect_exit ( THREAD_ENTRY thread_p,
int  cs_index 
)
int csect_finalize_static_critical_sections ( void  )

Definition at line 266 of file critical_section.c.

References assert, CRITICAL_SECTION_COUNT, sync_critical_section::cs_index, csect_finalize_critical_section(), i, and NO_ERROR.

Referenced by net_server_start().

Here is the caller graph for this function:

int csect_initialize_static_critical_sections ( void  )

Definition at line 240 of file critical_section.c.

References CRITICAL_SECTION_COUNT, sync_critical_section::cs_index, csect_initialize_critical_section(), csect_Names, i, and NO_ERROR.

Referenced by net_server_start().

Here is the caller graph for this function:

const char* csect_name_at ( int  cs_index)

Definition at line 101 of file critical_section.c.

References assert, CRITICAL_SECTION_COUNT, and csect_Names.

Referenced by cubsync::critical_section_tracker::check().

Here is the caller graph for this function:

int csect_promote ( THREAD_ENTRY thread_p,
int  cs_index,
int  wait_secs 
)

Definition at line 1356 of file critical_section.c.

References assert, CRITICAL_SECTION_COUNT, and csect_promote_critical_section().

Referenced by LOG_CS_PROMOTE().

Here is the caller graph for this function:

static int csect_wait_on_promoter_queue ( THREAD_ENTRY thread_p,
SYNC_CRITICAL_SECTION csect,
int  timeout,
struct timespec *  to 
)
static
static int csect_wait_on_writer_queue ( THREAD_ENTRY thread_p,
SYNC_CRITICAL_SECTION csect,
int  timeout,
struct timespec *  to 
)
static
static int csect_wakeup_waiting_promoter ( SYNC_CRITICAL_SECTION csect)
static

Definition at line 446 of file critical_section.c.

References NO_ERROR, NULL, THREAD_CSECT_PROMOTER_RESUMED, thread_wakeup(), and sync_critical_section::waiting_promoters_queue.

Referenced by csect_enter_critical_section(), and csect_exit_critical_section().

Here is the caller graph for this function:

static int csect_wakeup_waiting_writer ( SYNC_CRITICAL_SECTION csect)
static

Definition at line 427 of file critical_section.c.

References NO_ERROR, NULL, THREAD_CSECT_WRITER_RESUMED, thread_wakeup(), and sync_critical_section::waiting_writers_queue.

Referenced by csect_exit_critical_section().

Here is the caller graph for this function:

static SYNC_STATS_CHUNK * sync_allocate_sync_stats_chunk ( void  )
static

Definition at line 2329 of file critical_section.c.

References ARG_FILE_LINE, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), NULL, p, and sync_initialize_sync_stats_chunk().

Referenced by sync_allocate_sync_stats().

Here is the caller graph for this function:

static SYNC_STATS * sync_consume_sync_stats_from_pool ( SYNC_STATS_CHUNK sync_stats_chunk,
int  idx,
SYNC_PRIMITIVE_TYPE  sync_prim_type,
const char *  name 
)
static
void sync_dump_statistics ( FILE *  fp,
SYNC_PRIMITIVE_TYPE  type 
)
int sync_finalize_sync_stats ( void  )
int sync_initialize_sync_stats ( void  )
static int sync_initialize_sync_stats_chunk ( SYNC_STATS_CHUNK sync_stats_chunk)
static
static void sync_reset_stats_metrics ( SYNC_STATS stats)
static
static int sync_return_sync_stats_to_pool ( SYNC_STATS_CHUNK sync_stats_chunk,
int  idx 
)
static

Variable Documentation

const char* csect_Names[]
static
Initial value:
= {
"WFG",
"LOG",
"LOCATOR_CLASSNAME_TABLE",
"QPROC_QUERY_TABLE",
"QPROC_LIST_CACHE",
"DISK_CHECK",
"CNV_FMT_LEXER",
"HEAP_CHNGUESS",
"TRAN_TABLE",
"CT_OID_TABLE",
"HA_SERVER_STATE",
"COMPACTDB_ONE_INSTANCE",
"ACL",
"PARTITION_CACHE",
"EVENT_LOG_FILE",
"LOG_ARCHIVE",
"ACCESS_STATUS"
}

Definition at line 74 of file critical_section.c.

Referenced by csect_initialize_static_critical_sections(), and csect_name_at().

SYNC_CRITICAL_SECTION csectgl_Critical_sections[CRITICAL_SECTION_COUNT]

Definition at line 72 of file critical_section.c.