#include "tpl_os_stm_internal_types.h" % foreach obj in OBJECT before % /* * Declaration of STM-HRT shared data */ % do % /* Data % !obj::DATA_NAME % */ % if exists obj::DATA_VALUE_INIT then !obj::DATA_TYPE % % !obj::DATA_NAME % = % !obj::DATA_VALUE_INIT %; % else !obj::DATA_TYPE % % !obj::DATA_NAME %; % end if end foreach foreach obj in OBJECT before % /* * Declaration of Object IDs */ % do % /* Object % !obj::NAME % identifier */ #define % !obj::NAME %_id % !INDEX % CONST(ObjectType, AUTOMATIC) % !obj::NAME % = % !obj::NAME %_id; % end foreach foreach obj in OBJECT before % /* * Object table (indexed by object IDs) */ VAR(tpl_stm_object, OS_APPL_DATA) object_table[NUMBER_OF_OBJECTS] = { % do % {% % "%!obj::NAME%", /* object name */ % !obj::NAME %_id, /* object id */ "%!obj::DATA_TYPE%", /* data type */ sizeof(%!obj::DATA_TYPE%), /* data size */ 0, /* current_pos */% loop core from 1 to OS::NUMBER_OF_CORES before % {% do %&%!obj::DATA_NAME%,% after % NULL, NULL}, /* copy_table */% end loop % 0 /* concurrency_vector */ } % between % , % after %}; % end foreach % /* * Transaction descriptors' table (indexed by core IDs) */% if OS::NUMBER_OF_CORES > 1 then # multicore : un descripteur de transaction par coeur donc fusion des READ_SET et WRITE_SET des transactions de même coeur % VAR(tpl_stm_tx_descriptor, OS_APPL_DATA) trans_table[NUMBER_OF_CORES] = { % # parcours de toutes les transactions foreach tx in TRANSACTION do let core_already_done := 0 let E_INDEX := INDEX # une transaction de ce coeur a-t-elle été traitée précédemment ? foreach t in TRANSACTION do if INDEX < E_INDEX & tx::NAME != t::NAME & tx::CORE_ID == t::CORE_ID then let core_already_done := 1 end if end foreach # ajout d'un nouveau descripteur de transaction si 1ère transaction ou bien si aucune transaction de ce coeur n'a été non traitée précédemment if E_INDEX==0 | core_already_done == 0 then if E_INDEX !=0 then % , % end if % { % !tx::CORE_ID%, /* core id */ 0, /* status */% % {% let read_set_empty := 1 if exists tx::READ_SET then let read_set_empty := 0 # ajouts des objets READ_SET de la transaction tx foreach o in tx::READ_SET do foreach obj in OBJECT do if o::VALUE == obj::NAME then let index_read := 2+tx::CORE_ID % &object_table[% !INDEX %].copy_table[%!index_read%]% end if end foreach between %, % end foreach end if # ajouts des objets READ_SET des autres transactions t de même core_id, uniquement s'ils sont différents foreach t in TRANSACTION do let I_INDEX:=INDEX if I_INDEX > E_INDEX & tx::NAME != t::NAME & tx::CORE_ID == t::CORE_ID then if exists t::READ_SET then foreach ot in t::READ_SET do let egalite_objet := 0 if exists tx::READ_SET then foreach o in tx::READ_SET do if o::VALUE == ot::VALUE then let egalite_objet := 1 end if end foreach end if if egalite_objet == 0 then if read_set_empty == 0 then %,% end if foreach obj in OBJECT do if ot::VALUE == obj::NAME then let read_set_empty := 0 let index_read := 2+tx::CORE_ID % &object_table[% !INDEX %].copy_table[%!index_read%]% end if end foreach end if end foreach end if end if end foreach if read_set_empty==1 then %NULL% end if %}, /* read_set */% % {% let write_set_empty := 1 if exists tx::WRITE_SET then let write_set_empty := 0 # ajouts des objets WRITE_SET de la transaction tx foreach o in tx::WRITE_SET do foreach obj in OBJECT do if o::VALUE == obj::NAME then % &object_table[% !INDEX %].copy_table[1]% end if end foreach between %, % end foreach end if # ajouts des objets WRITE_SET des autres transactions t de même core_id, uniquement s'ils sont différents foreach t in TRANSACTION do let I_INDEX:=INDEX if I_INDEX > E_INDEX & tx::NAME != t::NAME & tx::CORE_ID == t::CORE_ID then if exists t::WRITE_SET then foreach ot in t::WRITE_SET do let egalite_objet := 0 if exists tx::WRITE_SET then foreach o in tx::WRITE_SET do if o::VALUE == ot::VALUE then let egalite_objet := 1 end if end foreach end if if egalite_objet == 0 then if write_set_empty == 0 then %,% end if foreach obj in OBJECT do if ot::VALUE == obj::NAME then let write_set_empty := 0 % &object_table[% !INDEX %].copy_table[1]% end if end foreach end if end foreach end if end if end foreach if write_set_empty==1 then %NULL% end if %}, /* write_set */% % 0 /* access_vector */ }% end if after % }; % end foreach else #monoprocessor % VAR(tpl_stm_tx_descriptor, OS_APPL_DATA) trans_table[NUMBER_OF_CORES] = { { 0, /* core id */ 0, /* status */% % {% let read_set_empty := 1 # parcours de toutes les transactions foreach tx in TRANSACTION do let E_INDEX:=INDEX if exists tx::READ_SET then # ajouts des objets READ_SET de toutes les transactions, en veillant à ne pas avoir de doublons foreach o in tx::READ_SET do let egalite_objet := 0 foreach t in TRANSACTION do let I_INDEX:=INDEX if exists t::READ_SET then foreach ot in t::READ_SET do if I_INDEX < E_INDEX & tx::NAME != t::NAME & o::VALUE == ot::VALUE then let egalite_objet := 1 end if end foreach end if end foreach if egalite_objet == 0 then foreach obj in OBJECT do if o::VALUE == obj::NAME then if read_set_empty == 0 then %,% end if % &object_table[% !INDEX %].copy_table[2]% let read_set_empty := 0 end if end foreach end if end foreach end if after if read_set_empty==1 then %NULL% end if %}, /* read_set */% end foreach % {% let write_set_empty := 1 foreach tx in TRANSACTION do let E_INDEX:=INDEX if exists tx::WRITE_SET then # ajouts des objets WRITE_SET de toutes les transactions, en veillant à ne pas avoir de doublons foreach o in tx::WRITE_SET do let egalite_objet := 0 foreach t in TRANSACTION do let I_INDEX:=INDEX if exists t::WRITE_SET then foreach ot in t::WRITE_SET do if I_INDEX < E_INDEX & tx::NAME != t::NAME & o::VALUE == ot::VALUE then let egalite_objet := 1 end if end foreach end if end foreach if egalite_objet == 0 then foreach obj in OBJECT do if o::VALUE == obj::NAME then if write_set_empty == 0 then %,% end if let write_set_empty := 0 % &object_table[% !INDEX %].copy_table[1]% end if end foreach end if end foreach end if after if write_set_empty==1 then %NULL% end if %}, /* write_set */% end foreach % 0 /* access_vector */ } }; % end if % /* * Writers' table (indexed by object IDs) */ P2VAR(tpl_stm_tx_descriptor, AUTOMATIC, OS_APPL_DATA) writer_table[NUMBER_OF_OBJECTS] = { % foreach obj in OBJECT do let no_writer := 1 foreach tx in TRANSACTION do let E_INDEX := INDEX if exists tx::WRITE_SET then foreach o in tx::WRITE_SET do if obj::NAME == o::VALUE then let no_writer := 0 %&trans_table[% !E_INDEX%]% end if end foreach end if end foreach if no_writer==1 then %NULL% end if between %, % after % };% end foreach