Ejemplo n.º 1
0
/****** spool/berkeleydb/bdb_set_txn() *****************************************
*  NAME
*     bdb_set_txn() -- store a transaction handle
*
*  SYNOPSIS
*     void 
*     bdb_set_txn(bdb_info info, DB_TXN *txn) 
*
*  FUNCTION
*     Stores a Berkeley DB transaction handle.
*     It is always stored in thread local storage.
*
*  INPUTS
*     bdb_info info - the database object
*     DB_TXN *txn           - the transaction handle to store
*
*  NOTES
*     MT-NOTE: bdb_set_txn() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_get_txn()
*******************************************************************************/
void
bdb_set_txn(bdb_info info, DB_TXN *txn)
{
   GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                "bdb_set_txn");
   con->txn = txn;
}
Ejemplo n.º 2
0
/****** spool/berkeleydb/bdb_get_txn() *****************************************
*  NAME
*     bdb_get_txn() -- get a transaction handle
*
*  SYNOPSIS
*     DB_TXN * 
*     bdb_get_txn(bdb_info info) 
*
*  FUNCTION
*     Returns a transaction handle set earlier with bdb_set_txn().
*     Each thread can have one transaction open.
*
*  INPUTS
*     bdb_info info - the database object
*
*  RESULT
*     DB_TXN * - a transaction handle
*
*  NOTES
*     MT-NOTE: bdb_get_txn() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_set_txn()
*******************************************************************************/
DB_TXN *
bdb_get_txn(bdb_info info)
{
   GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                "bdb_get_txn");
   return con->txn;
}
Ejemplo n.º 3
0
const char *bootstrap_get_default_domain(void)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_get_default_domain");
   bootstrap = handle->current;                
   return bootstrap->get_default_domain(bootstrap);
}
Ejemplo n.º 4
0
bool bootstrap_get_job_spooling(void)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_get_job_spooling");
   bootstrap = handle->current;                
   return bootstrap->get_job_spooling(bootstrap);
}
Ejemplo n.º 5
0
void bootstrap_set_job_spooling(bool value)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_set_job_spooling");
   bootstrap = handle->current;                
   bootstrap->set_job_spooling(bootstrap, value ); 
}
Ejemplo n.º 6
0
void bootstrap_set_jvm_thread_count(int value)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_set_jvm_thread_count");
   bootstrap = handle->current;                
   bootstrap->set_jvm_thread_count(bootstrap, value); 
}
Ejemplo n.º 7
0
int bootstrap_get_jvm_thread_count(void)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_get_jvm_thread_count");
   bootstrap = handle->current;                
   return bootstrap->get_jvm_thread_count(bootstrap);
}
Ejemplo n.º 8
0
void bootstrap_set_qmaster_spool_dir(const char *value)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_set_qmaster_spool_dir");
   bootstrap = handle->current;                
   bootstrap->set_qmaster_spool_dir(bootstrap, value);
}
Ejemplo n.º 9
0
void bootstrap_set_security_mode(const char *value)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_set_security_mode");
   bootstrap = handle->current;                
   bootstrap->set_security_mode(bootstrap, value ); 
}
Ejemplo n.º 10
0
const char *bootstrap_get_qmaster_spool_dir(void)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_get_qmaster_spool_dir");
   bootstrap = handle->current;                
   return bootstrap->get_qmaster_spool_dir(bootstrap);
}
Ejemplo n.º 11
0
const char *bootstrap_get_security_mode(void)
{
   sge_bootstrap_state_class_t* bootstrap = NULL;
   GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                "bootstrap_get_security_mode");
   bootstrap = handle->current;                
   return bootstrap->get_security_mode(bootstrap);
}
Ejemplo n.º 12
0
/****** spool/berkeleydb/bdb_set_env() *****************************************
*  NAME
*     bdb_set_env() -- set the Berkeley DB environment
*
*  SYNOPSIS
*     void 
*     bdb_set_env(bdb_info info, DB_ENV *env) 
*
*  FUNCTION
*     Sets the Berkeley DB environment.
*     If the RPC mechanism is used, an environment has to be created and opened
*     per thread.
*
*  INPUTS
*     bdb_info info - the database object
*     DB_ENV *env           - the environment handle to set
*
*  NOTES
*     MT-NOTE: bdb_set_env() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_get_env()
*******************************************************************************/
void
bdb_set_env(bdb_info info, DB_ENV *env)
{
   if (info->server == NULL) {
      info->env  = env;
   } else {
      GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                   "bdb_set_env");
      con->env = env;
   }
}
Ejemplo n.º 13
0
/****** spool/berkeleydb/bdb_set_db() ******************************************
*  NAME
*     bdb_set_db() -- set a Berkeley DB database handle
*
*  SYNOPSIS
*     void 
*     bdb_set_db(bdb_info info, DB *db) 
*
*  FUNCTION
*     Sets the Berkeley DB database handle.
*     If the RPC mechanism is used, a database handle has to be created and 
*     opened per thread.
*
*  INPUTS
*     bdb_info info - the database object
*     DB *db                - the database handle to store
*
*  NOTES
*     MT-NOTE: bdb_set_db() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_get_db()
*******************************************************************************/
void
bdb_set_db(bdb_info info, DB *db, const bdb_database database)
{
   if (info->server == NULL) {
      info->db[database]  = db;
   } else {
      GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                   "bdb_set_db");
      con->db[database] = db;
   }
}
Ejemplo n.º 14
0
void sge_bootstrap_state_set_thread_local(sge_bootstrap_state_class_t* ctx) {
   DENTER(TOP_LAYER, "sge_bootstrap_state_set_thread_local");
   
   {   
      GET_SPECIFIC(sge_bootstrap_thread_local_t, handle, bootstrap_thread_local_init, sge_bootstrap_thread_local_key, 
                   "sge_bootstrap_state_set_thread_local");
      if (ctx != NULL) {
         handle->current = ctx;
      } else {
         handle->current = handle->original;
      }
   }
   DEXIT;
}
Ejemplo n.º 15
0
/****** spool/berkeleydb/bdb_get_env() *****************************************
*  NAME
*     bdb_get_env() -- get Berkeley DB database environment
*
*  SYNOPSIS
*     DB_ENV * bdb_get_env(bdb_info info) 
*
*  FUNCTION
*     Returns the Berkeley DB database environment set earlier using 
*     bdb_set_env().
*     If the RPC mechanism is used, the environment is stored per thread.
*
*  INPUTS
*     bdb_info info - the database object
*
*  RESULT
*     DB_ENV * - the database environment
*
*  NOTES
*     MT-NOTE: bdb_get_env() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_set_env()
*******************************************************************************/
DB_ENV *
bdb_get_env(bdb_info info)
{
   DB_ENV *env = NULL;

   if (info->server == NULL) {
      env = info->env;
   } else {
      GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                   "bdb_get_env");
      env = con->env;
   }

   return env;
}
Ejemplo n.º 16
0
/****** spool/berkeleydb/bdb_get_db() ******************************************
*  NAME
*     bdb_get_db() -- get Berkeley DB database handle
*
*  SYNOPSIS
*     DB * 
*     bdb_get_db(bdb_info info) 
*
*  FUNCTION
*     Return the Berkeleyd BD database handle set earlier using bdb_set_db().
*     If the RPC mechanism is used, the database handle is stored per thread.
*
*  INPUTS
*     bdb_info info - the database object
*
*  RESULT
*     DB * - the database handle
*
*  NOTES
*     MT-NOTE: bdb_get_db() is MT safe 
*
*  SEE ALSO
*     spool/berkeleydb/bdb_set_db()
*******************************************************************************/
DB *
bdb_get_db(bdb_info info, const bdb_database database)
{
   DB *db = NULL;

   if (info->server == NULL) {
      db = info->db[database];
   } else {
      GET_SPECIFIC(bdb_connection, con, bdb_init_connection, info->key, 
                   "bdb_get_db");
      db = con->db[database];
   }

   return db;
}
Ejemplo n.º 17
0
/****** test_sge_lock_multiple/thread_function() *********************************
*  NAME
*     thread_function() -- Thread function to execute 
*
*  SYNOPSIS
*     static void* thread_function(void *anArg) 
*
*  FUNCTION
*     Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()'
*     and 'sge_unlock()' sleep to increase the probability of interlocked execution. 
*     Note that we deliberately test the boundaries of 'sge_locktype_t'.
*
*  INPUTS
*     void *anArg - thread function arguments 
*
*  RESULT
*     static void* - none
*
*  SEE ALSO
*     test_sge_lock_multiple/get_thrd_func()
*******************************************************************************/
static void *thread_function(void *anArg)
{
   struct timeval before;
   struct timeval after;
   double time_new;
   int i;
   int max = 1000000;
   int test = 257;
   int result;

   DENTER(TOP_LAYER, "thread_function");

   has_finished("start",0.0);
 
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      result = test +1;
      test = result +1;
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("variable access", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      GET_SPECIFIC(state_t, state, state_init, state_key, "test_sge_lock_multiple");
      state->value2 = state->value +1;
      state->value = state->value2 +1;
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("thread local   ", time_new);
  
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      pthread_once(&log_once, log_once_init);
      {
        GET_SPECIFIC(state_t, state, state_init, state_key, "test_sge_lock_multiple");
         state->value2 = state->value +1;
         state->value = state->value2 +1;
      }
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("thread local once ", time_new);
   
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      sge_mutex_lock("mutex", SGE_FUNC, __LINE__, &mutex);
      result = test +1;
      test = result +1;
      sge_mutex_unlock("mutex", SGE_FUNC, __LINE__, &mutex);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("mutex          ", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      SGE_LOCK(LOCK_GLOBAL, LOCK_READ);
      result = test +1;
      test = result +1;
      SGE_UNLOCK(LOCK_GLOBAL, LOCK_READ);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("read lock      ", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      SGE_LOCK(LOCK_GLOBAL, LOCK_WRITE);
      result = test +1;
      test = result +1;
      SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("write lock     ", time_new);

 
   DEXIT;
   return (void *)NULL;
} /* thread_function */