kernel_mutex--mysql5.5.18

在mysql innodb中,随处可见的kernel_mutex。全局锁,事务开始的一段代码段 /trx/trx0trx.c 中 trx_start()函数

/****************************************************************//**
Starts a new transaction.
@return    TRUE */
UNIV_INTERN
ibool
trx_start(
/*======*/
    trx_t*    trx,    /*!< in: transaction */
    ulint    rseg_id)/*!< in: rollback segment id; if ULINT_UNDEFINED
            is passed, the system chooses the rollback segment
            automatically in a round-robin fashion */
{
    ibool    ret;

    /* Update the info whether we should skip XA steps that eat CPU time
    For the duration of the transaction trx->support_xa is not reread
    from thd so any changes in the value take effect in the next
    transaction. This is to avoid a scenario where some undo
    generated by a transaction, has XA stuff, and other undo,
    generated by the same transaction, doesn't. */
    trx->support_xa = thd_supports_xa(trx->mysql_thd);

    mutex_enter(&kernel_mutex);

    ret = trx_start_low(trx, rseg_id);

    mutex_exit(&kernel_mutex);

    return(ret);
}


http://blog.csdn.net/zhaiwx1987/article/details/7108610

你可能感兴趣的:(MySQL源码)