src/core/sentinel.h File Reference

Sentinel manager interface. More...

#include <misc/result.h>

Go to the source code of this file.

Defines

#define TXC_SENTINEL_ACQUIRED   0x1
#define TXC_SENTINEL_ACQUIREONRETRY   0x2

Typedefs

typedef txc_tx_s txc_tx_t
typedef txc_sentinel_s txc_sentinel_t
typedef pool_element_sentinel_s pool_element_sentinel_t
typedef txc_sentinelmgr_s txc_sentinelmgr_t
typedef txc_sentinel_list_s txc_sentinel_list_t
typedef txc_sentinel_list_entry_s txc_sentinel_list_entry_t

Functions

txc_result_t txc_sentinelmgr_create (txc_sentinelmgr_t **)
 Creates a sentinel manager.
void txc_sentinelmgr_destroy (txc_sentinelmgr_t **sentinelmgrp)
 Destroys a sentinel manager.
txc_result_t txc_sentinel_create (txc_sentinelmgr_t *, txc_sentinel_t **)
void txc_sentinel_destroy (txc_sentinel_t *)
 Destroys a sentinel.
txc_result_t txc_sentinel_list_create (txc_sentinelmgr_t *sentinelmgr, txc_sentinel_list_t **sentinel_list)
 Create a sentinel list.
txc_result_t txc_sentinel_detach (txc_sentinel_t *sentinel)
 Detaches from a sentinel.
txc_result_t txc_sentinel_list_destroy (txc_sentinel_list_t **sentinel_list)
 Destroy a sentinel list.
txc_result_t txc_sentinel_list_init (txc_sentinel_list_t *sentinel_list)
 Initialize a sentinel list.
txc_result_t txc_sentinel_tryacquire (txc_tx_t *, txc_sentinel_t *, int)
 Try to acquire a sentinel.
void txc_sentinel_transaction_postbegin (txc_tx_t *txd)
void txc_sentinelmgr_print_pools (txc_sentinelmgr_t *sentinelmgr)
txc_tx_ttxc_sentinel_owner (txc_sentinel_t *sentinel)
txc_result_t txc_sentinel_is_enlisted (txc_tx_t *txd, txc_sentinel_t *sentinel)
txc_result_t txc_sentinel_enlist (txc_tx_t *txd, txc_sentinel_t *sentinel, int flags)
 Enlist the sentinel in the transaction's sentinel list.
void txc_sentinel_register_sentinelmgr_commit_action (txc_tx_t *txd)
void txc_sentinel_register_sentinelmgr_undo_action (txc_tx_t *txd)

Variables

txc_sentinelmgr_ttxc_g_sentinelmgr


Detailed Description

Sentinel manager interface.

Definition in file sentinel.h.


Define Documentation

#define TXC_SENTINEL_ACQUIRED   0x1

Sentinel has been acquired. Drop it when transaction completes (commit/abort) or restarts execution.

Definition at line 13 of file sentinel.h.

#define TXC_SENTINEL_ACQUIREONRETRY   0x2

Acquire the sentinel after transaction restarts.

Definition at line 14 of file sentinel.h.

Referenced by txc_sentinel_enlist(), txc_sentinel_tryacquire(), x_close(), x_dup(), x_fsync(), x_lseek(), x_read(), x_rename(), x_sendmsg(), x_unlink(), and x_write_pipe().


Function Documentation

void txc_sentinel_destroy ( txc_sentinel_t sentinel  ) 

Destroys a sentinel.

Parameters:
[in] sentinel The sentinel to destroy (deallocate).

Definition at line 252 of file sentinel.c.

References txc_sentinel_s::synch_mutex, TXC_ASSERT, TXC_MUTEX_LOCK, and TXC_MUTEX_UNLOCK.

txc_result_t txc_sentinel_detach ( txc_sentinel_t sentinel  ) 

Detaches from a sentinel.

It logically detaches from the sentinel by decrementing the sentinel's refererence counter. If reference counter becomes zero then sentinel is destroyed.

Parameters:
[in] sentinel The sentinel to detach from.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 294 of file sentinel.c.

References txc_sentinel_s::synch_mutex, TXC_MUTEX_LOCK, and TXC_MUTEX_UNLOCK.

Referenced by txc_koa_destroy().

txc_result_t txc_sentinel_enlist ( txc_tx_t txd,
txc_sentinel_t sentinel,
int  flags 
)

Enlist the sentinel in the transaction's sentinel list.

It also attaches to the sentinel by bumping up the sentinel's refcount via a call to sentinel_attach().

Parameters:
[in] txd Transactional descriptor.
[in] sentinel Sentinel to enlist.
[in] flags TXC_SENTINEL_ACQUIREONRETRY
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 730 of file sentinel.c.

References txc_tx_s::sentinel_list, txc_sentinel_s::synch_mutex, TXC_MUTEX_LOCK, TXC_MUTEX_UNLOCK, TXC_R_SUCCESS, and TXC_SENTINEL_ACQUIREONRETRY.

txc_result_t txc_sentinel_list_create ( txc_sentinelmgr_t sentinelmgr,
txc_sentinel_list_t **  sentinel_list 
)

Create a sentinel list.

Parameters:
[in] sentinelmgr Sentinel manager responsible for the sentinel list.
[in,out] sentinel_list Pointer to the created sentinel list.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 618 of file sentinel.c.

References FREE, MALLOC, TXC_R_NOMEMORY, TXC_R_SUCCESS, and TXC_SENTINEL_LIST_SIZE.

Referenced by txc_txmgr_create().

txc_result_t txc_sentinel_list_destroy ( txc_sentinel_list_t **  sentinel_list  ) 

Destroy a sentinel list.

Deallocate sentinel list entries and then deallocates the list itself

Parameters:
[in,out] sentinel_list Pointer to the sentinel list to deallocate. Pointer will point to NULL after return.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 669 of file sentinel.c.

References FREE, and TXC_R_SUCCESS.

Referenced by txc_txmgr_destroy().

txc_result_t txc_sentinel_list_init ( txc_sentinel_list_t sentinel_list  ) 

Initialize a sentinel list.

Parameters:
[in] sentinel_list Sentinel list to deallocate.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 651 of file sentinel.c.

References txc_sentinel_list_s::num_entries, and TXC_R_SUCCESS.

Referenced by txc_tx_create().

txc_result_t txc_sentinel_tryacquire ( txc_tx_t txd,
txc_sentinel_t sentinel,
int  flags 
)

Try to acquire a sentinel.

It will try to acquire the sentinel. If sentinel is acquired it will enlist it in the transaction's sentinel list as acquired, otherwise if the sentinel is not acquired (busy) it will return without block-waiting for the sentinel to become free (prevent deadlock).

Parameters:
[in] txd Transactional descriptor.
[in] sentinel Sentinel to acquire.
[in] flags TXC_SENTINEL_ACQUIRED, TXC_SENTINEL_ACQUIREONRETRY
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 759 of file sentinel.c.

References txc_sentinel_s::id, txc_sentinel_s::owner, txc_sentinel_s::sentinel_mutex, txc_sentinel_s::synch_mutex, TXC_ASSERT, TXC_DEBUG_PRINT, TXC_INTERNALERROR, TXC_MUTEX_LOCK, TXC_MUTEX_TRYLOCK, TXC_MUTEX_UNLOCK, TXC_R_BUSYSENTINEL, TXC_R_SUCCESS, txc_runtime_settings, TXC_SENTINEL_ACQUIREONRETRY, txc_sentinel_is_enlisted(), txc_sentinel_owner(), and txc_tx_get_xactstate().

Referenced by x_close(), x_create(), x_dup(), x_fsync(), x_lseek(), x_open(), x_pipe(), x_read(), x_rename(), x_sendmsg(), x_socket(), x_unlink(), and x_write_pipe().

txc_result_t txc_sentinelmgr_create ( txc_sentinelmgr_t **  sentinelmgrp  ) 

Creates a sentinel manager.

It preallocates a pool of sentinels to make sentinel allocation fast.

Parameters:
[out] sentinelmgrp Pointer to the created sentinel manager.
Returns:
Code indicating success or failure (reason) of the operation.

Definition at line 158 of file sentinel.c.

References FREE, txc_sentinel_s::id, MALLOC, txc_sentinel_s::manager, txc_sentinel_s::owner, txc_sentinel_s::sentinel_mutex, txc_sentinel_s::synch_mutex, TXC_MUTEX_INIT, txc_pool_create(), TXC_POOL_OBJECT_ALLOCATED, txc_pool_object_first(), TXC_POOL_OBJECT_FREE, txc_pool_object_next(), txc_pool_object_of(), TXC_R_NOMEMORY, TXC_R_SUCCESS, TXC_SENTINEL_NOOWNER, and TXC_SENTINEL_NUM.

Referenced by _TXC_global_init().

void txc_sentinelmgr_destroy ( txc_sentinelmgr_t **  sentinelmgrp  ) 

Destroys a sentinel manager.

It deallocates all sentinels that it manages.

Parameters:
[in,out] sentinelmgrp Poitner to the sentinel manager to be destroyed.

Definition at line 206 of file sentinel.c.

References FREE, and txc_pool_destroy().


Generated on Wed Dec 9 20:32:40 2009 for xCalls by  doxygen 1.4.7