~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/sync0arr.h

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/sync0arr.h
20
21
The wait array used in synchronization primitives
21
22
 
22
23
Created 9/5/1995 Heikki Tuuri
30
31
#include "ut0mem.h"
31
32
#include "os0thread.h"
32
33
 
 
34
/** Synchronization wait array cell */
33
35
typedef struct sync_cell_struct         sync_cell_t;
 
36
/** Synchronization wait array */
34
37
typedef struct sync_array_struct        sync_array_t;
35
38
 
36
 
#define SYNC_ARRAY_OS_MUTEX     1
37
 
#define SYNC_ARRAY_MUTEX        2
 
39
/** Parameters for sync_array_create() @{ */
 
40
#define SYNC_ARRAY_OS_MUTEX     1       /*!< protected by os_mutex_t */
 
41
#define SYNC_ARRAY_MUTEX        2       /*!< protected by mutex_t */
 
42
/* @} */
38
43
 
39
 
/***********************************************************************
 
44
/*******************************************************************//**
40
45
Creates a synchronization wait array. It is protected by a mutex
41
46
which is automatically reserved when the functions operating on it
42
 
are called. */
 
47
are called.
 
48
@return own: created wait array */
43
49
UNIV_INTERN
44
50
sync_array_t*
45
51
sync_array_create(
46
52
/*==============*/
47
 
                                /* out, own: created wait array */
48
 
        ulint   n_cells,        /* in: number of cells in the array
 
53
        ulint   n_cells,        /*!< in: number of cells in the array
49
54
                                to create */
50
 
        ulint   protection);    /* in: either SYNC_ARRAY_OS_MUTEX or
 
55
        ulint   protection);    /*!< in: either SYNC_ARRAY_OS_MUTEX or
51
56
                                SYNC_ARRAY_MUTEX: determines the type
52
57
                                of mutex protecting the data structure */
53
 
/**********************************************************************
 
58
/******************************************************************//**
54
59
Frees the resources in a wait array. */
55
60
UNIV_INTERN
56
61
void
57
62
sync_array_free(
58
63
/*============*/
59
 
        sync_array_t*   arr);   /* in, own: sync wait array */
60
 
/**********************************************************************
 
64
        sync_array_t*   arr);   /*!< in, own: sync wait array */
 
65
/******************************************************************//**
61
66
Reserves a wait array cell for waiting for an object.
62
67
The event of the cell is reset to nonsignalled state. */
63
68
UNIV_INTERN
64
69
void
65
70
sync_array_reserve_cell(
66
71
/*====================*/
67
 
        sync_array_t*   arr,    /* in: wait array */
68
 
        void*           object, /* in: pointer to the object to wait for */
69
 
        ulint           type,   /* in: lock request type */
70
 
        const char*     file,   /* in: file where requested */
71
 
        ulint           line,   /* in: line where requested */
72
 
        ulint*          index); /* out: index of the reserved cell */
73
 
/**********************************************************************
 
72
        sync_array_t*   arr,    /*!< in: wait array */
 
73
        void*           object, /*!< in: pointer to the object to wait for */
 
74
        ulint           type,   /*!< in: lock request type */
 
75
        const char*     file,   /*!< in: file where requested */
 
76
        ulint           line,   /*!< in: line where requested */
 
77
        ulint*          index); /*!< out: index of the reserved cell */
 
78
/******************************************************************//**
74
79
This function should be called when a thread starts to wait on
75
80
a wait array cell. In the debug version this function checks
76
81
if the wait for a semaphore will result in a deadlock, in which
79
84
void
80
85
sync_array_wait_event(
81
86
/*==================*/
82
 
        sync_array_t*   arr,    /* in: wait array */
83
 
        ulint           index);  /* in: index of the reserved cell */
84
 
/**********************************************************************
 
87
        sync_array_t*   arr,    /*!< in: wait array */
 
88
        ulint           index);  /*!< in: index of the reserved cell */
 
89
/******************************************************************//**
85
90
Frees the cell. NOTE! sync_array_wait_event frees the cell
86
91
automatically! */
87
92
UNIV_INTERN
88
93
void
89
94
sync_array_free_cell(
90
95
/*=================*/
91
 
        sync_array_t*   arr,    /* in: wait array */
92
 
        ulint           index); /* in: index of the cell in array */
93
 
/**************************************************************************
 
96
        sync_array_t*   arr,    /*!< in: wait array */
 
97
        ulint           index); /*!< in: index of the cell in array */
 
98
/**********************************************************************//**
94
99
Note that one of the wait objects was signalled. */
95
100
UNIV_INTERN
96
101
void
97
102
sync_array_object_signalled(
98
103
/*========================*/
99
 
        sync_array_t*   arr);   /* in: wait array */
100
 
/**************************************************************************
 
104
        sync_array_t*   arr);   /*!< in: wait array */
 
105
/**********************************************************************//**
101
106
If the wakeup algorithm does not work perfectly at semaphore relases,
102
107
this function will do the waking (see the comment in mutex_exit). This
103
108
function should be called about every 1 second in the server. */
105
110
void
106
111
sync_arr_wake_threads_if_sema_free(void);
107
112
/*====================================*/
108
 
/**************************************************************************
109
 
Prints warnings of long semaphore waits to stderr. */
 
113
/**********************************************************************//**
 
114
Prints warnings of long semaphore waits to stderr.
 
115
@return TRUE if fatal semaphore wait threshold was exceeded */
110
116
UNIV_INTERN
111
117
ibool
112
118
sync_array_print_long_waits(void);
113
119
/*=============================*/
114
 
                        /* out: TRUE if fatal semaphore wait threshold
115
 
                        was exceeded */
116
 
/************************************************************************
 
120
/********************************************************************//**
117
121
Validates the integrity of the wait array. Checks
118
122
that the number of reserved cells equals the count variable. */
119
123
UNIV_INTERN
120
124
void
121
125
sync_array_validate(
122
126
/*================*/
123
 
        sync_array_t*   arr);   /* in: sync wait array */
124
 
/**************************************************************************
 
127
        sync_array_t*   arr);   /*!< in: sync wait array */
 
128
/**********************************************************************//**
125
129
Prints info of the wait array. */
126
130
UNIV_INTERN
127
131
void
128
132
sync_array_print_info(
129
133
/*==================*/
130
 
        FILE*           file,   /* in: file where to print */
131
 
        sync_array_t*   arr);   /* in: wait array */
 
134
        FILE*           file,   /*!< in: file where to print */
 
135
        sync_array_t*   arr);   /*!< in: wait array */
132
136
 
133
137
 
134
138
#ifndef UNIV_NONINL