Benchmarks Documentation Examples Repository Blog Contact

Transcation subsystem

Where exclusivity is needed, transactions are used in place of mutexes. Transactions provide a means of ensuring that the internal state of program has been consistent thorough the execution of transaction.

  • read-only transactions - these provide guarantee that the internal state of the system did not change while the transaction was computing the result. If any modification to the system state happened during the transaction, an attempt to commit read-only transaction will fail.
  • read-write transactions - these provide means of gaining exclusive right to modify the system state. When code is ready to perform the modification, it attempts to commit the transaction. If there was no concurrent modification in between this transaction has been created, then commit is granted an code can perform the modification in exclusive state. read-only transactions - these provide guarantee that the internal state of the system did not change while the transaction was computing the result. If any modification to the system state happened during the transaction, an attempt to commit read-only transaction will fail.read-write transactions - these provide means of gaining exclusive right to modify the system state. When code is ready to perform the modification, it attempts to commit the transaction. If there was no concurrent modification in between this transaction has been created, then commit is granted an code can perform the modification in exclusive state.

This approach trades better SMP capabilities and less contention for a bit of complexity on the user side. Any code that uses transactions has to define what will happen if transaction commit fails.

For most use cases the way to deal with transaction commit failure is to redo the action but some of them may figure out that the action is not needed anymore.

Enumeration

Unknown member type TxnType

Type Definitons

typedef uint8_t Txn_t

Transaction handle type.

Functions

os_txn_start()

This function will start a transaction. Starting a transaction means that the code will remember actual record version number (active rolling counter value). rolling counters are updated whenever read-write transaction is commited. It is perfectly valid to start transaction and not commit it. This effectively equals to voluntarily aborting the transaction. Such abandonned transactions pose no overhead nor stall / corruption risk. transaction ID

int os_txn_commit(Txn_t transaction, enum TxnType type)

This function will try to enter the critical section so that the code running afterwards has exclusive access to the shared resource. If another transaction has been commited meanwhile, then this call will fail as transaction couldn’t be commited. Then the critical section is left immediately. If no other transaction conflicted with this one, the code remains in the critical section and can modify the shared context. After the code is done with modifying the shared context, it mustos_txn_done

transaction the ID of transaction as obtained by the call to ox_txn_start()

type the type of transaction E_OK if transaction can be commited E_INVALID if transaction cannot be applied as different transaction has been commited meanwhile.

  • transaction the ID of transaction as obtained by the call to ox_txn_start()
  • type the type of transaction

Returns E_OK if transaction can be commited

int os_txn_start_commit()

This is a combination of os_txn_startos_txn_commitos_txn_doneE_OK as this action never fails.

void os_txn_done()

This function will leave the critical section related to the transaction. This function has to be called for read-write transaction after all the data changes in the transaction were commited.

os_sys_txn_start(Txn_t *domain)

This function performs some additional argument checking.

domain domain in which transactions are allocated transaction identifier within given domain

  • domain domain in which transactions are allocated

Returns transaction identifier within given domain

int os_sys_txn_commit(Txn_t *domain, Txn_t txn, enum TxnType type)

This function performs some additional argument checking.

domain domain in which transactions are allocated

txn identifier of transaction to be committed

type identifies if transaction is read-only or read-write E_OK if transaction was committed. E_INVALID if transaction cannot be applied as different transaction has been committed meanwhile.

  • domain domain in which transactions are allocated
  • txn identifier of transaction to be committed
  • type identifies if transaction is read-only or read-write

Returns E_OK if transaction was committed. E_INVALID if transaction cannot be applied as different transaction has been committed meanwhile.

64kB of protected memory ought to be enough for everyone.