# rt_policy_strict

> ## Directory

> > eXtremeDB_rt/samples/rt_policy_strict

> ## Description

> > rt_policy_strict illustrates the strict deadline policy.

> ## Used API

> > mco_trans_rt_start(), mco_trans_commit(), mco_get_last_error(), mco_trans_rt_set_params()

> ## Code snippet

> >         mco_bool strict_policy_transaction(mco_db_h db, unsigned int n_ops)
> >         {
> >             ...

> >             /* Start the transaction passing the deadline through the tx_params */
> >             tx_params.deadline = 100;
> >             start_ts = mco_system_get_current_time();
> >             CHECK(mco_trans_rt_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &tx_params, &t));

> >             /* Continue work until we have something to do and transaction is not aborted
> >              * either due to timeout expiration either because of some other database error.
> >              */
> >             for (n = 0; n < n_ops && mco_get_last_error(t) == MCO_S_OK; ++n) {
> >                 Measurement obj;
> >                 int id = lcg_rand() % N_OBJECTS;

> >                 rc = Measurement_pk_find(t, id, &obj);

> >                if (rc == MCO_S_NOTFOUND) {
> >                     rc = Measurement_new(t, &obj);
> >                     if (rc == MCO_S_OK) {
> >                         Measurement_id_put(&obj, id);
> >                         Measurement_checkpoint(&obj);
> >                     }
> >                     n_insert++;
> >                 }
> >                 if (rc == MCO_S_OK) {
> >                     Measurement_val_put(&obj, id * 3.1415);
> >                     if (lcg_rand() % 5 == 3) {
> >                         Measurement_delete(&obj);
> >                         n_delete++;
> >                     } else {
> >                         n_update++;
> >                     }
> >                 }
> >             }
> >             commit_rc = mco_trans_commit(t);
> >             commit_ts = mco_system_get_current_time();
> >             commit_rc = mco_trans_commit(t);
> >             commit_ts = mco_system_get_current_time();
> >             if (commit_rc != MCO_S_OK) {
> >                 CHECK(mco_rollback_buf_info(t, &rb_info));
> >                 do {
> >                     tx_params.deadline += 1;///tx_params.deadline / 10;
> >                     CHECK(mco_trans_rt_set_params(t, &tx_params));
> >                     rback_rc = mco_trans_rollback(t);
> >                     n_rollback++;
> >                 } while (rback_rc == MCO_E_INTERRUPTED);
> >                 CHECK(rback_rc);
> >             }

> >             ...

> ## What to expect as an output

> >         Set memory throughput to 293 Mbytes/sec

> >         Transaction deadline 100, acutal time 4367.
> >             Workload  : #ops 1000 (#inserts 993 + #updates 797 + #deletes 203)
> >             Commit    : SUCCESS
> >             DB stat   : #objects 790. Free pages 130128 of 131011

> >         Transaction deadline 100, acutal time 5591.
> >             Workload  : #ops 1500 (#inserts 1481 + #updates 1195 + #deletes 305)
> >             Commit    : SUCCESS
> >             DB stat   : #objects 1966. Free pages 128896 of 131011