@ -70,6 +70,8 @@ struct ht_epoch {
ck_epoch_entry_t epoch_entry ;
} ;
COMMON_ALARM_DECLARE_GLOBAL ( alarm_event , next_stage )
static void
alarm_handler ( int s )
{
@ -135,8 +137,8 @@ table_init(void)
ck_epoch_init ( & epoch_ht ) ;
ck_epoch_register ( & epoch_ht , & epoch_wr ) ;
srand48( ( long int ) time ( NULL ) ) ;
if ( ck_ht_init ( & ht , CK_HT_MODE_DIRECT , hash_function , & my_allocator , 8 , lrand48( ) ) = = false ) {
common_ srand48( ( long int ) time ( NULL ) ) ;
if ( ck_ht_init ( & ht , CK_HT_MODE_DIRECT , hash_function , & my_allocator , 8 , common_ lrand48( ) ) = = false ) {
perror ( " ck_ht_init " ) ;
exit ( EXIT_FAILURE ) ;
}
@ -267,6 +269,8 @@ main(int argc, char *argv[])
pthread_t * readers ;
double p_r , p_d ;
COMMON_ALARM_DECLARE_LOCAL ( alarm_event )
r = 20 ;
s = 8 ;
p_d = 0.5 ;
@ -305,6 +309,8 @@ main(int argc, char *argv[])
}
}
COMMON_ALARM_INIT ( alarm_event , r )
affinerator . delta = 1 ;
readers = malloc ( sizeof ( pthread_t ) * n_threads ) ;
assert ( readers ! = NULL ) ;
@ -316,9 +322,9 @@ main(int argc, char *argv[])
table_init ( ) ;
for ( i = 0 ; i < keys_length ; i + + ) {
keys [ i ] = ( uintptr_t ) lrand48( ) ;
keys [ i ] = ( uintptr_t ) common_ lrand48( ) ;
while ( keys [ i ] = = 2 )
keys [ i ] = ( uintptr_t ) lrand48( ) ;
keys [ i ] = ( uintptr_t ) common_ lrand48( ) ;
}
for ( i = 0 ; i < ( size_t ) n_threads ; i + + ) {
@ -415,7 +421,7 @@ main(int argc, char *argv[])
while ( ck_pr_load_int ( & barrier [ HT_STATE_STOP ] ) ! = n_threads )
ck_pr_stall ( ) ;
ck_pr_inc_int ( & barrier [ HT_STATE_STOP ] ) ;
sleep( r ) ;
common_ sleep( r ) ;
ck_pr_store_int ( & state , HT_STATE_STRICT_REPLACEMENT ) ;
while ( ck_pr_load_int ( & barrier [ HT_STATE_GET ] ) ! = n_threads )
ck_pr_stall ( ) ;
@ -425,8 +431,7 @@ main(int argc, char *argv[])
fprintf ( stderr , " | Executing strict replacement test... " ) ;
a = repeated = 0 ;
signal ( SIGALRM , alarm_handler ) ;
alarm ( r ) ;
common_alarm ( alarm_handler , & alarm_event , r ) ;
ck_pr_inc_int ( & barrier [ HT_STATE_GET ] ) ;
for ( ; ; ) {
@ -451,8 +456,7 @@ main(int argc, char *argv[])
fprintf ( stderr , " done (writer = % " PRIu64 " ticks, reader = % " PRIu64 " ticks) \n " ,
a / ( repeated * keys_length ) , accumulator [ HT_STATE_STRICT_REPLACEMENT ] / n_threads ) ;
signal ( SIGALRM , alarm_handler ) ;
alarm ( r ) ;
common_alarm ( alarm_handler , & alarm_event , r ) ;
fprintf ( stderr , " | Executing deletion test (%.2f)... " , p_d * 100 ) ;
a = repeated = 0 ;
@ -465,7 +469,7 @@ main(int argc, char *argv[])
for ( i = 0 ; i < keys_length ; i + + ) {
table_insert ( keys [ i ] ) ;
if ( p_d ! = 0.0 ) {
delete = drand48( ) ;
delete = common_ drand48( ) ;
if ( delete < = p_d )
table_remove ( keys [ i ] ) ;
}
@ -487,8 +491,7 @@ main(int argc, char *argv[])
fprintf ( stderr , " done (writer = % " PRIu64 " ticks, reader = % " PRIu64 " ticks) \n " ,
a / ( repeated * keys_length ) , accumulator [ HT_STATE_DELETION ] / n_threads ) ;
signal ( SIGALRM , alarm_handler ) ;
alarm ( r ) ;
common_alarm ( alarm_handler , & alarm_event , r ) ;
fprintf ( stderr , " | Executing replacement test (%.2f)... " , p_r * 100 ) ;
a = repeated = 0 ;
@ -501,12 +504,12 @@ main(int argc, char *argv[])
for ( i = 0 ; i < keys_length ; i + + ) {
table_insert ( keys [ i ] ) ;
if ( p_d ! = 0.0 ) {
delete = drand48( ) ;
delete = common_ drand48( ) ;
if ( delete < = p_d )
table_remove ( keys [ i ] ) ;
}
if ( p_r ! = 0.0 ) {
replace = drand48( ) ;
replace = common_ drand48( ) ;
if ( replace < = p_r )
table_replace ( keys [ i ] ) ;
}