cgroup/get_cgroup_double_value -- return a cgroup attribute
bool get_cgroup_double_value(const char *cgroup, const char *attrib, double *value)
Return a cgroup attribute, where the value is expected to be compatible with type double.
cgroup - filename of cgroup attrib - attribute to return value - returned value
true on success / false on failure
sge_fifo_lock() -- acquire a read/write lock
bool sge_fifo_lock(sge_fifo_rw_lock_t *lock, bool is_reader)
A call to this function acquires either a read or a write lock depending on the value of "is_reader". If the value of "is_reader" is "true" the function returns as soon as it gets the read lock. This is the case if there is noone currently holding the write lock and if there was noone previously trying to get the write lock. If the value of "is_reader" is "false" then the function returns as soon as it gets the write lock. This is only the case if there is noone holding a read or write lock and only if there was noone else who tried to get the read or write lock. A thread my hold multiple concurrent read locks. If so the corresponding sge_fifo_unlock() function has to be called once for each lock obtained. Multiple threads might obtain a read lock whereas only one thread can have the write lock at the same time. Threads which can't acquire a read or write lock block till the lock is available. A certain number of blocking threads (defined by the define FIFO_LOCK_QUEUE_LENGTH) wait in a queue so that each of those threads has a chance to get the lock. If more than FIFO_LOCK_QUEUE_LENGTH threads try to get the lock it might happen that then there are threads which will never get the lock (This behaviour depends on the implementation of the pthread library). A read/write lock has to be initialized with sge_fifo_lock_init() before it can be used with this function.
sge_fifo_rw_lock_t *lock - lock object bool is_reader - try to get the read lock (true) or write lock (false)
bool - error state true - success false - error occured
MT-NOTE: sge_fifo_lock() is MT safe
sge_fifo_lock_init() -- initialize a fifo read/write lock
bool sge_fifo_lock_init(sge_fifo_rw_lock_t *lock)
This function is used to initialize a fifo read/write lock. On success the function returns true. If the lock object can't be initialized then the function will return with false.
sge_fifo_rw_lock_t *lock - fifo lock object
bool - error state true - success false - error
MT-NOTE: sge_fifo_lock_init() is MT safe
sge_fifo_ulock() -- release a read or write lock
bool sge_fifo_ulock(sge_fifo_rw_lock_t *lock, bool is_reader)
Releases a read or write lock previously obtained with sge_fifo_lock() or sge_fifo_unlock()
sge_fifo_rw_lock_t *lock - lock object bool is_reader - type of lock to be released
bool - error state true - success false - error
MT-NOTE: sge_fifo_ulock() is MT safe
id_callback_impl() -- locker ID callback
static sge_locker_t id_callback_impl(void)
Return ID of current locker.
void - none
sge_locker_t - locker id
MT-NOTE: id_callback() is MT safe.
lock_once_init() -- setup lock service
static void lock_once_init(void)
Determine number of locks needed. Create and initialize the respective mutexes. Register the callbacks required by the locking API
void - none
void - none
MT-NOTE: lock_once_init() is NOT MT safe. Currently we do not use so called recursive mutexes. This may change *without* warning, if necessary!
RMON - Grid Engine Monitoring Interface
The RMON library is a set of functions, which do allow monitoring of of application execution. The functions provided, however, should not be used directly. Rather the RMON functions are utilized by a set of monitoring macros, like 'DENTER' or 'DEXIT'. If monitoring is active, the RMON functions do get called very frequently. Hence, the overhead caused by monitoring needs to be minimal. For this reason, access to external global and static global variables is NOT synchronized through a mutex! Not using a lock of type 'pthread_mutex_t' also means that the RMON functions are async-signal safe. To use RMON library in a multi threaded environment, some restrictions must be followed strictly! It is of utmost importance, that the function 'rmon_mopen()' is ONLY invoked from exactly one thread. The thread which is calling 'rmon_mopen()' must be the ONLY thread at this point in time. 'DENTER_MAIN' is the only macro from which 'rmon_mopen()' is called. The macro 'DENTER_MAIN' is used at the beginning of a main function. At this point in time, the so called main-thread is the only thread. It is safe to call the remaining RMON functions, like 'rmon_menter()' or 'rmon_mexit()', from within multiple threads. 'rmon_mopen()' is the only RMON function which does change the critical global variables ('mtype', 'rmon_fp' and 'RMON_DEBUG_ON'). 'rmon_menter()' and 'rmon_mexit()' are used by the macro 'DENTER' and 'DEXIT', respectively.
mwrite() -- Write monitoring message
static void mwrite(char *message)
Write monitoring message. The message is written to the output stream associated with 'rmon_fp'. The output stream is flushed immediately. A prefix is added to 'message'. It does consist of a trace sequence number, the PID and the thread ID of the calling thread.
char *message - monitoring message
void - none
MT-NOTE: 'mwrite()' is MT safe with exceptions. See introduction! MT-NOTE: MT-NOTE: It is guaranteed that the output of different threads is not MT-NOTE: mingled.
rmon_condition() -- Check monitoring condition.
int rmon_condition(int layer, int class)
Check whether monitoring should be enabled for the given combination of 'layer' and 'class'.
int layer - monitor layer int class - monitor class
1 - do monitor 0 - do not monitor
MT-NOTE: 'rmon_condition()' is MT safe with exceptions. See introduction!
rmon_debug_client_callback() -- callback for debug clients
static void rmon_debug_client_callback(int dc_connected, int debug_level)
Is called when a debug client is connected/disconnected or on debug level changes. Use cl_com_application_debug() to send debug messages to the connected qping -dump client.
int dc_connected - 1 debug client is connected 0 no debug client is connected int debug_level - debug level from 0 (off) to 5(DPRINTF)
MT-NOTE: rmon_debug_client_callback() is MT safe (but is called from commlib thread, which means that no qmaster thread specific setup is done), just use global thread locking methods which are initialized when called, or initialized at compile time)
rmon_is_enabled() -- Check if monitoring is enabled.
int rmon_is_enabled(void)
Check if monitoring is enabled. Note that even if monitoring is enabled no actual monitoring output may be generated. Generation of monitoring output is controlled by 'rmon_condition()'.
void - none
1 - monitoring enabled 0 - monitoring disabled
MT-NOTE: 'rmon_is_enabled()' is MT safe with exceptions. See introduction!
rmon_menter() -- Monitor function entry
void rmon_menter(const char *func)
Monitor function entry. Generate function entry message.
const char *func - function name
void - none
MT-NOTE: 'rmon_menter()' is MT safe with exceptions. See introduction!
rmon_mexit() -- Monitor function exit
void rmon_mexit(const char *func, const char *file, int line)
Monitor function exit. Generate function exit message.
const char *func - function name const char *file - source file in which function is defined int line - number of invocation source line
void - none
MT-NOTE: 'rmon_mexit()' is MT safe with exceptions. See introduction!
rmon_mopen() -- Open, i.e. initialize monitoring.
void rmon_mopen(int *argc, char *argv[], char *programname)
Initialize monitoring. Clear all monitoring levels. Set monitoring levels according to 'SGE_DEBUG_LEVEL' environment variable. Set monitoring target (i.e. output stream) according to 'SGE_DEBUG_TARGET' environment variable. Enable monitoring. NOTE: Even though 'argc' and 'argv' are not used, they do make sure that 'rmon_mopen()' is only used within a main function to a certain degree.
int *argc - not used char *argv[] - not used char *programname - not used
void - none
MT-NOTE: 'rmon_mopen()' is NOT MT safe. See introduction!
rmon_mprintf() -- Print formatted monitoring message.
void rmon_mprintf(const char *fmt, ...)
Print formatted monitoring message.
const char *fmt - format string ... - variable argument list
void - none
MT-NOTE: 'rmon_mprintf()' is MT safe with exceptions. See introduction!
rmon_mtrace() -- Monitor function progress
void rmon_mtrace(const char *func, const char *file, int line)
Monitor function progress. Generate function trace message.
const char *func - function name const char *file - source file in which function is defined int line - number of invocation source line
void - none
MT-NOTE: 'rmon_mtrace()' is MT safe with exceptions. See introduction!
set_debug_level_from_env() -- Set debug level from environment variable.
static int set_debug_level_from_env(void)
Set debug level. Read environment variable "SGE_DEBUG_LEVEL" and use it to initialize debug levels.
void - none
0 - successful ENOENT - environment variable not set EINVAL - unexpected format
MT-NOTE: 'set_debug_level_from_env()' is MT safe with exceptions. MT-NOTE: See introduction!
set_debug_target_from_env() -- Set debug target from environment variable.
static int set_debug_target_from_env(void)
Set debug target. Read environment variable "SGE_DEBUG_TARGET" and use it to initialize debug output target. 'SGE_DEBUG_TARGET' may either be 'stdout', 'stderr' or a fully qualified file name (that is file name and path). If a file name is given an already existing file with the same name will be overwritten.
void - none
0 - successful EACCES - file name is invalid or unable to open file
MT-NOTE: 'set_debug_target_from_env()' is MT safe with exceptions. MT-NOTE: See introduction!
bindingLinearParseCoreOffset() -- Get core number of linear request.
int bindingLinearParseCoreOffset(const char* parameter)
In a request like "-binding linear:<amount>:<socketnr>,<corenr>" it parses the core number.
const char* parameter - pointer to the binding request
int - if a value >= 0 then this reflects the core number if a value < 0 then there was a parsing error or no core number was given
MT-NOTE: bindingLinearParseCoreOffset() is not MT safe
bindingLinearParseSocketOffset() -- Get socket number of linear request.
int bindingLinearParseSocketOffset(const char* parameter)
In a request like "-binding linear:<amount>:<socketnr>,<corenr>" it parses the socket number.
const char* parameter - pointer to the binding request
int - if a value >= 0 then this reflects the socket number if a value < 0 then there was a parsing error or no socket number was given
MT-NOTE: bindingLinearParseSocketOffset() is not MT safe
binding_explicit_has_correct_syntax() -- Check if parameter has correct syntax.
bool binding_explicit_has_correct_syntax(const char* parameter)
This function checks if the given string is a valid argument for the -binding parameter which provides a list of socket, cores which have to be selected explicitly. The accepted syntax is: "explicit:[1-9][0-9]*,[1-9][0-9]*(:[1-9][0-9]*,[1-9][0-9]*)*" This is used from parse_qsub.c.
const char* parameter - A string with the parameter.
bool - True if the parameter has the expected syntax.
MT-NOTE: binding_explicit_has_correct_syntax() is not MT safe
binding_linear_parse_number() -- Parse the number of cores to occupy.
int binding_linear_parse_number(const char* parameter)
Parses a string in order to get the number of cores requested. The string has following format: "linear:<amount>[:<socket>,<core>]"
const char* parameter - The first character of the string
int - if a value >= 0 then this reflects the number of cores if a value < 0 then there was a parsing error
MT-NOTE: binding_linear_parse_number() is MT safe
binding_parse_type() -- Parses binding type out of binding string.
binding_type_t binding_parse_type(const char* parameter)
The execution daemon communicates with the shepherd with the config file. This function parses the type of binding out of the specific binding string from the config file. In case of binding type "set" there is no special prefix in this string. In case of "environment" the "env_" prefix in within the string. In case of setting the rankfile the "pe_" prefix can be found in this string.
const char* parameter - The binding string from the config file.
binding_type_t - The type of binding.
MT-NOTE: binding_parse_type() is MT safe
binding_striding_parse_first_core() -- Parses core number from command line.
int binding_striding_parse_first_core(const char* parameter)
Parses the core number from command line in which to start binding in "striding" case. -binding striding:<amount>:<stepsize>:<socket>,<core>
const char* parameter - Pointer to first character of CL string.
int - -1 in case the string is corrupt or core number is not set >= 0 in case the core number could parsed successfully.
MT-NOTE: binding_striding_parse_first_core() is not MT safe
binding_striding_parse_first_socket() -- Parses the socket to begin binding on.
int binding_striding_parse_first_socket(const char* parameter)
Parses the "striding:" parameter string for the socket number. The string is expected to have following syntax: "striding:<amount>:<stepsize>[:<socket>,<core>]"
const char* parameter - Points to the string with the query.
int - Returns the socket number in case it could be parsed otherwise -1
MT-NOTE: binding_striding_parse_first_socket() is not MT safe
binding_striding_parse_number() -- Parses the number of cores to bind to.
int binding_striding_parse_number(const char* parameter)
Parses the number of cores to bind to out of "striding:" parameter string. The string is expected to have following syntax: "striding:<amount>:<stepsize>[:<socket>,<core>]"
const char* parameter - Points to the string with the query.
int - Returns the number of cores to bind to otherwise -1.
MT-NOTE: binding_striding_parse_number() is not MT safe
binding_striding_parse_step_size() -- Parses the step size out of the "striding" query.
int binding_striding_parse_step_size(const char* parameter)
Parses the step size for the core binding strategy "striding" out of the query. The query string is expected to have following syntax: "striding:<amount>:<stepsize>[:<socket>,<core>]"
const char* parameter - Points to the string with the query.
int - Returns the step size or -1 when it could not been parsed.
MT-NOTE: binding_striding_parse_step_size() is not MT safe
check_explicit_binding_string() -- Checks binding string for duplicate pairs.
bool check_explicit_binding_string(const char* expl, const int amount)
Checks binding string for duplicate <socket,core> pairs. Works also when the first pair is the "explicit" string.
const char* expl - pointer to the explicit binding request const int amount - expected number of pairs const bool with_explicit_prefix - expl start with "excplicit:"
bool - true if the explicit binding request is duplicate free
MT-NOTE: check_explicit_binding_string() is MT safe
get_explicit_number() -- Counts the number of <socket,core> pairs.
int get_explicit_number(const char* expl)
Counts the number of <socket,core> pairs in the binding explicit request.
const char* expl - pointer to explicit binding request string const bool with_explicit_prefix - does string start with "explicit:"?
int - number of <socket,core> pairs in explicit binding request string
MT-NOTE: get_explicit_number() is MT safe
is_digit() -- Checks if char array consists of digits.
static bool is_digit(const char* position, const char stopchar)
Checks if the character array contains only digits till the end of the array or to a given stop character. If there is no digit found or the input pointer is a null pointer 'false' is returned. The input pointer have to point to the first digit of a number.
const char* position - pointer to the character array const char stopchar - stop scanning at this parameter
static bool - true if a number is found false if not
MT-NOTE: is_digit() is MT safe
parse_binding_parameter_string() -- Parses binding parameter string.
bool parse_binding_parameter_string(const char* parameter, u_long32* type, dstring* strategy, int* amount, int* stepsize, int* firstsocket, int* firstcore, dstring* socketcorelist, dstring* error)
Parses binding parameter string and returns the values of the parameter. Please check output values in dependency of the strategy string.
const char* parameter - binding parameter string
u_long32* type - type of binding (pe = 0| env = 1|set = 2) dstring* strategy - binding strategy string int* amount - number of cores to bind to int* stepsize - step size between cores (or -1) int* firstsocket - first socket to use (or -1) int* firstcore - first core to use (on "first socket") (or -1) dstring* socketcorelist - list of socket,core pairs with prefix explicit or NULL dstring* error - error as string in case of return false
bool - true in case parsing was successful false in case of errors
MT-NOTE: parse_binding_parameter_string() is MT safe
topology_string_to_socket_core_lists() -- Converts a topology into socket,core lists.
bool topology_string_to_socket_core_lists(const char* topology, int** sockets, int** cores, int* amount)
Converts a topology string into lists of cores and sockets which are marked as beeing used and returns them.
const char* topology - Pointer to a topology string.
int** sockets - Pointer to the location of the socket array. int** cores - Pointer to the location of the core array. int* amount - Length of the arrays.
bool - false when problems occured true otherwise
MT-NOTE: topology_string_to_socket_core_lists() is MT safe
sge_get_qmaster_port() -- get qmaster port
int sge_get_qmaster_port(bool *from_services)
This function returns the TCP/IP port of the qmaster daemon. It returns a cached value from a previous run. The cached value will be refreshed every 10 Minutes. The port may come from environment variable SGE_QMASTER_PORT or the services files entry "sge_qmaster".
bool *from_services - Pointer to a boolean which is set to true when the port value comes from the services file.
int - port of qmaster
Grid Engine Locking API
The Grid Engine Locking API is a mediator between a lock service provider and a lock client. A lock service provider offers a particular lock implementation by registering a set of callbacks. A lock client does acquire and release a lock using the respective API functions. A lock service provider (usually a daemon) needs to register three different callbacks: + a lock callback, which is used by the API lock function + an unlock callback, which is used by the API unlock function + an ID callback, which is used by the API locker ID function Lock service provider has to register these callbacks *before* lock client uses the lock/unlock API functions. Otherwise the lock/unlock operations do have no effect at all. Locktype denotes the entity which will be locked/unlocked (e.g. Global Lock. Lockmode denotes in which mode the locktype will be locked/unlocked. Locker ID unambiguously identifies a lock client. Adding a new locktype does recquire two steps: 1. Add an enumerator to 'sge_locktype_t'. Do not forget to update 'NUM_OF_TYPES'. 2. Add a description to 'locktype_names'.
sge_lock() -- Acquire lock
void sge_lock(sge_locktype_t aType, sge_lockmode_t aMode)
Acquire lock. If the lock is already held, block the caller until lock becomes available again. Instead of using this function directly the convenience macro 'SGE_LOCK(type, mode)' could (and should) be used.
sge_locktype_t aType - lock to acquire sge_lockmode_t aMode - lock mode
void - none
MT-NOTE: sge_lock() is MT safe
sge_locker_id() -- Locker identifier
sge_locker_t sge_locker_id(void)
Return an unambiguous identifier for the locker.
void - none
sge_locker_t - locker identifier
There is a 1 to 1 mapping between a locker id an a thread. However the locker id and the thread id may be different. MT-NOTE: sge_locker_id() is MT safe
sge_unlock() -- Release lock
void sge_unlock(sge_locktype_t aType, sge_lockmode_t aMode)
Release lock. Instead of using this function directly the convenience macro 'SGE_UNLOCK(type, mode)' could (and should) be used.
sge_locktype_t aType - lock to release sge_lockmode_t aMode - lock mode in which the lock has been acquired
void - none
MT-NOTE: sge_unlock() is MT safe
sge_mutex_lock() -- Mutex locking wrapper with rmon monitoring
void sge_mutex_lock(const char *mutex_name, const char *func, int line, pthread_mutex_t *mutex)
Locks the passed mutex. Before and after locking rmon DLOCKPRINTF() is used to facilitate tracking of deadlocks that are caused by mutexes.
const char *mutex_name - The name of the mutex. const char *func - The function where sge_mutex_lock() was called from int line - The line number where sge_mutex_lock() was called from pthread_mutex_t *mutex - The mutex.
MT-NOTE: sge_mutex_lock() is MT-safe MT-NOTE: MT-NOTE: This function is considered being MT-safe, even though is does MT-NOTE: use 'strerror()'. The error message returned from 'strerror()' MT-NOTE: is not stored and used imediately.
sge_mutex_unlock() -- Mutex unlocking wrapper with rmon monitoring
void sge_mutex_unlock(const char *mutex_name, const char *func, int line, pthread_mutex_t *mutex)
Unlocks the passed mutex. Before and after unlocking rmon DLOCKPRINTF() is used to facilitate tracking of deadlocks that are caused by mutexes.
const char *mutex_name - The name of the mutex. const char *func - The function where sge_unmutex_unlock() was called from int line - The line number where sge_unmutex_lock() was called from pthread_mutex_t *mutex - The mutex.
MT-NOTE: sge_mutex_unlock() is MT-safe MT-NOTE: MT-NOTE: This function is considered being MT-safe, even though is does MT-NOTE: use 'strerror()'. The error message returned from 'strerror()' MT-NOTE: is not stored and used imediately.
sge_relative_timespec() -- set timespec to now plus timeout
static void sge_relative_timespec(signed long timeout, struct timespec *ts)
Based on the relative timeout passed an absolute timespec is returned. The timespec can e.g. be used for pthread_cond_timedwait(). Also a timout of 0 can be used. However if the timespec returned is then used with pthread_cond_timedwait() this requires the predicate is checked once at least.
signed long timeout - A relative timeout interval or 0
struct timespec *ts - An abstime timespec value
MT-NOTE: sge_relative_timespec() is MT safe
convert_arg_list_to_vector() -- creates an argument vector from a list
void convert_arg_list_to_vector(sge_sl_list_t *sl_args, char ***pargs)
Takes the list of arguments (i.e. a list of strings) and creates an argument vector out of it, like you get it in the main() function. The strings in the argument vector are still the ones from the argument list, i.e. the string buffers are not copied, the elements of the argument vector just point to them.
sge_sl_list_t *sl_args - a list with single C strings as elements char ***pargs - an argument vector like main() provides, filled with all arguments from the list. This argument vector is terminated by an element that points to NULL.
int - The length of the argument vector including the terminal NULL element.
sge_sl_list_t *sl_args; char **args; char command_line[] = "foo bla \"trala\""; sge_sl_create(&sl_args); parse_quoted_command_line(command_line, sl_args); convert_arg_list_to_vector(sl_args, &args); ... use args ... ... done using args ... sge_sl_destroy(&sl_args, NULL);
MT-NOTE: convert_arg_list_to_vector() is not MT safe
parse_quoted_command_line() -- parses a command line with quoted arguments
int parse_quoted_command_line(char *command, sge_sl_list_t *sl_args)
Parses a command line with quoted arguments and stores the single arguments into a SGE simple list (sge_sl). The command line is modified during the parse process. This function recognizes the quotes " and '. This function can't handle escaped quotes, see last example.
char *command - the command line to be parsed. "command" gets modified during the parse process, so provide a copy of the real command line if you need it afterwards. sge_sl_list_t *sl_args - pointer to the list where the single arguments get stored to. This must be a properly created list (using sge_sl_create()). In case of error, the list contains all arguments not including the last quoted one (with the missing closing quote)
int - 0: OK 1: unmatched quote " 2: unmatched quote '
command line: foo "bar trala 'hey hu'" list: + foo + bar trala 'hey hu' command line: 'foo bar' trala "hey" hu list: + foo bar + trala + hey + hu command line: foo "bar trala '"hey hu' list: + foo + bar trala ' + hey hu' command line: foo "bar trala hey hu return value 1 list: + foo command line: "foo \"bar huhu\" trala" hey list: + foo \ + bar + huhu\ + trala + hey
MT-NOTE: parse_quoted_command_line() is not MT safe
unescape_env_value() --
char * unescape_env_value(char *value)
Undo any backslash escapes (\\ or \n) in value string, returning a new string.
char *value - environment variable value
new string
MT-NOTE: unescape_env_value() is MT safe
thread_function_2() -- Thread function to execute
static void* thread_function_2(void *anArg)
Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()' and 'sge_unlock()' sleep to increase the probability of interlocked execution. Note: This function for itself is perfectly reasonable. However, a race condition, and thus a potential deadlock, does emerge if this function is run in parallel with 'thread_function_1()'. The reason for this is, that 'thread_function_2()' and 'thread_function_1()' each follow their own local acquire/release protocol. As a consequence, 'thread_function_2()' and 'thread_function_1()' acquire and release their respective locks in different orders. This example does reveal how important it is to obey a GLOBAL acquire/release protocol.
void *anArg - thread function arguments
static void* - none
main() -- Generic skeleton for lock API test programs.
int main(int argc, char *argv[])
Generic driver for lock API test programs utilizing pthreads and pthread mutexes. Setup locking API by registering the needed callbacks. Determine the number of threads needed. Create threads and execute the provided thread function. Wait until all the threads have finished. Teardown the locking API. If a program wants to utilize this skeleton it has to implement the functions of a small API defined in 'sge_lock_main.h'.
int argc - number of arguments char *argv[] - argument array
int - always 0
thread_function() -- Thread function to execute
static void* thread_function(void *anArg)
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'.
void *anArg - thread function arguments
static void* - none
thread_function() -- Thread function to execute
static void* thread_function(void *anArg)
Lock the global lock in read mode and sleep. Unlock the global lock.
void *anArg - thread function arguments
static void* - none
thread_function_1() -- Thread function to execute
static void* thread_function_1(void *anArg)
Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()' and 'sge_unlock()' sleep to increase the probability of interlocked execution. Note: This function for itself is perfectly reasonable. However, a race condition, and thus a potential deadlock, does emerge if this function is run in parallel with 'thread_function_2()'. The reason for this is, that 'thread_function_1()' and 'thread_function_2()' each follow their own local acquire/release protocol. As a consequence, 'thread_function_1()' and 'thread_function_2()' acquire and release their respective locks in different orders. This example does reveal how important it is to obey a GLOBAL acquire/release protocol.
void *anArg - thread function arguments
static void* - none
sge_afs_extend_token() -- Extend an AFS token
int sge_afs_extend_token(const char *command, char *tokenbuf, const char *user, int token_extend_time, char *err_str, size_t lstr)
Call 'command', pipe content of 'tokenbuf' to 'command', using 'user' as arg1 and 'token_extend_time' as arg2
const char *command - command char *tokenbuf - input for command const char *user - 1st argument for command int token_extend_time - 2nd argument for command char *err_str - error message size_t lstr - length of err_str
MT-NOTE: sge_afs_extend_token() is not MT safe because it uses MT unsafe MT-NOTE: sge_peopen()
int - error state 0 - OK -1 - Error
sge_get_token_cmd() -- Check if 'tokencmdname' is executable
int sge_get_token_cmd(const char *tokencmdname, char *buf, size_t lbuf)
Check if 'tokencmdname' exists and is executable. If an error occures write a error message into 'buf' if not NULL. Otherwise write error messages to stderr.
const char *tokencmdname - command char *buf - NULL or buffer for error message size_t lbuf - size of buf
MT-NOTE: sge_get_token_cmd() is MT safe
int - error state 0 - OK 1 - Error
sge_read_token() -- read token from file
char* sge_read_token(const char *file)
Read token from file, malloc buffer, add '\0' byte and return pointer to buffer.
const char *file - filename
MT-NOTE: sge_read_token() is MT safe
char* - pointer to a malloced buffer or NULL if error occured
binding_get_topology_for_job() -- Returns topology string.
const char * binding_get_topology_for_job(const char *binding_result)
Returns the topology string of a host where the cores are marked with lowercase letters for those cores that were "bound" to a certain job. It is assumed the 'binding_result' parameter that is passed to this function was previously returned by create_binding_strategy_string()
const char *binding_result - string returned by create_binding_strategy_string()
const char * - topology string like "SCc"
Bitfield -- A variable size bitfield implementation
bitfield sge_bitfield_new(unsigned int size)
This module provides variable size bitfields. The size of a bitfield can be defined when the bitfield is created. Individual bits can be set, read and cleared. The contents of a bitfield can be printed to stdout or any file handle.
See main program (module test) in libs/uti/sge_bitfield.c
MT-NOTE: this module is MT safe
Bitfield_Typedefs -- type definitions for the Bitfield module
typedef struct { unsigned int size; union { char fix[sizeof(char *)]; char *dyn; } bf; } bitfield; typedef _bitfield *bitfield;
The _bitfield structure is the internal representation of a bitfield. All operations on bitfields use the bitfield type. For small bitfields, no memory is allocated, but the space available in bf.fix is used (depending on the architecture, this suffices for 32 or 64 bit bitfields). This saves a considerable amount of memory and above all processing time.
ISSET(),VALID(),SETBIT(),CLEARBIT() - Bit manipulation makros
#define ISSET(a,b) ((a&b)==b) #define VALID(a,b) ((a|b)==b) #define SETBIT(a,b) (b=(a)|b); #define CLEARBIT(a,b) (b &= (~(a)));
Makros to get/set/clear bits in native variables.
int,long,u_long32... a - Bitmask int,long,u_long32... b - Variable
b will be modified
These Makros can't be used in combination with the bitfield type.
sge_bitfield_copy() -- copies a bitfield into another one.
bool sge_bitfield_bitwise_copy(const bitfield *source, bitfield *target)
The memory has to be allocated before, but the bitfields can have different sizes. If the source is longer than the target, only the bits up to target's length are copied.
const bitfield *source - source bitfield bitfield *target - target bitfield
bool - false, if one of the bitfields is NULL
MT-NOTE: sge_bitfield_bitwise_copy() is MT safe
sge_bitfield_changed() -- figures out if something was changed.
bool sge_bitfield_changed(const bitfield *source)
bitfield *source - bitfield to analyze
bool - true, if the bitfield has a changed bit set.
MT-NOTE: sge_bitfield_copy() is MT safe
sge_bitfield_clear() -- clear a bit
bool sge_bitfield_clear(bitfield *bf, unsigned int bit)
Clears a certain bit in a bitfield (sets its content to 0).
bitfield *bf - the bitfield to manipulate unsigned int bit - the bit to clear
MT-NOTE: sge_bitfield_clear() is MT safe
bool - true on success, false on error
sge_bitfield_copy() -- copies a bitfield into another one.
bool sge_bitfield_copy(const bitfield *source, bitfield *target)
The memory has to be allocated before, and source and target has to have the same size. Otherwise it will return false and does not copy anything.
const bitfield *source - source bitfield bitfield *target - target bitfield
bool - false, if one of the bitfields is NULL or the bitfield sizes are different
MT-NOTE: sge_bitfield_copy() is MT safe
sge_bitfield_free() -- destroy a bitfield
bitfield sge_bitfield_free(bitfield *bf)
Destroys a bitfield. Frees all memory allocated by the bitfield.
bitfield *bf - the bitfield to destroy
MT-NOTE: sge_bitfield_free() is MT safe
bitfield * - NULL
sge_bitfield_free_data() -- free the bitfield data
bool sge_bitfield_free_data(bitfield *bf)
Frees the data part of a bitfield. The bitfield itself is not freed.
bitfield *bf - the bitfield to work on
bool - true on success, else false
MT-NOTE: sge_bitfield_free_data() is MT safe
sge_bitfield_get() -- read a bit
bool sge_bitfield_get(const bitfield *bf, unsigned int bit)
Reads a certain bit of a bitfield and returns it's contents.
bitfield *bf - the bitfield to read from unsigned int bit - the bit to read
MT-NOTE: sge_bitfield_get() is MT safe
bool - false, if bit is not set (or input params invalid), true, if bit is set
sge_bitfield_init() -- initialize a bitfield object
bool sge_bitfield_init(bitfield *bf, unsigned int size)
Initializes a bitfield object. Storage for the bits is allocated if necessary (size of the bitfield is bigger than the preallocated storage) and the size is stored.
bitfield *bf - the bitfield to initialize unsigned int size - the targeted size of the bitfield
bool - true on success, else false
MT-NOTE: sge_bitfield_init() is MT safe
sge_bitfield_new() -- create a new bitfield
bitfield * sge_bitfield_new(unsigned int size)
Allocates and initializes the necessary memory. It is in the responsibility of the caller to free the bitfield once it is no longer needed.
unsigned int size - size in bits
bitfield - a new bitfield or NULL, if the creation of the bitfield failed
MT-NOTE: sge_bitfield_new() is MT safe
sge_bitfield_print() -- print contents of a bitfield
void sge_bitfield_print(bitfield *bf, FILE *fd)
Prints the contents of a bitfield. For each bit one digit (0/1) is printed. If NULL is passed as file descriptor, output is sent to stdout.
MT-NOTE: sge_bitfield_print() is MT safe
bitfield bf - the bitfield to output FILE *fd - filehandle or NULL
sge_bitfield_reset() -- clears a bitfield
bool sge_bitfield_reset(bitfield *bf)
bitfield *bf - bitfield to reset
bool - false, if bf is NULL
MT-NOTE: sge_bitfield_copy() is MT safe
sge_bitfield_set() -- set a bit
bool sge_bitfield_set(bitfield *bf, unsigned int bit)
Sets a certain bit in a bitfield to 1.
bitfield *bf - the bitfield to manipulate unsigned int bit - the bit to set
MT-NOTE: sge_bitfield_set() is MT safe
bool - true on success, false on error
bootstrap_mt_init() -- Initialize bootstrap code for multi threading use.
void bootstrap_mt_init(void)
Set up bootstrap code. This function must be called at least once before any of the bootstrap oriented functions can be used. This function is idempotent, i.e. it is safe to call it multiple times. Thread local storage for the bootstrap state information is reserved.
void - NONE
void - NONE
MT-NOTE: bootstrap_mt_init() is MT safe
bootstrap_state_destroy() -- Free thread local storage
static void bootstrap_state_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memory which should be freed.
static void - none
MT-NOTE: bootstrap_state_destroy() is MT safe.
bootstrap_thread_local_destroy() -- Free thread local storage
static void bootstrap_thread_local_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memory which should be freed.
static void - none
MT-NOTE: bootstrap_thread_local_destroy() is MT safe.
bootstrap_thread_local_init() -- Initialize bootstrap state.
static void bootstrap_thread_local_init(sge_bootstrap_state_class_t* theState)
Initialize bootstrap state.
bootstrap_state_t* theState - Pointer to bootstrap state structure.
static void - none
MT-NOTE: bootstrap_thread_local_init() is MT safe.
bootstrap_thread_local_once_init() -- One-time bootstrap code initialization.
static bootstrap_thread_local_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: bootstrap_thread_local_once_init() is MT safe.
sge_bootstrap() -- read and process bootstrap file
bool sge_bootstrap(void)
Reads the bootstrap file ($SGE_ROOT/$SGE_CELL/common/bootstrap). Initializes the policy for hostcpy and hostcmp (ignore_fqdn and default_domain).
dstring *error_dstring - dynamic string buffer to return error messages. if error_string is NULL, error messages will be written using the sge_log functions, else they will be returned in error_dstring.
bool - true on success, else false
MT-NOTE: sge_bootstrap() is MT safe
DSTRING_INIT -- Define to initialize dstring variables
#define DSTRING_INIT {NULL, 0, 0}
Define to preinitialize dstring variables
{ dstring error_msg = DSTRING_INIT; }
The DSTRING_INIT counterpart for static buffers is sge_dstring_init()
sge_dstring_append() -- strcat() for dstrings
const char* sge_dstring_append(dstring *sb, const char *a)
Append 'a' after 'sb'
dstring *sb - dynamic string const char *a - string
MT-NOTE: sge_dstring_append() is MT safe
const char* - result string
sge_dstring_append() -- strcat() for dstrings
const char* sge_dstring_append(dstring *sb, const dstring *a)
Append 'a' after 'sb'
dstring *sb - dynamic string const dstring *a - string
MT-NOTE: sge_dstring_append_dstring() is MT safe
const char* - result string
sge_dstring_clear() -- empty a dstring
void sge_dstring_clear(dstring *sb)
Set a dstring to an empty string.
MT-NOTE: sge_dstring_clear() is MT safe
dstring *sb - dynamic string
sge_dstring_copy_dstring() -- strcpy() for dstrings
const char* sge_dstring_copy_dstring(dstring *sb1, const dstring *sb2)
strcpy() for dstrings
dstring *sb1 - destination dstring const dstring *sb2 - source dstring
MT-NOTE: sge_dstring_copy_dstring() is MT safe
const char* - result string buffer
sge_dstring_copy_string() -- copy string into dstring
const char* sge_dstring_copy_string(dstring *sb, char* str)
Copy string into dstring
dstring *sb - destination dstring char* str - source string
MT-NOTE: sge_dstring_copy_string() is MT safe
const char* - result string
sge_dstring_free() -- sge_free() for dstrings
void sge_dstring_free(dstring *sb)
Frees a dynamically allocated string
MT-NOTE: sge_dstring_free() is MT safe
dstring *sb - dynamic string
sge_dstring_get_string() -- Returns string buffer
const char* sge_dstring_get_string(const dstring *string)
Returns a pointer to the buffer where the string is stored. The pointer is not valid until doomsday. The next sge_dstring_* call may make it invalid.
const dstring *string - pointer to dynamic string
MT-NOTE: sge_dstring_get_string() is MT safe
const char* - pointer to string buffer
sge_dstring_init() -- init static dstrings
size_t sge_dstring_init(dstring *string, char *s, size_t size)
Initialize dstring with a static buffer.
const dstring *string - pointer to dynamic string
MT-NOTE: sge_dstring_init() is MT safe
size_t - remaining chars
sge_dstring_remaining() -- remaining chars in dstring
size_t sge_dstring_remaining(const dstring *string)
Returns number of chars remaining in dstrings.
const dstring *string - pointer to dynamic string
MT-NOTE: sge_dstring_remaining() is MT safe
size_t - remaining chars
sge_dstring_split() -- splits a string into two parts
bool sge_dstring_split(dstring *string, char character, dstring *before, dstring *after)
This functions tries to find the first occurrence of "character" in "string". The characters before will be copied into "before" and the characters behind into "after" dstring.
dstring *sb - dstring char character - character dstring *before - characters before dstring *after - characters after
error state true - success false - error
sge_dstring_sprintf() -- sprintf() for dstrings
const char* sge_dstring_sprintf(dstring *sb, const char *format, ...)
see sprintf()
dstring *sb - dynamic string const char *format - format string ... - additional parameters
const char* - result string
MT-NOTE: sge_dstring_sprintf() is MT safe
sge_dstring_sprintf_append() -- sprintf() and append for dstrings
const char* sge_dstring_sprintf_append(dstring *sb, const char *format, ...)
See sprintf() The string created by sprintf is appended to the existing contents of the dstring.
dstring *sb - dynamic string const char *format - format string ... - additional parameters
const char* - result string
MT-NOTE: sge_dstring_sprintf_append() is MT safe
sge_dstring_strip_white_space_at_eol() -- as it says
void sge_dstring_strip_white_space_at_eol(dstring *string)
removes whitespace at the end of the given "string".
dstring *string - dstring
sge_dstring_strlen() -- strlen() for dstrings
size_t sge_dstring_strlen(const dstring *string)
strlen() for dstrings
const dstring *string - pointer to dynamic string
MT-NOTE: sge_dstring_strlen() is MT safe
size_t - string length
sge_dstring_ulong_to_binstring() -- convert ulong into bin-string
const char* sge_dstring_ulong_to_binstring(dstring *sb, u_long32 number)
Convert ulong into bin-string
dstring *sb - dstring u_long32 number - 32 bit ulong value
const char* - pointer to dstrings internal buffer
sge_dstring_vsprintf() -- vsprintf() for dstrings
const char* sge_dstring_vsprintf(dstring *sb, const char *format,va_list ap)
see vsprintf()
dstring *sb - dynamic string const char *format - format string va_list ap - argument list
const char* - result string
MT-NOTE: sge_dstring_vsprintf() is MT safe
file_exists -- whether file exists
bool file_exists(const char *file)
Test whether a file exists (actually can be stat'ed).
file - file name
true iff file can be stat'ed
copy_linewise -- copy a file line-by-line
bool copy_linewise(const char *src, const char *dst)
Copy line-by-line (unbuffered writes) from file SRC to file DST, assuming line length < MAX_STRING_SIZE.
src - source file name dst - destination file name
true on success, false if an i/o error occurs
sge_copy_hostent() -- make a deep copy of a struct hostent
struct hostent *sge_copy_hostent (struct hostent *orig)
Makes a deep copy of a struct hostent so that sge_gethostbyname() can free it's buffer for the gethostbyname_r() calls on Linux and Solaris.
MT-NOTE: sge_copy_hostent() is MT safe
sge_gethostbyaddr() -- gethostbyaddr() wrapper
struct hostent *sge_gethostbyaddr(const struct in_addr *addr, int* system_error_retval)
Wraps gethostbyaddr() function calls, measures time spent in gethostbyaddr() and logs when very much time has passed. On error, return error code in *system_error_retval if that is non-null. return value must be released by function caller (don't forget the char** array lists inside of struct hostent) If possible (libcomm linked) use cl_com_cached_gethostbyaddr() from libcomm. This will return an sge aliased hostname.
MT-NOTE: sge_gethostbyaddr() is MT safe MT-NOTE: sge_gethostbyaddr() uses a mutex to guard access to the MT-NOTE: gethostbyaddr() system call on all platforms other than Solaris, MT-NOTE: Linux, and HP-UX. Therefore, except on the aforementioned MT-NOTE: platforms, MT calls to gethostbyaddr() must go through MT-NOTE: sge_gethostbyaddr() to be MT safe.
sge_gethostbyname() -- gethostbyname() wrapper
struct hostent *sge_gethostbyname(const char *name, int *system_error_retval)
Wraps gethostbyname() function calls, measures time spent in gethostbyname() and logs when very much time has passed. On error, return error code in *system_error_retval if that is non-null. return value must be released by function caller (don't forget the char* array lists inside of struct hostent) If possible (libcomm linked) use getuniquehostname() or cl_com_cached_gethostbyname() or cl_com_gethostname() from libcomm. This will return an sge aliased hostname.
MT-NOTE: sge_gethostbyname() is MT safe MT-NOTE: sge_gethostbyname() uses a mutex to guard access to the MT-NOTE: gethostbyname() system call on all platforms other than Solaris, MT-NOTE: Linux, AIX, Tru64, HP-UX, and MacOS 10.2 and greater. Therefore, MT-NOTE: except on the aforementioned platforms, MT calls to MT-NOTE: gethostbyname() must go through sge_gethostbyname() to be MT safe.
is_hgroup_name() -- Is the given name a hostgroup name
bool is_hgroup_name(const char *name)
Is the given name a hostgroup name
This function is also used for usergroup in resource quota sets
const char *name - hostname or hostgroup name
bool - true for hostgroupnames otherwise false
sge_gethostbyname_retry() -- gethostbyname() wrapper
struct hostent *sge_gethostbyname_retry(const char *name)
Wraps sge_gethostbyname() function calls, and retries if the host is not found. return value must be released by function caller (don't forget the char** array lists inside of struct hostent) If possible (libcomm linked) use getuniquehostname() or cl_com_cached_gethostbyname() or cl_com_gethostname() from commlib. This will return an sge aliased hostname.
MT-NOTE: see sge_gethostbyname()
sge_host_delete() -- delete host in host list with all aliases
static void sge_host_delete(host *h)
host *h - host to be deleted
MT-NOTE: sge_host_delete() is not MT safe due to access to global variable
sge_host_get_mainname() -- Return mainname considering aliases
char* sge_host_get_mainname(host *h)
Return the mainname of a host considering aliases.
host *h - host
char* - mainname NOTES: MT-NOTE: sge_host_get_mainname() is not MT safe
sge_host_list_print() -- Print hostlist into file
void sge_host_list_print(FILE *fp)
Print hostlist into file
FILE *fp - filename
MT-NOTE: sge_host_list_print() is not MT safe due to access to hostlist MT-NOTE: global variable
sge_host_print() -- Print host entry info file
void sge_host_print(host *h, FILE *fp)
Print host entry info file
host *h - host entry FILE *fp - file
MT-NOTE: sge_host_print() is NOT MT safe ( because of inet_ntoa() call)
sge_host_search() -- Search for host
host* sge_host_search(const char *name, char *addr)
Search for host. If 'name' is not NULL the returned host has the given or the alias that matches this name. 'name' is not case sensitive. 'addr' is in hostorder. If 'addr' is not NULL the returned host has 'addr' in his addrlist. If 'addr' is aliased this function returns the hostname of the first alias (mainname)
const char *name - hostname char *addr - address
MT-NOTE: sge_host_search() is not MT safe due to access to hostlist MT-NOTE: global variable
host* - host entry
sge_host_search_pred_alias() -- search host who's aliasptr points to host
static host* sge_host_search_pred_alias(host *h)
host *h - host we search for
static host* - found host if contained in host list
MT-NOTE: sge_host_search_pred_alias() is not MT safe due to access to MT-NOTE: global variable
???
sge_hostcmp() -- strcmp() for hostnames
int sge_hostcmp(const char *h1, const char*h2)
strcmp() for hostnames. Honours some configuration values: - Domain name may be ignored - Domain name may be replaced by a 'default domain' - Hostnames may be used as they are.
const char *h1 - 1st hostname const char *h2 - 2nd hostname
int - 0, 1 or -1
sge_hostcpy() -- strcpy() for hostnames.
void sge_hostcpy(char *dst, const char *raw)
strcpy() for hostnames. Honours some configuration values: - Domain name may be ignored - Domain name may be replaced by a 'default domain' - Hostnames may be used as they are. - straight strcpy() for hostgroup names
char *dst - possibly modified hostname const char *raw - hostname
sge_hostmatch() -- fnmatch() for hostnames
int sge_hostmatch(const char *h1, const char*h2)
fnmatch() for hostnames. Honours some configuration values: - Domain name may be ignored - Domain name may be replaced by a 'default domain' - Hostnames may be used as they are.
const char *h1 - 1st hostname const char *h2 - 2nd hostname
int - 0, 1 or -1
sge_strtolower() -- convert all upper character in the string to lower case
int sge_strtolower(char *buffer)
sge_strtolower() for hostnames. Honours some configuration values:
char *buffer - string to be lowered
no result, this function modify the argument string
htable -- A Hashtable Implementation for Grid Engine
htable sge_htable_create(int size, int (*hash_func)(const void *), int (*compare_func)(const void *, const void *)); void sge_htable_destroy(htable ht); void sge_htable_store(htable ht, const void* key, const void* data); int sge_htable_lookup(htable ht, const void* key, const void** data); void sge_htable_delete(htable ht, const void* key); void sge_htable_for_each(htable ht, sge_htable_for_each_proc proc);
This module provides a hash table implementation for Grid Engine. Hash tables are used to have very fast access to objects stored in data structures like linked lists without having to traverse the whole list when searching a specific element. An element in a hash table is characterized by a unique key. This hash table implementation dynamically adjusts the size of the hash table when necessary.
MT-NOTE: This module is MT safe.
compare_func_<type>() -- Compare functions for selected data types
int HashCompare_<type>(const void *a, const void *b)
Depending on the data type of the hash key, different functions have to be used to compare two elements. Which compare function to use has to be specified when creating a new hash table. Syntax and return value are similar to strcmp.
const void *a - pointer to first element const void *b - pointer to second element
int - 0, if the elements are equal > 0, if the first element is bigger than the second < 0, if the first element is smaller than the second
The following data types are provided with this module: - strings (char *) - u_long32
dup_func_<type>() -- function duplicate the key
const void *dup_func_<type>(const void *key)
The hash table cannot rely on the key data to remain valid over the programs execution time. Therefore copies of keys are stored in the bucket object. To allow duplication of keys with types unknown to the hash table implementation, a duplication function must be specified when a hash table is created.
const void *key - pointer to the key to duplicate
const void * - the duplicated key
The following data types are provided with this module: - strings (char *) - u_long32
hash_func_<type>() -- Hash functions for selected data types
int hash_func_<type>(const void *key)
Depending on the data type of the hash key, different hash functions have to be used. Which hash function to use has to be specified when creating a new hash table.
const void *key - pointer to key for which to compute a hash value
int - the hash value
The following data types are provided with this module: - strings (char *) - u_long32
sge_htable_create() -- Create a new hash table
htable sge_htable_create(int size, int (*hash_func)(const void *), int (*compare_func)(const void *, const void *)
Creates an empty hash table and initializes its data structures.
int size - Initial table size will be 2^n int (*hash_func) - pointer to hash function int (*compare_func) - pointer to compare function
htable - the created hash table
htable MyHashTable = sge_htable_create(5, hash_func_u_long32, hash_compare_u_long32);
sge_htable_delete() -- Delete an element in a hash table
void sge_htable_delete(htable table, const void* key)
Deletes an element in a hash table. If the number of elements falls below a certain threshold (half the size of the hash table), the hash table is resized (shrunk).
htable table - hash table that contains the element const void* key - key of the element to delete
Only deletes the entry in the hash table. The object itself is not deleted.
sge_htable_destroy() -- Destroy a hash table
void sge_htable_destroy(htable ht)
Destroys a hash table and frees all used memory.
htable ht - the hash table to destroy
The objecs managed by the hash table are not destroyed and have to be handled separately.
sge_htable_for_each() -- Apply an action on all elements
void sge_htable_for_each(htable table, sge_htable_for_each_proc proc)
Calls a certain function for all elements in a hash table.
htable table - the hash table sge_htable_for_each_proc proc - func to call for each element
sge_htable_lookup() -- search for an element
int sge_htable_lookup(htable table, const void* key, const void** data)
Search for a certain object characterized by a unique key in the hash table. If an element can be found, it is returned in data.
htable table - the table to search const void* key - unique key to search const void** data - object if found, else NULL
int - true, when an object was found, else false
sge_htable_resize() -- Resize the hash table
static void sge_htable_resize(htable ht, int grow)
Hash tables are dynamically resized if necessary. If the number of elements in a has table becomes too big, the hash algorithm can no longer provide efficient access to the stored objects. On the other hand, storing only a few elements in a much too big hash table wastes memory. Therefore the whole table can be resized. If the hash table has to grow, it is doubled in size. If it has to be shrunk, it is halfed in size. Resizing implies rehashing all stored objects.
htable ht - the hashtable to resize int grow - true or false true = double size of the table, false = shrink table to half the size
If the system is running in log_level log_debug, statistics is output before and after resizing the hash table, along with timing information.
sge_htable_statistics() -- Get some statistics for a hash table
const char* sge_htable_statistics(htable ht)
Returns a constant string containing statistics for a hash table in the following format: "size: %ld, %ld entries, chains: %ld empty, %ld max, %.1f avg" size is the size of the hash table (number of hash chains) entries is the number of objects stored in the hash table Information about hash chains: empty is the number of empty hash chains max is the maximum number of objects in a hash chain avg is the average number of objects for all occupied hash chains The string returned is a static buffer, subsequent calls to the function will overwrite this buffer.
htable ht - Hash table for which statistics shall be generated dstring *buffer - buffer to be provided by caller
const char* - the string described above
sge_htable_store() -- Store a new element in a hash table
void sge_htable_store(htable table, const void* key, const void* data)
Stores a new element in a hash table. If there already exists an element with the same key in the table, it will be replaced by the new element. If the number of elements in the table exceeds the table size, the hash table will be resized.
htable table - table to hold the new element const void* key - unique key const void* data - data to store, usually a pointer to an object
sge_bin2string() -- Put binary stream into a string
char* sge_bin2string(FILE *fp, int size)
Read a binary steam from given file descriptor 'fp' and write it into (dynamically) malloced buffer as "ASCII" format. "ASCII" format means: '\0' is written as '\\' '\0' '\\' is written as '\\' '\\' End of buffer is written as '\0'
FILE *fp - file descriptor int size - size of the buffer used within this function
char* - malloced buffer
MT-NOTE: sge_bin2string() is MT safe
sge_copy_append() -- Copy/append one file to another
int sge_copy_append(char *src, const char *dst, sge_mode_t mode)
Copy/append content from 'src' to 'dst'
char *src - source filename const char *dst - destination filename sge_mode_t mode - mode
int - error state 0 - OK -1 - Error
MT-NOTE: sge_copy_append() is MT safe
sge_file2string() -- Load file into string
char* sge_file2string(const char *fname, int *len)
Load file into string. Returns a pointer to a string buffer containing the file contents and the size of the buffer (= number of bytes read) in the variable len. If the file cannot be read (doesn't exist, permissions etc.), NULL is returned as buffer and len is set to 0.
const char *fname - filename int *len - number of bytes read
char* - malloced string buffer
MT-NOTE: sge_file2string() is MT safe
sge_filecmp() -- Compare two files
int sge_filecmp(const char *name0, const char *name1)
Compare two files. They are equal if: - both of them have the same name - if a stat() succeeds for both files and i-node/device-id are equal we are not sure - if stat() failes for at least one of the files (It could be that both pathes direct to the same file not existing)
const char *name0 - 1st filename const char *name1 - 2nd filename
int - Identical? 0 - Yes. 1 - No they are not equivalent.
MT-NOTE: sge_filecmp() is MT safe
sge_mode_t -- Type of operation for sge_copy_append()
typedef enum { SGE_MODE_APPEND = 1, SGE_MODE_COPY = 2 } sge_mode_t;
Defines the operation which should be performed by sge_copy_append(): SGE_MODE_APPEND - append the file SGE_MODE_COPY - copy the file
sge_readnbytes() -- Read n bytes from file descriptor
int sge_readnbytes(int sfd, char *ptr, int n)
Read n bytes from file descriptor.
int sfd - file descriptor char *ptr - pointer to buffer int n - number of bytes
int - number of bytes read
MT-NOTE: sge_readnbytes() is MT safe
sge_stream2string() -- Read string from stream
char* sge_stream2string(FILE *fp, int *len)
Read string from stream
FILE *fp - file descriptor int *len - number of bytes read
char* - pointer to malloced string buffer
MT-NOTE: sge_stream2string() is MT safe
sge_string2bin() -- Write 'binary' string into file
int sge_string2bin(FILE *fp, const char *buf)
Write 'binary' string into file
FILE *fp - file descriptor const char *buf - "ASCII" string (see sge_bin2string())
int - error state 0 - OK -1 - Error
MT-NOTE: sge_string2bin() is MT safe
sge_string2file() -- Write string into file
int sge_string2file(const char *str, int len, const char *fname)
Write string into file
const char *str - pointer to buffer int len - number of bytes which should be written const char *fname - filename
int - error state 0 - OK -1 - Error
MT-NOTE: sge_string2file() is MT safe
sge_writenbytes() -- Write n bytes to file descriptor
int sge_writenbytes(int sfd, const char *ptr, int n)
Write n bytes to file descriptor
int sfd - file descriptor const char *ptr - pointer to buffer int n - number of bytes
int - number of bytes written
MT-NOTE: sge_writenbytes() is MT safe
sge_get_message_id_output() -- check if message id should be added
int sge_get_message_id_output(void)
This function returns the value stored in the static global variable sge_message_id_view_flag.
int - value of sge_message_id_view_flag
MT-NOTE: sge_get_message_id_output() is guarded by language_mutex
sge_get_message_id_output_implementation() -- pure implementation of sge_get_message_id_output_implementation() that does not lock language_mutex
int sge_get_message_id_output_implementation(void)
When the sge_get_message_id_output() functionality is needed from within the language modules the language_mutex may not be obtained because this mutex is already owned by the same thread.
int - value of sge_message_id_view_flag
MT-NOTE: The caller of sge_get_message_id_output_implementation() must MT-NOTE: have obtained the language_mutex mutex due to access to MT-NOTE: 'sge_enable_msg_id' and 'sge_enable_msg_id_to_every_message'.
sge_gettext() -- dummy gettext() function
const char* sge_gettext(char *x)
This function returns the given argument
char *x - string
const char* - input string
sge_gettext_() -- add error id to message
const char* sge_gettext_(int msg_id, const char *msg_str)
This function is used for adding the message id to the translated gettext message string. The message id is only added when the function sge_get_message_id_output() returns not "0" and the message string contains at least one SPACE character.
int msg_id - message id const char *msg_str - message to translate
const char* - translated (L10N) message with message id
sge_gettext__() -- get translated message from message file
char *sge_gettext__(char *x)
makes a call to sge_language_functions.gettext_func(x) if gettext_func is not NULL, otherwise it returns the input string.
char *x - pointer to message which should be internationalizied
char* - pointer internationalized message
MT-NOTE: not guarded b/c sge_gettext__() is used only in infotext utility
sge_init_language() -- initialize language package for gettext()
int sge_init_language(char* package, char* localeDir)
starts up the language initialization for gettext(). This function should be called nearly after the main() function. sge_init_language_func() must be called first to install the correct function pointers for gettext() setlocale() etc. etc.
char* package - package name like "gridengine" of binary package *.mo file. (if package is NULL sge_init_language tries to get the package name from the invironment variable "GRIDPACKAGE"). char* localeDir - path to the localisazion directory (if localeDir is NULL sge_init_language tries to get the localization directory path from the invironment variable "GRIDLOCALEDIR").
int state - true for seccess, false on error.
MT-NOTE: sge_init_languagefunc() is guarded by language_mutex
sge_init_language() -- install language functions
void sge_init_language_func(gettext_func_type new_gettext, setlocale_func_type new_setlocale, bindtextdomain_func_type new_bindtextdomain, textdomain_func_type new_textdomain);
set the function pointer for the gettext(), setlocale(), bindtextdomain() and textdomain() function calls. This function must called before any call to sge_init_language() and sge_gettext().
gettext_func_type - pointer for gettext() setlocale_func_type - pointer for setlocale() bindtextdomain_func_type - pointer for bindtextdomain() textdomain_func_type - pointer for textdomain()
MT-NOTE: sge_init_language_func() is guarded by language_mutex
sge_set_message_id_output() -- enable message id number adding
void sge_set_message_id_output(int flag)
This procedure is used to enable the adding of message id's when showing error messages. This function is used in the macro SGE_ADD_MSG_ID(x) to enable the message id for errors.
int flag - 0 = off ; 1 = on
MT-NOTE: sge_set_message_id_output() is guarded by language_mutex
CRITICAL() -- Log a critical message
#define CRITICAL(params) void CRITICAL(char *buffer, const char* formatstring, ...)
Log a critical message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
DEBUG() -- Log a debug message
#define DEBUG(params) void DEBUG(char *buffer, const char* formatstring, ...)
Log a debug message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
ERROR() -- Log an error message
#define ERROR(params) void ERROR(char *buffer, const char* formatstring, ...)
Log a error message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
INFO() -- Log an info message
#define INFO(params) void INFO(char *buffer, const char* formatstring, ...)
Log an info message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
NOTICE() -- Log a notice message
#define NOTICE(params) void NOTICE(char *buffer, const char* formatstring, ...)
Log a notice message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
PROFILING() -- Log a profiling message
#define PROFILING(params) void PROFILING(char *buffer, const char* formatstring, ...)
Log a profiling message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
SGE_ASSERT() -- Log a message and exit if assertion is false
#define SGE_ASSERT(expression) void SGE_ASSERT(int expression)
Log a critical message and exit if assertion is false.
expression - a logical expression
WARNING() -- Log an warning message
#define WARNING(params) void WARNING(char *buffer, const char* formatstring, ...)
Log a warning message
buffer - e.g SGE_EVENT formatstring - printf formatstring ...
log_buffer_destroy() -- Free thread local storage
static void log_buffer_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memroy which should be freed.
static void - none
MT-NOTE: log_buffer_destroy() is MT safe.
log_buffer_getspecific() -- Get thread local log state
static log_buffer_t* log_buffer_getspecific()
Return thread local log state. If a given thread does call this function for the first time, no thread local log state is available for this particular thread. In this case the thread local log state is allocated and set.
static log_buffer_t* - Pointer to thread local log state.
MT-NOTE: log_buffer_getspecific() is MT safe
log_buffer_once_init() -- One-time logging initialization.
static log_buffer_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: log_buffer_once_init() is MT safe.
log_context_destroy() -- Free thread local storage
static void log_context_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memroy which should be freed.
static void - none
MT-NOTE: log_context_destroy() is MT safe.
log_context_getspecific() -- Get thread local log context
static log_context_t* log_context_getspecific()
Return thread local log context. If a given thread does call this function for the first time, no thread local log state is available for this particular thread. In this case the thread local log state is allocated and set.
static log_context_t* - Pointer to thread local log context.
MT-NOTE: log_context_getspecific() is MT safe
log_context_once_init() -- One-time logging initialization.
static log_context_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: log_context_once_init() is MT safe.
log_get_log_buffer() -- Return a buffer that can be used to build logging strings
char *log_get_log_buffer(void)
Return a buffer that can be used to build logging strings
char *
log_get_log_context() -- Return a context for the specific thread
sge_gdi_ctx_class_t* log_get_log_context(void)
Return a context for the specific thread
sge_gdi_ctx_class_t*
log_set_log_context() -- set a context for the specific thread
void log_set_log_context(void *newctx)
Return a context for the specific thread
void newctx - the new ctx
MT-NOTE: log_state_set_log_file() is not MT safe. MT-NOTE: MT-NOTE: It is safe, however, to call this function from within multiple MT-NOTE: threads as long as no other thread calls log_state_set_log_file()
log_state_get_log_as_admin_user() -- Needs sge_log() to change into admin user?
trace_func_type log_state_get_log_as_admin_user(void)
Returns whether logging shall be done as admin user.
int
log_state_get_log_gui() -- Is GUI logging enabled?
int log_state_get_log_gui(void)
Is GUI logging enabled? With GUI logging enabled messages are printed to stderr/stdout.
int - 0 or 1
log_state_get_log_level() -- Return log level.
u_long32 log_state_get_log_level(void)
Return log level
u_long32
log_state_get_log_verbose() -- Is verbose logging enabled?
int log_state_get_log_verbose(void)
Is verbose logging enabled? With verbose logging enabled not only ERROR/CRITICAL messages are printed to stderr but also WARNING/INFO.
int - 0 or 1
log_state_set_log_as_admin_user() -- Enable/Disable logging as admin user
void log_state_set_log_as_admin_user(int i)
This function enables/disables logging as admin user. This means that the function/macros switches from start user to admin user before any messages will be written. After that they will switch back to 'start' user.
int i - 0 or 1
log_state_set_log_gui() -- Enable/disable logging for GUIs
void log_state_set_log_gui(int i)
Enable/disable logging for GUIs With GUI logging enabled messages are printed to stderr/stdout.
int i - 0 or 1
log_state_set_log_level() -- Set log level to be used.
void log_state_set_log_level(int i)
Set log level to be used.
u_long32
log_state_set_log_verbose() -- Enable/disable verbose logging
void log_state_set_log_verbose(int i)
Enable/disable verbose logging
int i - 0 or 1
sge_log() -- Low level logging function
int sge_log(int log_level, char *mesg, char *file__, char *func__, int line__)
Low level logging function. Used by various macros. Do not use this function directly.
int log_level - Logging Level char *mesg - Message char *file__ - Filename char *func__ - Function Name int line__ - Line within 'file__'
int - 0
MT-NOTE: sge_log() is not MT safe due to sge_switch2admin_user() MT-NOTE: sge_log() can be used in clients where no admin user switching MT-NOTE: takes place MT-NOTE: sge_log() is not MT safe due rmon_condition() MT-NOTE: sge_log() can be used if DENTER_MAIN() is called only by one MT-NOTE: thread
ext_edt_output() -- generates a string from the GDI extension
static void ext_edt_output(char *message, int size, void *monitoring_extension, double time)
generates a string from the extension and returns it.
char *message - initilized string buffer int size - buffer size void *monitoring_extension - the extension structure double time - length of the mesurement interval
MT-NOTE: ext_edt_output() is MT safe
ext_gdi_output() -- generates a string from the GDI extension
static void ext_gdi_output(char *message, int size, void *monitoring_extension, double time)
generates a string from the extension and returns it.
char *message - initilized string buffer int size - buffer size void *monitoring_extension - the extension structure double time - length of the mesurement interval
MT-NOTE: ext_gdi_output() is MT safe
ext_lis_output() -- generates a string from the listener extension
static void ext_lis_output(char *message, int size, void *monitoring_extension, double time)
generates a string from the extension and returns it.
char *message - initilized string buffer int size - buffer size void *monitoring_extension - the extension structure double time - length of the mesurement interval
MT-NOTE: ext_lis_output() is MT safe
ext_sch_output() -- generates a string from the scheduler extension
static void ext_sch_output(char *message, int size, void *monitoring_extension, double time)
generates a string from the extension and returns it.
char *message - initilized string buffer int size - buffer size void *monitoring_extension - the extension structure double time - length of the mesurement interval
MT-NOTE: ext_gdi_output() is MT safe
ext_tet_output() -- generates a string from the GDI extension
static void ext_edt_output(char *message, int size, void *monitoring_extension, double time)
generates a string from the extension and returns it.
dstring *message - initilized string buffer void *monitoring_extension - the extension structure double time - length of the mesurement interval
MT-NOTE: ext_tet_output() is MT safe
sge_monitor_free() -- frees the monitoring data structure
void sge_monitor_free(monitoring_t *monitor)
removes the line for the commlib output, and frees memory in the monitoring structure
monitoring_t *monitor - monitoring strucutre
MT-NOTE: sge_monitor_free() is MT safe
sge_monitor_init() -- init the monitoring structure
void sge_monitor_init(monitoring_t *monitor, const char *thread_name, extension_t ext, thread_warning_t warning_timeout, thread_error_t error_timeout)
Sets the default values and inits the structure, finds the line pos for the comlib output
monitoring_t *monitor - monitoring strucutre const char *thread_name - the thread name extension_t ext - the extension time (-> enum) thread_warning_t warning_timeout - the warning timeout (-> enum) thread_error_t error_timeout - the error timeout (-> enum)
MT-NOTE: sge_monitor_init() is MT safe
sge_monitor_output() -- outputs the result into the message file
void sge_monitor_output(monitoring_t *monitor)
This function computes the output line from the gathered statistics. The output is only generated, when the the output flag in the monitoring structure is set. The monitoring line is printed to the message file in the profiling class and it made available for the qping -f output. For the qping output, it stores the the generation time, though that qping can show, when the message was generated. If an extension is set, it calls the apropriate output function for it.
monitoring_t *monitor - the monitoring info
MT-NOTE: sge_monitor_output() is MT safe
sge_monitor_reset() -- resets the monitoring data
void sge_monitor_reset(monitoring_t *monitor)
Resets the data structure including the extesion. No data in the extension is presevered.
monitoring_t *monitor - monitoring structure
MT-NOTE: sge_monitor_reset() is MT safe
sge_monitor_status() -- generates the status for qping / commlib
u_long32 sge_monitor_status(char **info_message, u_long32 monitor_time)
This method creates the health monitoring output and returns the monitoring info to the commlib.
char **info_message - info_message pointer, has to point to a NULL string u_long32 monitor_time - the configured monitoring interval
u_long32 - 0 : everything is okay 1 : warning 2 : error 3 : init problems
MT-NOTE: sge_monitor_status() is MT safe
sge_set_last_wait_time() -- updates the last wait time (health monitoring)
void sge_set_last_wait_time(monitoring_t *monitor, struct timeval after)
Updates the last wait time, which is used for the health monitoring to determine if a thread has a problem or not.
monitoring_t *monitor - monitoring structure struct timeval wait_time - current time
MT-NOTE: sge_set_last_wait_time() is MT safe
fd_compare() -- file descriptor compare function for qsort()
static int fd_compare(const void* fd1, const void* fd2)
qsort() needs a callback function to compare two filedescriptors for sorting them. This is the implementation to value the difference of two file descriptors. If one paramter is NULL, only the pointers are used for the comparsion. Used by sge_close_all_fds().
const void* fd1 - pointer to an int (file descriptor 1) const void* fd2 - pointer to an int (file descriptor 2)
static int - compare result (1, 0 or -1) 1 : fd1 > fd2 0 : fd1 == fd2 -1 : fd1 < fd2
MT-NOTE: fd_compare() is MT safe
redirect_to_dev_null() -- redirect a channel to /dev/null
int redirect_to_dev_null(int target, int mode)
Attaches a certain filedescriptor to /dev/null.
int target - file descriptor int mode - mode for open
int - target fd number if everything was ok, else -1
MT-NOTE: redirect_to_dev_null() is MT safe
sge_checkprog() -- Has "pid" of a running process the given "name"
int sge_checkprog(pid_t pid, const char *name, const char *pscommand)
Check if "pid" of a running process has given "name". Only first 8 characters of "name" are significant. Check only basename of command after "/".
pid_t pid - process id const char *name - process name const char *pscommand - ps commandline
int - result state 0 - Process with "pid" has "name" 1 - No such pid or pid has other name -1 - error occurred (mostly sge_peopen() failed)
MT-NOTES: sge_checkprog() is not MT safe
sge_close_all_fds() -- close all open file descriptors
void sge_close_all_fds(int* keep_open, unsigned long nr_of_fds)
This function is used to close all possible open file descriptors for the current process. This is done by getting the max. possible file descriptor count and looping over all file descriptors and calling sge_close_fd(). It is possible to specify a file descriptor set which should not be closed.
int* keep_open - integer array which contains file descriptor ids which should not be closed - if this value is set to NULL nr_of_fds is ignored unsigned long nr_of_fds - nr of filedescriptors in the keep_open array
void - no result
sge_close_fd() -- close a file descriptor
static void sge_close_fd(int fd)
This function closes the specified file descriptor on an architecture specific way. If __INSURE__ is defined during compile time and it is an fd used by insure the file descriptor is not closed.
int fd - file descriptor number to close
static void - no return value
sge_contains_pid() -- Checks whether pid array contains pid
int sge_contains_pid(pid_t pid, pid_t *pids, int npids)
whether pid array contains pid
pid_t pid - process id pid_t *pids - pid array int npids - number of pids in array
int - result state 0 - pid was not found 1 - pid was found
MT-NOTES: sge_contains_pid() is MT safe
sge_dup_fd_above_stderr() -- Make sure a fd is >=3
int sge_dup_fd_above_stderr(int *fd)
This function checks if the given fd is <3, if yes it dups it to be >=3. The fd obtained by open(), socket(), pipe(), etc. can be <3 if stdin, stdout and/or stderr are closed. As it is difficult for an application to determine if the first three fds are connected to the std-handles or something else and because many programmers just rely on these three fds to be connected to the std-handles, this function makes sure that it doesn't use these three fds.
int *fd - pointer to the fd which is to be checked and dupped.
int - 0: Ok >0: errno
sge_get_max_fd() -- get max filedescriptor count
int sge_get_max_fd(void)
This function returns the nr of file descriptors which are available (Where fd 0 is the first one). So the highest file descriptor value is: max_fd - 1.
void - no input paramteres
int - max. possible open file descriptor count on this system
sge_get_pids() -- Return all "pids" of a running processes
int sge_get_pids(pid_t *pids, int max_pids, const char *name, const char *pscommand)
Return all "pids" of a running processes with given "name". Only first 8 characters of "name" are significant. Checks only basename of command after "/".
pid_t *pids - pid array int max_pids - size of pid array const char *name - name const char *pscommand - ps commandline
int - Result 0 - No program with given name found >0 - Number of processes with "name" -1 - Error
MT-NOTES: sge_get_pids() is not MT safe
sge_getcpuload() -- Retrieve cpu utilization percentage
int sge_getcpuload(double *cpu_load)
Retrieve cpu utilization percentage (load value "cpu")
double *cpu_load - caller passes adr of double variable for cpu load
int - error state 0 - OK !0 - Error
sge_mem_info_t -- Structure to store memory information
typedef struct { double mem_total; double mem_free; double swap_total; double swap_free; #ifdef IRIX double swap_rsvd; #endif } sge_mem_info_t;
mem_total - total amount of memory in MB mem_free - amount of free memory in MB swap_total - total amount of swap space in MB swap_free - amount of free swap space in MB swap_rsvd - amount of reserved swap space in MB
sge_nprocs() -- Number of processors in this machine
int sge_nprocs()
Use this function to get the number of processors in this machine
int - number of procs
MT-NOTE: sge_nprocs() is MT safe (SOLARIS, NEC, IRIX, ALPHA, HPUX, LINUX)
sge_occupy_first_three() -- Open descriptor 0, 1, 2 to /dev/null
int sge_occupy_first_three(void)
Occupy the first three filedescriptors, if not available. This is done to be sure that a communication by a socket will not get any "forgotten" print output from code.
int - error state -1 - OK 0 - there are problems with stdin 1 - there are problems with stdout 2 - there are problems with stderr
MT-NOTE: sge_occupy_first_three() is MT safe
parse_script_params() -- Parse prolog/epilog/pe_start/pe_stop line from config
char *parse_script_params(char **script_file)
Parses the config value for prolog/epilog/pe_start or pe_stop. Retrieves the target user (as whom the script should be run) and eats the target user from the config value string, so that the path of the script file remains.
char **script_file - Pointer to the string containing the conf value. syntax: [<user>@]<path>, e.g. joe@/home/joe/script
char **script_file - Pointer to the string containing the script path.
char* - If one is given, the name of the user. Else NULL.
path_mt_init() -- Initialize global SGE path state for multi threading use.
void path_mt_init(void)
Set up global SGE path state. This function must be called at least once before any of the path oriented functions can be used. This function is idempotent, i.e. it is safe to call it multiple times. Thread local storage for the path state information is reserved.
void - NONE
void - NONE
MT-NOTE: path_mt_init() is MT safe
path_once_init() -- One-time SGE path state initialization.
static path_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: path_once_init() is MT safe.
path_state_destroy() -- Free thread local storage
static void path_state_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memory which should be freed.
static void - none
MT-NOTE: path_state_destroy() is MT safe.
path_state_get_????() - read access to SGE path state.
Provide access to thread local storage.
path_state_init() -- Initialize SGE path state.
static void path_state_init( path_state_t* theState)
Initialize SGE path state.
path_state_t* theState - Pointer to SGE path state structure.
static void - none
MT-NOTE: path_state_init() is MT safe.
path_state_get_????() - write access to SGE path state.
Provide access to thread local storage.
sge_setup_paths() -- setup global paths
bool sge_setup_paths(const char *sge_cell, dstring *error_dstring)
Set SGE_ROOT and SGE_CELL dependent path components. The spool directory may later be overridden by global configuration. This function calls 'path_mt_init()' to initialize thread local storage. This function is idempotent, i.e. it is safe to inovke it multiple times.
const char *sge_cell - the SGE cell to be used
dstring *error_dstring - A string buffer to return error messages. Also used by caller to indicate if setup function should exit on errror or not.
bool - true on success, else false
MT-NOTE: sge_setup_paths() is MT safe
Profiling -- A simple profiling utility
The profiling module provides a number of utility functions to output some performance metrics about a program, like wallclock, busy time, user and system cpu time etc. Profiling can be started and stopped, the measured data can be reset to 0. Profiling for individual code blocks can be done by starting and stopping a measurement. Measured data can be queried individually for each metric variable, or an informational message string can be requested containing the most interesting variables. To distinguish profiling data for different modules of a program, (e.g. time/cpu consumed for communication, spooling, etc.), multiple levels have been introduced. Besides the predefined levels, there exist 10 custom levels (SGE_PROF_CUSTOM0 up to SGE_PROF_CUSTOM9) that can be used to profile individual parts of a program. The predefined levels shall only be used by the developers of the corresponding components. The level SGE_PROF_OTHER is maintained by the profiling module itself and collects the remaining usage not covered by other levels. It shall NOT be used outside the profiling module itself. A measurement is always done for a certain level. If a measurement for a certain level is started, while another measurement for another level is still active, the data of the subordinated measurement is remembered in the superordinated level. When retrieving profiling information, a parameter defines whether information for subordinated measurements shall be included or excluded. Cyclic starting of measurements is not allowed and will result in profiling being switched off.
There is a test program (libs/uti/test_sge_profiling) and the module is used in sge_schedd (daemons/schedd/scheduler.c), in the event mirror module (libs/gdi/sge_mirror.c), the qmaster and his threads, execd and the spooling test program (libs/spool/test_sge_spooling.c).
MT-NOTE: this module is MT safe, if prof_mt_init() and/or sge_prof_set_enabled() are called before profiling is started and sge_prof_cleanup() is called after all threads which make profiling calls have been stopped! sge_prof_cleanup() is used to free the profiling array
In a multithreaded program, the values delivered by the times system call for cpu system and user time are per process times. This module assumes that the values delivered by times are per thread values. In the profiling output, the sum of user and system time can be higher than the wallclock time, the utilization greater 100%.
- Replace all pthread_mutex_(un)lock() calls with sge_mutex_(un)lock() - Separate public and private interfaces so that thread index can be passed around instead of always being rediscovered - Replace static array with thread specific storage? - Document static functions - Print levels without names
Defines -- Defines and macros for profiling
#define PROF_START_MEASUREMENT ... #define PROF_STOP_MEASUREMENT ...
Macros to start and stop a profiling measurement. They test if profiling is enabled at all and then call the functions to start or stop a measurement.
PROF_START_MEASUREMENT() -- starts the measurement for the specified level
PROF_START_MEASUREMENT(prof_level level)
starts the measurement for the specified level to use profiling the sge_prof_setup() function must be called in the main program first. At the end of the main program, sge_prof_cleanup() should be called to make sure, that all that stuff becomes clean.
prof_level level
PROF_START_MEASUREMENT(SGE_PROF_GDI)
MT-NOTE: PROF_START_MEASUREMENT() is MT safe
PROF_STOP_MEASUREMENT() -- stops the measurement for the specified level
PROF_STOP_MEASUREMENT(prof_level level)
stops the measurement for the specified level to use profiling the sge_prof_setup() function must be called in the main program first. At the end of the main program, sge_prof_cleanup() should be called to make sure, that all that stuff becomes clean.
prof_level level
PROF_STOP_MEASUREMENT(SGE_PROF_GDI)
MT-NOTE: PROF_STOP_MEASUREMENT() is MT safe
get_thread_info() -- get the thread name/id mapping array
thread_info_t* get_thread_info(void)
if the thread name/id mapping array is not initialized it will be done
returns a pointer to the thread name/id mapping array
MT-NOTE: get_thread_info() is MT safe
init_array() -- mallocs memory for the sge_prof_info_t array
void init_array(pthread_t num)
mallocs memory for sge_prof_info_t array for the number of MAX_THREAD_NUM threads mallocs memory for each thread if nedded
the thread id, which needs malloced memory
MT-NOTE: init_array() is MT safe
init_thread_info() -- mallocs memory for the thread_info_t array
void init_thread_info(void)
mallocs memory for thread_info_t array (thread name/id mapping) for the number of MAX_THREAD_NUM threads. Must be called once per process.
MT-NOTE: init_thread_info() is MT safe
prof_get_info_string() -- get informational message
const char* prof_get_info_string(prof_level level, bool with_sub, dstring *error)
Returns a string containing the most interesting data, both for the last measurement and for the total runtime: - wallclock of measurement - user cpu time of measurement - system cpu time of measurement - total wallclock time (runtime) - total busys time - utilization (busy time / wallclock time) * 100 %
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
const char* - pointer to result string. It is valid until the next call of prof_get_info_string() on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
The result can look like the following: "wc = 0.190s, utime = 0.120s, stime = 0.000s, runtime 9515s, busy 105s, utilization 1%"
MT-NOTE: prof_get_info_string() is MT safe
prof_get_measurement_stime() -- return system cpu time of measurement
double prof_get_measurement_stime(prof_level level, bool with_sub, dstring *error)
Returns the system cpu time of the last measurement in seconds. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the system cpu time of the last measurement on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_measurement_stime() is MT safe
prof_get_measurement_utime() -- return user cpu time of measurement
double prof_get_measurement_utime(prof_level level, bool with_sub, dstring *error)
Returns the user cpu time of the last measurement in seconds. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the user cpu time of the last measurement on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_measurement_utime() is not MT safe
prof_get_measurement_wallclock() -- return wallclock of a measurement
double prof_get_measurement_wallclock(prof_level level, bool with_sub, dstring *error)
Returns the wallclock of the last measurement in seconds. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the wallclock time of the last measurement on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
double - the wallclock time of the last measurement on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_measurement_wallclock() is MT safe
prof_get_total_busy() -- return total busy time
double prof_get_total_busy(prof_level level, bool with_sub, dstring *error)
Returns the total busy time since profiling was enabled in seconds. Busy time is the time between starting and stopping a measurement. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the total busy time of the profiling run on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_total_busy() is MT safe
prof_get_total_stime() -- get total system cpu time
double prof_get_total_stime(prof_level level, bool with_sub)
Returns the total system cpu time since profiling was enabled in seconds. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the total system cpu time of the profiling run on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_total_stime() is MT safe
prof_get_total_utime() -- get total user cpu time
double prof_get_total_utime(prof_level level, bool with_sub, dstring *error)
Returns the user cpu time since profiling was enabled in seconds. Resolution is clock ticks (_SC_CLK_TCK).
prof_level level - level to process bool with_sub - include usage of subordinated measurements? dstring *error - if != NULL, error messages will be put here
double - the total user cpu time of the profiling run on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_total_utime() is MT safe
prof_get_total_wallclock() -- get total wallclock time
double prof_get_total_wallclock(dstring *error)
Returns the wallclock time since profiling was enabled in seconds. Resolution is clock ticks (_SC_CLK_TCK).
dstring *error - if != NULL, error messages will be put here
double - the total wallclock time of the profiling run on error, 0 is returned and an error message is written to the buffer given in parameter error, if error != NULL
MT-NOTE: prof_get_total_wallclock() is MT safe
prof_info_init() -- initialize the sge_prof_info_t struc array with default values
static void prof_info_init(prof_level level)
initialize the sge_prof_info_t struct array with default values
prof_level level
initialized sge_prof_info_t array for the given profiling level
MT-NOTE: prof_info_init() is MT safe
prof_info_level_init() -- initialize the sge_prof_info_t struc array with default values
static void prof_info_level_init(prof_level level)
initialize the sge_prof_info_t struct array with default values
prof_level i int thread_num
initialized sge_prof_info_t array for the given profiling level
MT-NOTE: prof_info_level_init() is MT safe
prof_is_active() -- is profiling active?
bool prof_is_active(void)
Returns true, if profiling is active, else false.
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_is_active() is MT safe
prof_reset() -- reset usage information
bool prof_reset(dstring *error)
Reset usage and timing information to 0.
dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_reset() is MT safe
prof_reset_thread() -- reset usage information
bool prof_reset_thread(int thread_num, prof_level level)
Reset usage and timing information for a single thread and level to 0.
int thread_num the thread to reset prof_level level the profiling level to reset
MT-NOTE: prof_reset() is MT safe
prof_set_level_name() -- set name of a custom level
bool prof_set_level_name(prof_level level, const char *name)
Set the name of a custom profiling level.
prof_level level - level to edit const char *name - new name for level dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_set_level_name() is MT safe
prof_start() -- start profiling
bool prof_start(dstring *error)
Enables profiling. All internal variables are reset to 0. Performance measurement has to be started and stopped by calling profiling_start_measurement or profiling_stop_measurement.
dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_start() is MT safe
prof_start_measurement() -- start measurement
bool prof_start_measurement(prof_level level, dstring *error)
Starts measurement of performance data. Retrieves and stores current time and usage information.
prof_level level - level to process dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_start_measurement() is MT safe
prof_stop() -- stop profiling
bool prof_stop(dstring *error)
Profiling is disabled. Subsequent calls to profiling_start_measurement or profiling_stop_measurement will have no effect. Profiling can be re-enabled by calling profiling_start.
dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_start() is MT safe
prof_stop_measurement() -- stop measurement
bool prof_stop_measurement(prof_level level, dstring *error)
Stops measurement for a certain code block. Retrieves and stores current time and usage information. Sums up global usage information.
prof_level level - level to process dstring *error - if != NULL, error messages will be put here
bool - true on success, else false is returned and an error message is returned in parameter error, if error != NULL
MT-NOTE: prof_stop_measurement() is MT safe
prof_thread_local_once_init() -- inititalizes the profiling array
void prof_thread_local_once_init(void)
Initializes the profiling array.
MT-NOTE: prof_thread_local_once_init() is MT safe only if called before any other profiling calls other than sge_prof_set_enabled()
set_thread_name() -- set the thread name mapped to its id
void set_thread_name(pthread_t thread_id, const char* thread_name)
maps the name and the id of a thread set the thread profiling status to false
pthread_t thread_id const char* thread_name
MT-NOTE: set_thread_info() is MT safe
set_thread_prof_status_by_id() -- sets the profiling status for the thread with the given thread id
void set_thread_prof_status_by_id(pthread_t thread_id, bool prof_status)
set the thread profiling status of the thread with the given id
pthread_t thread_id bool prof_status
MT-NOTE: set_thread_prof_status_by_id() is MT safe
set_thread_prof_status_by_name() -- sets the profiling status for the thread with the given thread id and thread name
void set_thread_prof_status_by_name(pthread_t thread_id, const char* thread_name, bool prof_status)
set the thread profiling status of the thread with the given id and name
pthread_t thread_id const char* thread_name bool prof_status
return 0 - ok return 1 - thread_name = NULL
MT-NOTE: set_thread_prof_status_by_name() is MT safe
sge_prof_cleanup() -- frees the profiling array
void sge_prof_cleanup(void)
frees the profiling array
MT-NOTE: sge_prof_cleanup() is MT safe
sge_prof_set_enabled() -- enables/disables profiling
void sge_prof_set_enabled(bool enabled)
Enables/disables profiling completely. Profiling is enabled by default. This method is the fix to Issue 1471.
bool enabled Whether profiling should be enabled
MT-NOTE: sge_prof_set_enabled() is MT safe only if called before any other profiling calls
thread_output_profiling() -- output profiling info for thread
void thread_output_profiling(const char *title, time_t *next_prof_output)
Outputs profiling information for the current thread. Information for all active profiling levels is dumped. The first line dumped is a sort of title, that can/should be used to identify the thread. The variable next_prof_output will be set by this function. This variable should be initialized to 0 (zero) by the caller before the first call of this function.
const char *title - title to print as first line time_t *next_prof_output - time of next profiling output
MT-NOTE: thread_output_profiling() is MT safe
thread_prof_active_by_id() -- returns the status of a thread
bool thread_prof_active_by_id(pthread_t thread_id)
returns the profiling status of a thread
pthread_t thread_id
MT-NOTE: thread_prof_active_by_id() is MT safe
thread_prof_active_by_name() -- returns the status of a thread
bool thread_prof_active_by_name(pthread_t thread_id)
returns the profiling status of a thread
pthread_t thread_id
MT-NOTE: thread_prof_active_by_name() is MT safe
thread_start_stop_profiling() -- start profiling for thread
void thread_start_stop_profiling(void)
Checks if profiling has been enabled for the current thread. If yes, starts profiling for all levels. If profiling has been disabled for the current thread, profiling is disabled for all levels.
MT-NOTE: thread_start_stop_profiling() is MT safe
prog_once_init() -- One-time executable state initialization.
static prog_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: prog_once_init() is MT safe.
prog_state_destroy() -- Free thread local storage
static void prog_state_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memroy which should be freed.
static void - none
MT-NOTE: prog_state_destroy() is MT safe.
prog_state_getspecific() -- Get thread local prog state
static prog_state_t* prog_state_getspecific(pthread_key_t aKey)
Return thread local prog state. If a given thread does call this function for the first time, no thread local prog state is available for this particular thread. In this case the thread local prog state is allocated and set.
pthread_key_t aKey - Key for thread local prog state.
static prog_state_t* - Pointer to thread local prog state
MT-NOTE: prog_state_getspecific() is MT safe
prog_state_init() -- Initialize executable state.
static void prog_state_init(prog_state_t *theState)
Initialize executable state.
struct prog_state_t* theState - Pointer to executable state structure.
static void - none
MT-NOTE: prog_state_init() in MT safe.
sge_get_alias_path() -- Return the path of the 'alias_file'
const char* sge_get_alias_path(void)
Return the path of the 'alias_file'
MT-NOTE: sge_get_alias_path() is MT safe
sge_get_arch() -- SGE/EE architecture string
const char* sge_get_arch(void)
This function returns the SGE/EE architecture string of that host where the application is running which called this functionon. NOTES: MT-NOTE: sge_get_arch() is MT safe
const char* - architecture string
sge_get_default_cell() -- get cell name and remove trailing slash
const char* sge_get_default_cell(void)
This function returns the defined cell name of SGE. This directory is defined by the SGE_CELL environment variable of the calling process. If the environment variable does not exist or is not set then this function will return the 'DEFAULT_CELL'.
const char* - Cell name of this SGE installation
MT-NOTE: sge_get_default_cell() is MT safe
sge_get_lib_dir() -- Path to SGE libraries
int sge_get_lib_dir(char *buffer, size_t size)
This function stores the path to the SGE libraries in the buffer
char *buffer - Buffer where to store the SGE library dir size_t size - Size of the given buffer NOTES: MT-NOTE: sge_get_lib_dir() is MT safe
int - Return code 1 - Success -1 - Given buffer is NULL -2 - SGE_ROOT cannot be obtained -3 - given buffer is to small
sge_get_root_dir() -- SGE installation directory
const char* sge_get_root_dir(int do_exit, char *buffer, size_t size, int do_error_log )
This function returns the installation directory of SGE. This directory is defined by the SGE_ROOT environment variable of the calling process. If the environment variable does not exist or is not set then this function will handle this as error and return NULL (do_exit = 0). If 'do_exit' is 1 and an error occures, the function will terminate the calling application.
int do_exit - Terminate the application in case of an error char *buffer - buffer to be used for error message size_t size - size of buffer int do_error_log - enable/disable error logging
const char* - Root directory of the SGE installation
MT-NOTE: sge_get_arch() is MT safe
sge_getme() -- Initialize me-struct
void sge_getme(u_long32 program_number)
Initialize me-struct according to 'program_number'
u_long32 program_number - uniq internal program number
MT-NOTE: sge_getme() is MT safe
sge_show_me() -- Show content of me structure
static void sge_show_me()
Show content of me structure in debug output
MT-NOTE: sge_show_me() is MT safe
uti_state_get_????() - read access to utilib global variables
Provides access to either global variable or per thread global variable.
uti_state_get_exit_func() -- Return installed exit funciton
sge_exit_func_t uti_state_get_exit_func(void)
Returns installed exit funciton. Exit function will be called be sge_exit()
sge_exit_func_t - function pointer
uti_state_set_????() - write access to utilib global variables
Provides access to either global variable or per thread global variable.
uti_state_set_exit_func() -- Installs a new exit handler
void uti_state_set_exit_func(sge_exit_func_t f)
Installs a new exit handler. Exit function will be called be sge_exit()
sge_exit_func_t f - new function pointer
fork_no_pty() -- Opens pipes, forks and redirects the std handles
pid_t fork_no_pty(int *fd_pipe_in, int *fd_pipe_out, int *fd_pipe_err, dstring *err_msg)
Opens three pipes, forks and redirects stdin, stdout and stderr of the child to the pty.
int *fd_pipe_in - int[2] array for the two stdin pipe file descriptors int *fd_pipe_out - int[2] array for the two stdout pipe file descriptors int *fd_pipe_err - int[2] array for the two stderr pipe file descriptors dstring *err_msg - Receives an error string in case of error.
pid_t - -1 in case of error, 0 in the child process, or the pid of the child process in the parent process.
MT-NOTE: fork_no_pty() is not MT safe
fork_pty() -- Opens a pty, forks and redirects the std handles
pid_t fork_pty(int *ptrfdm, int *fd_pipe_err, dstring *err_msg)
Opens a pty, forks and redirects stdin, stdout and stderr of the child to the pty.
int *ptrfdm - Receives the file descriptor of the master side of the pty. int *fd_pipe_err - A int[2] array that receives the file descriptors of a pipe to separately redirect stderr. To achieve the same behaviour like rlogin/rsh, this is normally disabled, compile with -DUSE_PTY_AND_PIPE_ERR to enable this feature. dstring *err_msg - Receives an error string in case of error. uid_t uid - uid for pty owner
pid_t - -1 in case of error, 0 in the child process, or the pid of the child process in the parent process.
MT-NOTE: fork_pty() is not MT safe
ptym_open() -- Opens a pty master device
int ptym_open(char *pts_name)
Searches for a free pty master device and opens it.
char *pts_name - A buffer that is to receive the name of the pty master device. Must be at least 12 bytes large.
int - The file descriptor of the pty master device. -1 in case of error.
MT-NOTE: ptym_open() is not MT safe
ptys_open() -- Opens a pty slave device.
int ptys_open(int fdm, char *pts_name)
Opens a pty slave device that matches to a given pty master device.
int fdm - File descriptor of the pty master device. char *pts_name - The name of the master slave device.
int - File descriptor of the pty slave device. -1 in case of error.
MT-NOTE: ptys_open() is not MT safe
terminal_enter_raw_mode() -- Sets terminal to raw mode
int terminal_enter_raw_mode(void)
Sets terminal to raw mode, i.e. no control characters are interpreted any more, but are simply printed.
int - 0 if Ok, else errno
MT-NOTE: terminal_enter_raw_mode() is not MT safe
terminal_leave_raw_mode() -- restore previous terminal mode
int terminal_leave_raw_mode(void)
Restores the previous terminal mode.
int - 0 if Ok, else errno
MT-NOTE: terminal_leave_raw_mode() is not MT safe
sanitize_environment() -- remove sensitive variables from the environment before calling programs
#include "uti/execvlp.h" void sanitize_environment(char *env[])
Remove variables from the environment which represent a security risk when a program is called under a privileged id with an environment supplied by the user, such as remote communication daemons. (For instance, if the user can get a dynamically-linked privileged program run in an ELF environment with arbitrary LD_LIBRARY_PATH or LD_PRELOAD, all bets are off.)
sge_copy_sanitize_environment() -- make a copy of environment with sensitive variables removed
#include "uti/execvlp.h" char **sge_copy_sanitize_env(char *env[])
Remove variables from the environment which represent a security risk if when a program is called under a privileged id with an environment supplied by the user, for example, remote communication daemons. (If the user can get a dynamically-linked privileged program run in an ELF environment, say, with arbitrary LD_LIBRARY_PATH or LD_PRELOAD, all bets are off.) Also try to protect shell scripts from IFS, at least.
sge_dlopen -- interface to dlopen
#include <uti/sge_dlopen.h> void *sge_dlopen(const char *libbase, const char *libversion)
Call dlopen on a shared library name in a system-dependent way. Flags RTLD_NOW and RTLD_GLOBAL are used, along with RTLD_NODELETE, if it is defined.
libbase - Name of shared library. A system-dependent extension is appended if it doesn't have one. libversion - Version string appended to the shared library name if non-NULL. Currently only used for ELF libraries.
As for dlopen.
sge_execvlp -- like execve, but search the path
#include "uti/execvlp.h" int sge_execvlp (const char *file, char *const argv[], char *const envp[])
A version of execve that does a path search for the executable like execlp/execvp.
file - name of executable argv - null-terminated list of arguments envp - null-terminated list of environment elements
on success, the function will not return (it execs) -1 if the exec fails
log_state_get_log_file() -- get log file name
const char* log_state_get_log_file(void)
Return name of current log file. The string returned may or may not contain a path.
void - none
const char* - log file name (with relative or absolute path)
MT-NOTE: log_state_get_log_file() is not MT safe. MT-NOTE: MT-NOTE: It is safe, however, to call this function from within multiple MT-NOTE: threads as long as no other thread does change 'Log_File'.
BUGBUG-AD: This function should use something like a barrier for BUGBUG-AD: synchronization.
sge_do_log() -- Write message to log file (or syslog)
static void sge_do_log(u_long32 me, const char* progname, const char* unqualified_hostname, int aLevel, const char *aMessage, int log_level)
???
u_long32 me - process type (QMASTER etc.) const char* progname - program name const char* unqualified_hostname - name of host issuing message int aLevel - log level const char *aMessage - log message int log_level - numeric level from which aLevel is derived
void - none
MT-NOTE: sge_do_log() is MT safe.
sge_shlib_ext -- return system-dependent shared librray extension
#include <uti/sge_dlopen.h> const char *sge_shlib_ext()
Return shared library extension for the system, e.g. ".so".
Library extension.
sge_mkstemp() -- SGE version of mkstemp()
int sge_mkstemp(char *aBuffer, size_t size, dstring *error_message)
SGE-specific version of mkstemp(3) that tries TMPDIR as well as P_tmpdir before /tmp, returns an error message, and guarantees read and write access for the user only. The 'aBuffer' argument points to an array of at least 'size' in length. 'aBuffer' will contain the generated filename upon successful completion, and the file descriptor for the opened file is returned. If the function fails, -1 will be returned, with an error message in error_message.
char *aBuffer - Array to hold filename size_t size - size of aBuffer dstring error_message - Error message
char* - Points to 'aBuffer' if successful, NULL otherwise
MT-NOTE: sge_mkstemp() is MT safe.
sge_map_signal() -- Map system signal to 32bit SGE/EE signal
u_long32 sge_map_signal(int sys_sig)
Map the system specific signal to the 32bit sge signal
int sys_sig - system signal
u_long32 - SGE/EE Signal
MT-NOTE: sge_map_signal() is MT safe
sge_set_def_sig_mask() -- Set signal mask to default
void sge_set_def_sig_mask(int sig_num, err_func_t err_func)
Set signal mask to default for all signals except given signal
sigset_t sig_num - signals which should be ignored (use sigemptyset and sigaddset to set signals, if NULL, no signals are ignored) err_func_t err_func - callback function to report errors
MT-NOTE: sge_set_def_sig_mask() is MT safe
sge_sig2str() -- Make a string out of a SGE/EE signal
const char* sge_sig2str(u_long32 sge_sig)
Make a string out of a SGE/EE signal
u_long32 sge_sig - SGE/EE signal
const char* - signal string
MT-NOTE: sge_sig2str() is MT safe
str2signal() -- Make an SGE signal out of a string
u_long32 sge_str2signal(const char *str)
Make a sge signal out of a string. 'str' can be the signal name (caseinsensitive) without sig or the signal number (Take care numbers are system dependent).
const char *str - signal string
u_long32 - SGE/EE signal
MT-NOTE: sge_str2signal() is MT safe
sge_sys_sig2str() -- Make a string out of a system signal
const char* sge_sys_sig2str(u_long32 sys_sig)
Make a string out of a system signal
u_long32 sys_sig - system signal
const char* - signal string
MT-NOTE: sge_sys_sig2str() is MT safe
sge_sys_str2signal() -- Make an SGE signal out of a string
u_long32 sge_sys_str2signal(const char *str)
Make an SGE signal out of a string
const char *str - signal name
u_long32 - SGE/EE signal
MT-NOTE: sge_sys_str2signal() is MT safe
sge_thread_block_all_signals()
int sge_thread_block_all_signals(void)
Blocks all signals the OS knows for the calling thread.
sigset_t *oldsigmask - the sigmask of this thread that was set before this function was called.
int - 0 if ok, errno if pthread_sigmask failed, 1000 if oldsigmask == NULL.
MT-NOTE: sge_thread_block_signals() is MT safe
sge_unblock_all_signals()
void sge_unblock_all_signals(void)
Allow for all signals.
MT-NOTE: sge_unblock_all_signals() is MT safe
sge_unmap_signal() -- Unmap 32bit SGE/EE signal to system signal
int sge_unmap_signal(u_long32 sge_sig)
Unmap the 32bit SGE/EEsignal to the system specific signal
u_long32 sge_sig - SGE/EE signal
int - system signal
MT-NOTE: sge_unmap_signal() is MT safe
sl - A Simple List Implementation for Grid Engine
This module provides a simple and thread safe list implementation for Grid Engine. Lists can be created, destroyed and the number of the contained nodes can be retrieved. sge_sl_create() sge_sl_destroy() sge_sl_get_elements() The list is implemented as double links list so that data can be accessed forward and backward easily. Function arguments decide if the first or last element should be addressed. sge_sl_insert() sge_sl_delete() sge_sl_data() Elements can also be inserted into a sorted list or they can be searched using a user defined compare function. sge_sl_insert_search() sge_sl_delete_search() sge_sl_data_search() sge_sl_sort() The underlaying list data structure is thread safe so that one list can be accessed without additional synchronisation between the threads. Node data structures are NOT thread safe for that reason following functions need additional synchronisation because they provide access to node data structures. sge_sl_elem_create() sge_sl_elem_destroy() sge_sl_elem_data() sge_sl_elem_next() sge_sl_elem_search() sge_sl_dechain() sge_sl_insert_before() sge_sl_append_after() The list implementation provides locking functions that provide a way to synchronize access with a list object. Therefore it is easily possible to secure the above node based functions and execute them in an atomic block. sge_sl_lock() sge_sl_unlock() Please be cautious when you need other locks in a code block between the lock and unlock function. If the sequence in demanding the locks is not correct this might cause a deadlock.
sge_sl_append_after() -- Appends a new element after another one
bool sge_sl_append_after(sge_sl_list_t *list, sge_sl_elem_t *new_elem, sge_sl_elem_t *elem)
This elements appends 'new_elem' into 'list' after 'elem'.
sge_sl_list_t *list - sl list sge_sl_elem_t *new_elem - new sl elem sge_sl_elem_t *elem - sl elem already part of list
bool - error state true - success false - error
MT-NOTE: sge_sl_append_after() is MT safe
sge_sl_create() -- Create a new simple list
bool sge_sl_create(sge_sl_list_t **list)
This function creates a new simple list and returns the list in the 'list' parameter. In case of an error NULL will be returned.
sge_sl_list_t **list - new simple list
bool - error state true - success false - error
MT-NOTE: sge_sl_create() is MT safe
sge_sl_data() -- returns the first or last data element
bool sge_sl_data(sge_sl_list_t *list, void **data, sge_sl_direction_t direction)
Depending on 'direction' this function returns the pointer to the first/last data object of 'list' in 'data'.
sge_sl_list_t *list - list void **data - data pointer sge_sl_direction_t direction - direction
bool - error state true - success false - error
MT-NOTE: sge_sl_data() is MT safe
sge_sl_data_search() -- search a elements in list
bool sge_sl_data_search(sge_sl_list_t *list, void *key, void **data, sge_sl_compare_f compare, sge_sl_direction_t direction)
This function tries to find a element in 'list'. As result of the search the 'data' pointer will be returned. To find the data pointer the 'compare' function and the 'key' will be used. 'key' is past as first argument to the 'compare' function. 'direction' decides if this function starts the search from beginning or end of the list.
sge_sl_list_t *list - list void *key - search key void **data - returned data pointer sge_sl_compare_f compare - compare function sge_sl_direction_t direction - direction
bool - error state true - success false - error
MT-NOTE: sge_sl_data_search() is MT safe
sge_sl_dechain() -- unchains a element from a list
bool sge_sl_dechain(sge_sl_list_t *list, sge_sl_elem_t *elem)
This functions unchains 'elem' from 'list'. 'elem' can afterwards be inserted into a list again or can be destroyed.
sge_sl_list_t *list - sl list sge_sl_elem_t *elem - sl elem
bool - error state true - success false - error
MT-NOTE: sge_sl_dechain() is MT safe
sge_sl_delete() -- delete first/last element
bool sge_sl_delete(sge_sl_list_t *list, sge_sl_destroy_f destroy, sge_sl_direction_t direction)
This function deletes the first/last element of 'list' depending on the provided 'direction'. If 'destroy' is not NULL then this function will be used to destroy the element data.
sge_sl_list_t *list - list sge_sl_destroy_f destroy - destroy sge_sl_direction_t direction - direction
bool - error state true - success false - error
MT-NOTE: sge_sl_delete() is MT safe
sge_sl_delete_search() -- search a element and delete it
bool sge_sl_delete_search(sge_sl_list_t *list, void *key, sge_sl_destroy_f destroy, sge_sl_compare_f compare, sge_sl_direction_t direction)
This function searches a element in 'list' using the 'key' and 'compare' function and then deletes it. If 'direction' is SGE_SL_FORWARD then the search will start from beginning, otherwise from the end of the list. The first matched element will be destroyed. If there is a 'destroy' function provided then this function will be used to destroy the element data.
sge_sl_list_t *list - list void *key - search key sge_sl_destroy_f destroy - destroy function sge_sl_compare_f compare - compare function sge_sl_direction_t direction - search direction
bool - error state true - success false - error
MT-NOTE: sge_sl_delete_search() is MT safe
sge_sl_destroy() -- Destroys a simple list
bool sge_sl_destroy(sge_sl_list_t **list, sge_sl_destroy_f destroy)
This function destroys 'list' and sets the pointer to NULL. If a 'destroy' function is provided then it will be used to destroy all data elements that are referenced by the list elements.
sge_sl_list_t **list - sl list sge_sl_destroy_f destroy - destroy function
bool - error state true - success false - error
MT-NOTE: sge_sl_destroy() is not MT safe
Here is an example for a destroy function for a C string. bool destroy(void **data_ptr) { char *string = *(char **) data_ptr; sge_free(&string); return true; }
sge_sl_elem_count() -- returns the number of elements
u_long32 sge_sl_elem_count(sge_sl_list_t *list)
This function returns the number of elements contained in 'list'.
sge_sl_list_t *list - list pointer
u_long32 - number of elements
MT-NOTE: sge_sl_elem_count() is MT safe
sge_sl_elem_create() -- create a list element
bool sge_sl_elem_create(sge_sl_elem_t **elem, void *data)
This function creates a new sl element that can later on be inserted into a sl list. On success the function creates the element stores the 'data' pointer in it and returns the element pointer in 'elem'. On error false is returned by this function and 'elem' contains a NULL pointer. sge_sl_elem_destroy() can be used to destroy elements that were created with this function.
sge_sl_elem_t **elem - location were the pointer to the new element will be stored void *data - data pointer that will be stored in elem
bool - error state true - success false - error
MT-NOTE: sge_sl_elem_create() is MT safe
sge_sl_elem_data() -- return first/last data pointer
void *sge_sl_elem_data(sge_sl_elem_t *elem)
returns the stored data pointer of an element
sge_sl_elem_t *elem - sl element
void * - data pointer
MT-NOTE: sge_sl_elem_data() is MT safe
sge_sl_elem_destroy() -- destroys a sl element
bool sge_sl_elem_destroy(sge_sl_elem_t **elem, sge_sl_destroy_f destroy) typedef bool (*sge_sl_destroy_f)(void **data);
This function destroys the provided sl 'elem' and optionally destroys also the data that is referenced in the element if a 'destroy' function is passed. If 'elem' is part of a list it has to be unchained before this function can be called. Otherwise the list would be corrupted. On success elem will be set to NULL and the function returns true.
sge_sl_elem_t **elem - pointer to a sl element pointer sge_sl_destroy_f destroy - destroy function
bool - error state true - success false - error
Here is an example for a destroy function for a C string. bool destroy(void **data_ptr) { char *string = *(char **) data_ptr; sge_free(&string); return true; }
MT-NOTE: sge_sl_elem_destroy() is MT safe.
sge_sl_elem_next() -- provides the next element in sequence
bool sge_sl_elem_next(sge_sl_list_t *list, sge_sl_elem_t **elem, sge_sl_direction_t direction)
This function provides the possibility to iterate over all elements in 'list'. 'elem' will contain a pointer to an element when the function returns or the value NULL. 'elem' is also an input parameter and it defines what element of 'list' is returned. If *elem is NULL and direction is SGE_SL_FORWARD them *elem will contain the first element in 'list'. If direction is SGE_SL_BACKWARD then it will contain the last. If *elem is not NULL then the next element in the list sequence is returned if direction is SGE_SL_FORWARD or the previous one if direction is SGE_SL_BACKWARD. If the list is empty or if there is no previous/next element then NULL will be retuned in 'elem'.
sge_sl_list_t *list - sl list sge_sl_elem_t **elem - input/output sl elem sge_sl_direction_t direction - direction
bool - error state true - success false - error
Following code shows how it is possible to iterate over the whole list: { sge_sl_list_t *list; sge_sl_elem_t *next; sge_sl_elem_t *current; // assume that elements are added to the list here next = NULL; sge_sl_elem_next(list, &next, SGE_SL_FORWARD); while ((current = next) != NULL) { sge_sl_elem_next(list, &next, SGE_SL_FORWARD); // so something with 'current' here } }
MT-NOTE: sge_sl_elem_next() is MT safe
sge_sl_elem_search() -- searches the next element in sequence
bool sge_sl_elem_search(sge_sl_list_t *list, sge_sl_elem_t **elem, void *key, sge_sl_compare_f compare, sge_sl_direction_t direction)
This function provides the possibility to iterate over certain elements in 'list'. 'elem' will contain a pointer to an element when the function returns or the value NULL. 'elem' is also an input parameter and it defines what element of 'list' is returned. If *elem is NULL and direction is SGE_SL_FORWARD then *elem will contain the first element in 'list' that is equivalent with the provided 'key'. If direction is SGE_SL_BACKWARD then it will contain the last element that matches. If *elem is not NULL then the next element in the list sequence is returned if direction is SGE_SL_FORWARD or the previous one if direction is SGE_SL_BACKWARD. If the list is empty or if there is no previous/next element then NULL will be retuned in 'elem'. The provided 'compare' function is used to compare the provided 'key' with the data that is contained in the element. 'key' is passed as first parameter to the 'compare' function.
sge_sl_list_t *list - sl list sge_sl_elem_t **elem - input/output sl elem void *key - key that must match sge_sl_compare_f compare - compare function sge_sl_direction_t direction - search direction
bool - error state true - success false - error
This compare function could match static C strings stored in a sl list as data pointers. int fnmatch_compare(const void *key_pattern, const void *data) { int ret = 0; if (key_pattern != NULL && data != NULL) { ret = fnmatch(*(char**)key_pattern, *(char**)data, 0); } return ret; }
MT-NOTE: sge_sl_elem_search() is MT safe
sge_sl_get_mutex() -- returns the list mutex
pthread_mutex_t * sge_sl_get_mutex(sge_sl_list_t *list)
retrns the list mutex
sge_sl_list_t *list - list
pthread_mutex_t * - mutex used in the list to secure actions
MT-NOTE: sge_sl_get_mutex() is MT safe
sge_sl_insert() -- insert a new element
bool sge_sl_insert(sge_sl_list_t *list, void *data, sge_sl_direction_t direction)
Insert a new node in 'list' that references 'data'. If 'direction' is SGE_SL_FORWARD then the element will be inserted at the beginning of 'list' otherwise at the end.
sge_sl_list_t *list - simple list void *data - data sge_sl_direction_t - direction
bool - error state true - success false - error
MT-NOTE: sge_sl_insert() is MT safe
sge_sl_insert_before() -- inserts a new element before another one
bool sge_sl_insert_before(sge_sl_list_t *list, sge_sl_elem_t *new_elem, sge_sl_elem_t *elem)
Inserts 'new_elem' before 'elem' in 'list'. 'elem' must be an element already part of 'list'.
sge_sl_list_t *list - sl list sge_sl_elem_t *new_elem - new sl element sge_sl_elem_t *elem - sl elem already part of 'list"
bool - error state true - success false - error
MT-NOTE: sge_sl_insert_before() is MT safe
sge_sl_insert_search() -- inserts a new element in a sorted list
bool sge_sl_insert_search(sge_sl_list_t *list, void *data, sge_sl_compare_f *compare)
Inserts a new element in 'list' that references 'data'. The function assumes that 'list' is sorted in ascending order. To find the correct position for the new element the 'compare' function will be used.
sge_sl_list_t *list - list void *data - data reference sge_sl_compare_f compare - compare function
bool - error state true - success false - error
Example for a compare function when data is a C string int compare(const void *data1, const void *data2) { int ret = 0; if (data1 != NULL && data2 != NULL) { ret = strcmp(*(char**)data1, *(char**)data2); } return ret; }
MT-NOTE: sge_sl_insert_search() is MT safe
sge_sl_lock() -- locks a list
bool sge_sl_lock(sge_sl_list_t *list)
A call of this functions locks the provided 'list' so that all list operations executed between the lock and unlock are executed as atomic operation.
sge_sl_list_t *list - list
bool - error state true - success false - error
MT-NOTE: sge_sl_lock() is MT safe
sge_sl_sort() -- Sorts the list
bool sge_sl_sort(sge_sl_list_t *list, sge_sl_compare_f compare)
This function sorts the 'list' with the quick sort algorithm. 'compare' function will be used to compare the list elements.
sge_sl_list_t *list - list sge_sl_compare_f compare - compare function
bool - error state true - success false - error
MT-NOTE: sge_sl_sort() is MT safe
sge_sl_unlock() -- unlocks a list
bool sge_sl_unlock(sge_sl_list_t *list)
A call of this functions unlocks the provided 'list' that was previously locked with sge_sl_lock.
sge_sl_list_t *list - list
bool - error state true - success false - error
MT-NOTE: sge_sl_unlock() is MT safe
sge_file_path_format_t -- Format of filename and pathname
typedef enum { FORMAT_DEFAULT = 0x0000, FORMAT_DOT_FILENAME = 0x0001, FORMAT_FIRST_PART = 0x0002, FORMAT_SECOND_PART = 0x0004, FORMAT_THIRD_PART = 0x0008 } sge_file_path_format_t;
These constants are used with sge_get_file_path() to retrieve file and pathnames for objects which should be spooled onto a filesystem. FORMAT_DEFAULT - as it says the default format FORMAT_DOT_FILENAME - insert a '.' in front of the filename (e.g. '/path/path/.filename) FORMAT_FIRST_PART - first part of pathname (e.g /path) FORMAT_SECOND_PART - (e.g /path/part2) FORMAT_THIRD_PART - (e.g /path/part2/part3)
sge_file_path_id_t -- Type of filename or pathname
typedef enum { JOBS_SPOOL_DIR, JOB_SPOOL_DIR, JOB_SPOOL_DIR_AS_FILE, JOB_SPOOL_FILE, TASKS_SPOOL_DIR, TASK_SPOOL_DIR, TASK_SPOOL_DIR_AS_FILE, TASK_SPOOL_FILE, PE_TASK_SPOOL_FILE, JOB_SCRIPT_DIR, JOB_SCRIPT_FILE, JOB_ACTIVE_DIR } sge_file_path_id_t;
Type of filename or pathname if no other sge_spool_flags_t and/or sge_file_path_format_t are specified with sge_get_file_path(): JOBS_SPOOL_DIR - "./jobs" JOB_SPOOL_DIR - "./jobs/xx/yyyy/zzzz" zzzz is a directory 'xxyyyyzzzz' is a job id JOB_SPOOL_DIR_AS_FILE - "./jobs/xx/yyyy/zzzz" zzzz is a file 'xxyyyyzzzz' is a job id JOB_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/common" TASKS_SPOOL_DIR - "./jobs/xx/yyyy/zzzz/1-4096" (example for task ids between 1 and 4096) TASK_SPOOL_DIR - "./jobs/xx/yyyy/zzzz/1-4096/1" (example for task with id 1 (directory)) TASK_SPOOL_DIR_AS_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1" (example for task with id 1 (file)) TASK_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1/common" (example for task with id 1) PE_TASK_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1/1" (example for ja_task 1 pe_task 1) JOB_SCRIPT_DIR - "./job_scripts" JOB_SCRIPT_FILE - "./job_scripts/1234" (if job id is 1234) JOB_ACTIVE_DIR - "./active_jobs"
sge_get_active_job_file_path() -- Create paths in active_jobs dir
const char* sge_get_active_job_file_path(dstring *buffer, u_long32 job_id, u_long32 ja_task_id, const char *pe_task_id, const char *filename)
Creates paths in the execd's active_jobs directory. Both directory and file paths can be created. The result is placed in a buffer provided by the caller. WARNING: Do only use in shepherd and execution daemon!
dstring *buffer - buffer to hold the generated path u_long32 job_id - job id u_long32 ja_task_id - array task id const char *pe_task_id - optional pe task id const char *filename - optional file name
const char* - pointer to the string buffer on success, else NULL
To create the relative path to a jobs/tasks environment file, the following call would be used: char buffer[SGE_PATH_MAX] sge_get_active_job_file_path(buffer, SGE_PATH_MAX, job_id, ja_task_id, pe_task_id, "environment");
JG: TODO: The function might be converted to or might use a more general path creating function (utilib).
sge_get_confval() -- Get config value for
char* sge_get_confval(const char *conf_val, const char *fname)
Get config value for entry 'conf_val' from file 'fname'.
const char *conf_val - is case insensitive name const char *fname - filename
char* - pointer to internal static buffer
Lines may be up to 1024 characters long. Up to 1024 characters of the config value are copied to the static buffer.
Lines may be up to 1024 characters long. Up to 1024 characters of the config value are copied to the static buffer.
sge_get_confval_array() - Read configuration file entries
int sge_get_confval_array(const char *fname, int n, const char *name[], char value[][1025], dstring *error_dstring)
Reads in an array of configuration file entries
int - 0 on success
Function can not differ multiple similar named entries.
MT-NOTE: sge_get_confval_array() is MT safe
sge_get_file_path() -- Return SGE/EE specific file/pathname
char* sge_get_file_path(char *buffer, sge_file_path_id_t id, sge_file_path_format_t format_flags, sge_spool_flags_t spool_flags, u_long32 ulong_val1, u_long32 ulong_val2, const char *string_val1)
???
char *buffer - buffer for file/pathname sge_file_path_id_t id - type of file/pathname sge_file_path_format_t format_flags - format of returned string sge_spool_flags_t spool_flags - context where the name is needed u_long32 ulong_val1 - 1st ulong u_long32 ulong_val2 - 2nd ulong const char *string_val1 - 1st string
char* - equivalent with 'buffer'
MT-NOTE: sge_get_file_path() is not MT safe due to get_spool_dir_range()
sge_get_ja_tasks_per_directory() -- Configured number of tasks per dir
u_long32 sge_get_ja_tasks_per_directory(void)
Returns the configured number of tasks per directory
u_long32 - the number
MT-NOTE: sge_get_ja_tasks_per_directory() is not MT safe
sge_get_ja_tasks_per_file() -- Configured number of tasks per file
u_long32 sge_get_ja_tasks_per_file(void)
Returns the configured number of tasks per file
u_long32 - the number
MT-NOTE: sge_get_ja_tasks_per_file() is not MT safe
sge_get_management_entry() - Read management.properties file entries
int sge_get_management_entry(const char *fname, int n, const char *name[], char value[][1025], dstring *error_dstring)
Reads in an array of configuration file entries
int - 0 on success
Function can not differ multiple similar named entries.
MT-NOTE: sge_get_management_entry() is MT safe
sge_readpid() -- Read pid from file
pid_t sge_readpid(const char *fname)
Read pid from file 'fname'. The pidfile may be terminated with a '\n'. Empty lines at the beginning of the file are ignored. Whitespaces at the beginning of the line are ignored. Any characters or lines after a valid pid are ignored.
const char *fname - filename
pid_t - process id
MT-NOTE: sge_readpid() is MT safe.
sge_silent_get() -- Show whether silence is enable/disabled
int sge_silent_get()
Show whether silence is enable/disabled
int - 0 or 1
MT-NOTE: sge_silent_get() is not MT safe
sge_silent_set() -- Enable/disable silence during spool ops
void sge_silent_set(int i)
Enable/disable silence during spool operations. Silence means that no messages are printed to stdout.
int i - 0 or 1
MT-NOTE: sge_silent_set() is not MT safe
sge_spool_flags_t -- Context information for spooling functions
typedef enum { SPOOL_DEFAULT = 0x0000, SPOOL_HANDLE_AS_ZOMBIE = 0x0001, SPOOL_WITHIN_EXECD = 0x0002, SPOOL_IGNORE_TASK_INSTANCES = 0x0004, SPOOL_HANDLE_PARALLEL_TASKS = 0x0008, } sge_spool_flags_t;
These constants are necessary to provide spooling functions with context information where they are called and what they should do. It depends on these spooling functions, how these constants are interpreted. The documentation of these routines may give you a more detailed description than you may find here. SPOOL_DEFAULT - as it says the standard case SPOOL_HANDLE_AS_ZOMBIE - used mostly for jobs/array tasks which are already finished and stored in the list of zombie jobs. SPOOL_WITHIN_EXECD - Used for objects which are spooled within the execd. SPOOL_IGNORE_TASK_INSTANCES - Dont't handle array tasks. SPOOL_HANDLE_PARALLEL_TASKS - Spool pe tasks individually. SPOOL_ONLY_JATASK - spool only the ja_task, neither job nor pe_tasks SPOOL_ONLY_PETASK - spool only the pe_task, neither job nor ja_task
sge_spoolmsg_write() -- add a comment in a file
int sge_spoolmsg_write(FILE *file, char comment_char)
This function writes an additional comment into a file. First character in a comment line is 'comment_char'.
FILE *file - file descriptor char comment_char - first character in a comment line
-1 on error else 0
MT-NOTE: sge_spoolmsg_write() is not MT safe due to FPRINTF() macro
sge_status_end_turn() -- remove washing machine from display
void sge_status_end_turn(void)
Last turn of washing machine.
MT-NOTE: sge_status_end_turn() is not MT safe
sge_status_next_turn() -- show next turn
void sge_status_next_turn(void)
Show next turn of rotating washing machine.
MT-NOTE: sge_status_next_turn() is not MT safe
sge_status_set_type() -- set display mode
void sge_status_set_type(washing_machine_t type)
With 'STATUS_ROTATING_BAR' each call of sge_status_next_turn() will show a rotating bar. In 'STATUS_DOTS'-mode each call will show more dots in a line.
washing_machine_t type - display type STATUS_ROTATING_BAR STATUS_DOTS
MT-NOTE: sge_status_set_type() is not MT safe
sge_write_pid() -- Write pid into file
void sge_write_pid(const char *pid_log_file)
Write pid into file
const char *pid_log_file - filename
MT-NOTE: sge_write_pid() is MT safe
CLOSE() -- close() macro
#define CLOSE(argument) int close(int fd)
This CLOSE macro has to be used similar to the close function. It is not necessary to check the return value. In case of an error the macro will jump to a defined label. The label name is 'CLOSE_ERROR'.
int fd - file descriptor
Don't forget to define the 'CLOSE_ERROR'-label
FCLOSE() -- fclose() macro
#define FCLOSE(argument) int fclose(FILE *stream)
This FCLOSE macro has to be used similar to the fclose function. It is not necessary to check the return value. In case of an error the macro will jump to a defined label. The label name is 'FCLOSE_ERROR'.
FILE *stream - output stream
Don't forget to define the 'FCLOSE_ERROR'-label
FPRINTF() -- fprintf() macro
#define FPRINTF(arguments) void fprintf(FILE *stream, const char *format, ...)
This FPRINTF macro has to be used similar to the fprintf function. It is not necessary to check the return value. In case of an error the macro will jump to a defined label. The label name is 'FPRINTF_ERROR'.
FILE *stream - output stream const char *format - format string ...
Don't forget to define the 'FPRINTF_ERROR'-label
FPRINTF_ASSIGN() -- fprintf() macro with return value assignment
#define FPRINTF_ASSIGN(var, arguments) void fprintf(FILE *stream, const char *format, ...)
This FPRINTF macro has to be used similar to the fprintf function. It is not necessary to check the return value. In case of an error the macro will jump to a defined label. The label name is 'FPRINTF_ERROR'. This is a variarion of FPRINTF() that allows assigning the fprintf() return value to the variable passed as first makro argument.
FILE *stream - output stream const char *format - format string ...
Don't forget to define the 'FPRINTF_ERROR'-label
FSCANF() -- fscanf() macro
#define FSCANF(n, arguments) void fscanf(FILE *stream, const char *format, ...)
This FSCANF macro is used similarly to the fscanf function, except that the first argument is the number of items which must be read. It is not necessary to check the return value; In case too few items are read, the macro will jump to a defined label. The label name is 'FSCANF_ERROR'.
FILE *stream - output stream const char *format - format string ...
Don't forget to define the 'FSCANF_ERROR'-label
sge_peclose() -- pclose() call which is suitable for sge_peopen()
int sge_peclose(pid_t pid, FILE *fp_in, FILE *fp_out, FILE *fp_err, struct timeval *timeout)
???
pid_t pid - pid returned by peopen() FILE *fp_in FILE *fp_out FILE *fp_err struct timeval *timeout
int - exit code of command or -1 in case of errors
MT-NOTE: sge_peclose() is MT safe
sge_peopen_r() -- Advanced popen()
pid_t sge_peopen_r(const char *shell, int login_shell, const char *command, const char *user, char **env, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Advanced popen() with additional parameters: - free shell usage - login shell if wanted - user under which to start (for root only) - stdin and stderr file pointers - wait for exactly the process we started File descriptors have to be closed with sge_peclose(). This function is reentrant as long as env is not provided to this function. This means that the function can be used in multi thread processed as long as env is not used.
const char *shell - which shell to use int login_shell - make it a login shell? const char *command - name of the program const char *user - user under which to start (for root only) char **env - env variables to add to child FILE **fp_in - file input stream FILE **fp_out - file output stream FILE **fp_err - file error stream
pid_t - process id
MT-NOTE: sge_peopen_r() is MT safe
(MULTITHREADED ENVIRONMENT) THIS MIGHT CAUSE A DEADLOCK IN A MASTER THREAD.
sge_free() -- replacement for free
void sge_free(void *cp)
Replacement for free function. Accepts NULL pointers.
void *cp - pointer to a pointer of a memory block
MT-NOTE: sge_free() is MT safe
sge_getenv() -- get an environment variable
const char* sge_getenv(const char *env_str)
The function searches the environment list for a string that matches the string pointed to by 'env_str'.
const char *env_str - name of env. varibale
const char* - value
MT-NOTE: sge_getenv() is MT safe
sge_malloc() -- replacement for malloc()
void* sge_malloc(size_t size)
Allocates a memory block. Initilizes the block (0). Aborts in case of error.
size_t size - size in bytes
void* - pointer to memory block
MT-NOTE: sge_malloc() is MT safe
sge_maybe_set_dumpable() -- maybe allow core dumps after sge_setuid & al
void sge_maybe_set_dumpable(void gid)
Conditionally allows dumping core after calls to sge_setuid & al. The condition is that SGE_ENABLE_COREDUMP is set in the environment.
MT-NOTE: sge_maybe_set_dumpable() is not MT safe
sge_putenv() -- put an environment variable to environment
static int sge_putenv(const char *var)
Duplicates the given environment variable and calls the system call putenv.
const char *var - variable to put in the form <name>=<value>
static int - 1 on success, else 0
MT-NOTE: sge_putenv() is MT safe
sge_realloc() -- replacement for realloc
char* sge_realloc(char *ptr, int size, int abort)
Reallocates a memory block. Aborts in case of an error.
char *ptr - pointer to a memory block int size - new size int abort - do abort when realloc fails?
char* - pointer to the (new) memory block
MT-NOTE: sge_realloc() is MT safe
sge_setegid() -- set effective group id
int sge_setegid(gid_t gid)
Call setegid and maybe call prctl, or similar, afterwards. prctl is called under Linux to allow core dumps subsequently. That is only done if global sge_dumpable is non-zero.
gid_t gid - gid to set
Per setegid
MT-NOTE: MT safe as long as sge_dumpable is only set before threads are started.
sge_setenv() -- Change or add an environment variable
int sge_setenv(const char *name, const char *value)
Change or add an environment variable
const char *name - variable name const char *value - new value
int - error state 1 - success 0 - error
MT-NOTE: sge_setenv() is MT safe
sge_seteuid() -- set effective user id
int sge_seteuid(uid_t uid)
Call seteuid and maybe call prctl, or similar, afterwards. prctl is called under Linux to allow core dumps subsequently. That is only done if global sge_dumpable is non-zero.
uid_t uid - uid to set
Per seteuid
MT-NOTE: MT safe as long as sge_dumpable is only set before threads are started.
sge_setgid() -- set group id
int sge_setgid(gid_t gid)
Call setgid and maybe call prctl, or similar, afterwards. prctl is called under Linux to allow core dumps subsequently. That is only done if global sge_dumpable is non-zero.
gid_t gid - gid to set
Per setuid
MT-NOTE: MT safe as long as sge_dumpable is only set before threads are started.
sge_setuid() -- set user id
int sge_setuid(uid_t uid)
Call setuid and maybe call prctl, or similar, afterwards. prctl is called under Linux to allow core dumps subsequently. That is only done if global sge_dumpable is non-zero.
uid_t uid - uid to set
Per setuid
MT-NOTE: MT safe as long as sge_dumpable is only set before threads are started.
sge_unsetenv() -- unset environment variable
void sge_unsetenv(const char* varName)
Some architectures doesn't support unsetenv(), sge_unsetenv() is used to unset an environment variable.
const char* varName - name of envirionment variable
void - no return value
MT-NOTE: sge_unsetenv() is not MT safe
sge_basename() -- get basename for path
char* sge_basename(const char *name, int delim)
Determines the basename for a path like string - the last field of a string where fields are separated by a fixed one character delimiter.
const char *name - contains the input string (path) int delim - delimiter
char* - pointer to base of name after the last delimter NULL if "name" is NULL or zero length string or delimiter is the last character in "name"
sge_basename("/usr/local/bin/flex", '/'); returns "flex"
MT-NOTE: sge_basename() is MT safe
sge_compress_slashes() -- compresses sequences of slashes
void sge_compress_slashes(char *str)
Compresses sequences of slashes in str to one slash
char *str - string (e.g. path)
MT-NOTE: sge_compress_slashes() is MT safe
sge_delim_str() -- Trunc. a str according to a delimiter set
char* sge_delim_str(char *str, char **delim_pos, const char *delim)
Truncates a string according to a delimiter set. A copy of the string truncated according to the delimiter set will be returned. ATTENTION: The user is responsible for freeing the allocated memory outside this routine. If not enough space could be allocated, NULL is returned.
char *str - string to be truncated char **delim_pos - A placeholder for the delimiting position in str on exit. If set on entry the position of the delimiter in the input string 'str' is returned. If no delimiting character in string was found, the address of the closing '\0' in 'str' is returned. const char *delim - string containing delimiter characters
char* - Truncated copy of 'str' (Has to be freed by the caller!)
MT-NOTE: sge_delim_str() is MT safe
sge_dirname() -- Return first part of string up to deliminator
char* sge_dirname(const char *name, int delim)
The function will return a malloced string containing the first part of 'name' up to, but not including deliminator. NULL will be returned if 'name' is NULL or a zero length string or if 'delim' is the first character in 'name'
const char *name - string int delim - deliminator
char* - malloced string
This routine is called "dirname" in opposite to "basename" but is mostly used to strip off the domainname of a FQDN MT-NOTE: sge_dirname() is MT safe
sge_free_saved_vars() -- Free 'context' of sge_strtok_r()
void sge_free_saved_vars(struct saved_vars_s *context)
Free 'context' of sge_strtok_r()
struct saved_vars_s *context
MT-NOTE: sge_free_saved_vars() is MT safe
sge_is_expression() -- Test if string contains expressions & wildcard pattern
int sge_is_expression(const char *s)
Check whether string 's' contains a expressions & a wildcard pattern.
const char *s - string
int - result 0 - no wildcard pattern 1 - it is a wildcard pattern
MT-NOTE: sge_is_expression() is MT safe
sge_is_pattern() -- Test if string contains wildcard pattern
int sge_is_pattern(const char *s)
Check whether string 's' contains a wildcard pattern.
const char *s - string
int - result 0 - no wildcard pattern 1 - it is a wildcard pattern
MT-NOTE: sge_is_pattern() is MT safe
sge_jobname() -- get jobname of command line string
const char* sge_jobname(const char *name)
Determine the jobname of a command line. The following definition is used for the jobname: - take everything up to the first semicolon - take everything up to the first whitespace - take the basename
const char *name - contains the input string (command line)
const char* - pointer to the jobname NULL if name is NULL or only '\0'
Command line jobname ---------------------------------------------- "cd /home/me/5five; hostname" --> cd "/home/me/4Ujob" --> 4Ujob (invalid, will be denied) "cat /tmp/5five" --> cat "bla;blub" --> bla "a b" --> a
MT-NOTE: sge_jobname() is not MT safe
sge_patternnullcmp() -- like fnmatch
int sge_patternnullcmp(const char *str, const char *pattern)
Like fnmatch() apart from the handling of NULL strings. These are treated as being less than any not-NULL strings. Important for sorting lists where NULL strings can occur.
const char *str - string const char *pattern - pattern to match
int - result 0 - strings are the same or both NULL -1 - a < b or a is NULL 1 - a > b or b is NULL
MT-NOTE: fnmatch uses static variables, not MT safe
sge_replace_substring - replace sub strings in a string
const char *sge_replace_substring(const char *input, char *old, char *new)
Replaces all occurences of old with new. If old is part of the given string input, a new string is returned where the replacement is done.
const char *input - the input string const char *old - the string to replace const char *new - the replacement string
NULL, if the input string didn't contain the pattern, else a newly allocated string containing the input string with replacements.
MT-NOTE: sge_str_is_number() is MT safe It is the responsibility of the caller to free the returned string!
sge_str_is_number() -- check if a string represents a number
bool sge_str_is_number(const char *string)
This function returns true if the given string represents a floating point number.
const char *string - string to parse
bool - result true - string represents a number false - string is not a number
MT-NOTE: sge_str_is_number() is MT safe
sge_stracasecmp() -- Find string in string array
char** sge_stracasecmp(const char *cp, char **cpp)
Compare string with string field and return the pointer to the matched character pointer. Compare case sensitive.
const char *cp - string char **cpp - pointer to array of strings
char** - NULL or pointer a string
MT-NOTE: sge_stracasecmp() is MT safe
sge_stradup() -- Duplicate array of strings
char** sge_stradup(char **cpp, int n)
Copy list of character pointers including the strings these pointers refer to. If 'n' is 0 strings are '\0'-delimited, if 'n' is not 0 we use n as length of the strings.
char **cpp - pointer to array of strings int n - '\0' terminated?
char** - copy of 'cpp'
MT-NOTE: sge_stradup() is MT safe
sge_strafree() -- Free list of character pointers
void sge_strafree(char **cpp)
Free list of character pointers
char ***cpp - Pointer to array of string pointers
MT-NOTE: sge_strafree() is MT safe
sge_stramemncpy() -- Find string in string array
char** sge_stramemncpy(const char *cp, char **cpp, int n)
Compare string with string field and return the pointer to the matched character pointer. Compare exactly n chars case insensitive.
const char *cp - string to be found char **cpp - pointer to array of strings int n - number of chars NOTES: MT-NOTE: sge_stramemncpy() is MT safe
char** - NULL or pointer a string
MT-NOTE: sge_stramemncpy() is MT safe
sge_strdup() -- Replacement for strdup()
char* sge_strdup(char *old, const char *s)
Duplicate string 's'. "Use" 'old' buffer.
char *old - buffer (will be freed) const char *s - string
char* - malloced string
MT-NOTE: sge_strdup() is MT safe
sge_strerror() -- replacement for strerror
const char* sge_strerror(int errnum)
Returns a string describing an error condition set by system calls (errno). Wrapper arround strerror. Access to strerrror is serialized by the use of a mutex variable to make strerror thread safe.
int errnum - the errno to explain dstring *buffer - buffer into which the error message is written
const char* - pointer to a string explaining errnum
MT-NOTE: sge_strerror() is MT safe
sge_strip_blanks() -- Strip blanks from string
void sge_strip_blanks(char *str)
Strip all blanks contained in a string. The string is used both as source and drain for the necessary copy operations. The string is '\0' terminated afterwards.
char *str - pointer to string to be condensed
MT-NOTE: sge_strip_blanks() is MT safe
sge_strip_quotes() -- Strip quotes from string
void sge_strip_quotes(char **pstr)
Strip quotes from "pstr".
char **pstr - string to be modified
MT-NOTE: sge_strip_quotes() is MT safe
sge_strip_slash_at_eol() -- truncate slash at EOL
void sge_strip_slash_at_eol(char *str)
Truncate slash from the end of the string
char *str - string to be modified
void - NONE
MT-NOTE: sge_strip_slash_at_eol() is MT safe
sge_strip_white_space_at_eol() -- truncate white space at EOL
void sge_strip_white_space_at_eol(char *str)
Truncate white space from the end of the string
char *str - string to be modified
void - NONE
MT-NOTE: sge_strip_white_space_at_eol() is MT safe
sge_strisint() -- Is string a integer value in characters?
int sge_strisint(const char *str)
May we convert 'str' to int?
const char *str - string
int - result 0 - It is no integer 1 - It is a integer
MT-NOTE: sge_strisint() is MT safe
sge_strlcat() -- sge strlcat implementation
size_t sge_strlcat(char *dst, const char *src, size_t dstsize)
appends characters from from "src" to "dst" and terminates the dst string with '\0' Returns the size required for successfully completing the operation.
char *dst - destination const char *src - source string (must be '\0' terminated) size_t dstsize - size of destination string
size_t - min{dstsize,strlen(dst)}+strlen(src) this is the size required for successfully completing the strcat.
MT-NOTE: sge_strlcat() is MT safe
sge_strlcpy() -- sge strlcpy implementation
size_t sge_strlcpy(char *dst, const char *src, size_t dstsize)
copies "dstsize"-1 characters from from "src" to "dst" and terminates the src string with '\0'- Returns the size of the "src" string.
char *dst - destination const char *src - source string (must be '\0' terminated) size_t dstsize - size of destination string
size_t - strlen of src, not dst !!!
MT-NOTE: sge_strlcpy() is MT safe
sge_strlen() -- replacement for strlen()
int sge_strlen(const char *str)
replacement for strlen
const char *str - NULL or pointer to string
int - length of string or 0 if NULL pointer
MT-NOTE: sge_strlen() is MT safe
sge_strnullcasecmp() -- Like strcasecmp() but honours NULL ptrs.
int sge_strnullcasecmp(const char *a, const char *b)
Like strcasecmp() apart from the handling of NULL strings. These are treated as being less than any not-NULL strings. Important for sorting lists where NULL strings can occur.
const char *a - 1st string const char *b - 2nd string
int - result 0 - strings are the same minus case or both NULL -1 - a < b or a is NULL 1 - a > b or b is NULL
MT-NOTE: sge_strnullcasecmp() is MT safe
sge_strnullcmp() -- Like strcmp() but honours NULL ptrs.
int sge_strnullcmp(const char *a, const char *b)
Like strcmp() apart from the handling of NULL strings. These are treated as being less than any not-NULL strings. Important for sorting lists where NULL strings can occur.
const char *a - 1st string const char *b - 2nd string
int - result 0 - strings are the same or both NULL -1 - a < b or a is NULL 1 - a > b or b is NULL
MT-NOTE: sge_strnullcmp() is MT safe
sge_strtok() -- Replacement for strtok()
char* sge_strtok(const char *str, const char *delimiter)
Replacement for strtok(). If no delimiter is given isspace() is used.
const char *str - string which should be tokenized const char *delimiter - delimiter string
char* - first/next token of str.
MT-NOTE: sge_strtok() is not MT safe, use sge_strtok_r() instead
sge_strtok_r() -- Reentrant version of strtok()
char* sge_strtok_r(const char *str, const char *delimiter, struct saved_vars_s **context)
Reentrant version of sge_strtok. When 'str' is not NULL, '*context' has to be NULL. If 'str' is NULL, '*context' must not be NULL. The caller is responsible for freeing '*context' with sge_free_saved_vars(). If no delimiter is given, isspace() is used.
const char *str - str which should be tokenized const char *delimiter - delimiter string struct saved_vars_s **context - context
char* - first/next token
MT-NOTE: sge_strtok_r() is MT safe
sge_strtoupper() -- Convert the first n to upper case
void sge_strtoupper(char *buffer, int max_len)
Convert the first 'max_len' characters to upper case.
char *buffer - string int max_len - number of chars
MT-NOTE: sge_strtoupper() is MT safe
str_from_str() -- Extract valid qstat options/paramers from qstat profile.
char **str_from_str(const char *source_str, const char *delim);
Parse string 'source_str' based on delimeter(s) 'delim' and store resulting tokens in string array 'ret'. Supports comment lines.
const char *source_str - File content of qstat profile as plain string. const char *delim - Sequence of characters used to identify tokens and parameters.
char** - String array containing tokens found based on 'delim'.
It is the caller's responsibilty to free dynamic memory allocated in this routine. MT-NOTE: stra_from_str() is MT safe.
sge_thread_has_shutdown_started() -- shutdown in progress?
bool sge_thread_has_shutdown_started(void)
Service function which can be used to check if the executing component is already shutting down.
void - NONE
bool - is in progress? true - yes false - no
MT-NOTE: sge_thread_has_shutdown_started() is MT safe
sge_thread_notify_all_waiting() -- notify waiting thread
void sge_thread_notify_all_waiting(void)
After the main thread has initialized all needed components and threads it waits for a certain condition to be signaled (sge_thread_wait_for_signal). This signal will start the shutdown process of the master. This function triggers this signal.
void - NONE
void - NONE
MT-NOTE: sge_thread_notify_all_waiting() is MT safe
sge_thread_wait_for_signal() -- block current thread till shutdown
void sge_thread_wait_for_signal(void)
A call of this function will block the executing thread until the shutdown of the process is triggered via sge_thread_notify_all_waiting()
void - NONE
void - NONE
MT-NOTE: sge_thread_wait_for_signal() is not MT safe
append_time() -- Convert time value into string
const char* append_time(time_t i, dstring *buffer)
Convert time value into string
time_t i - time value dstring *buffer - dstring bool is_xml - write in XML dateTime format?
const char* - time string (current time if 'i' was 0) dstring *buffer - buffer provided by caller
MT-NOTE: append_time() is MT safe if localtime_r() can be used SHOULD BE REPLACED BY: sge_dstring_append_time()
duration_add_offset() -- add function for time add
u_long32 duration_add_offset(u_long32 duration, u_long32 offset)
add function to catch ulong overflow. Returns max ulong value if necessary
u_long32 duration - duration in seconds u_long32 offset - offset in seconds
u_long32 - value < U_LONG32_MAX
MT-NOTE: duration_add_offset() is not MT safe
sge_at_time() -- ???
const char* sge_at_time(time_t i, dstring *buffer)
???
time_t i - 0 or time value dstring *buffer - buffer provided by caller
const char* - time string (current time if 'i' was 0)
MT-NOTE: sge_at_time() is MT safe if localtime_r() can be used
sge_ctime() -- Convert time value into string
const char* sge_ctime(time_t i, dstring *buffer)
Convert time value into string
time_t i - 0 or time value
const char* - time string (current time if 'i' was 0) dstring *buffer - buffer provided by caller
MT-NOTE: sge_at_time() is MT safe if localtime_r() can be used
sge_ctime32() -- Convert time value into string (64 bit time_t)
const char* sge_ctime32(u_long32 *i, dstring *buffer)
Convert time value into string. This function is needed for systems with a 64 bit time_t because the ctime function would otherwise try to interpret the u_long32 value as a 64 bit value => $&&%$?$%!
u_long32 *i - 0 or time value dstring *buffer - buffer provided by caller
const char* - time string (current time if 'i' was 0)
MT-NOTE: if ctime_r() is not available sge_ctime32() is not MT safe
sge_get_gmt() -- Return current time
u_long32 sge_get_gmt()
Return current time
MT-NOTE: sge_get_gmt() is MT safe (except for WIN32NATIVE)
u_long32 - 32 bit time value
sge_stopwatch_log() -- ???
void sge_stopwatch_log(int i, const char *str)
???
int i - ??? const char *str - ???
MT-NOTE: sge_stopwatch_log() is not MT safe due to access to global variables
sge_stopwatch_start() -- ???
void sge_stopwatch_start(int i)
???
int i - ???
MT-NOTE: sge_stopwatch_start() is not MT safe due to access to global variables
sge_usleep() -- Mimics a non-iterruptable usleep()
void sge_usleep(int sleep_time)
Mimics a non-iterruptable usleep() to the caller.
int sleep_time - requested sleep time in microseconds
n/a
None.
sge_tq_create() -- Creates a task queue
bool sge_tq_create(sge_tq_queue_t **queue)
This function creates a task queue.
sge_tq_queue_t **queue - task queue
bool - error state true - success false - error
MT-NOTE: sge_tq_create() is MT safe
sge_tq_destroy() -- destroys a queue.
bool sge_tq_destroy(sge_tq_queue_t **queue)
This function destroys a queue. The queue must be empty otherwise this would produce a memory leak.
sge_tq_queue_t **queue - task queue
bool - error state true - success false - error
MT-NOTE: sge_tq_destroy() is MT safe
sge_tq_get_task_count() -- Returns the number of tasks in queue
u_long32 sge_tq_get_task_count(sge_tq_queue_t *queue)
This function returns the number of tasks in 'queue'
sge_tq_queue_t *queue - task queue
u_long32 - number of tasks
MT-NOTE: sge_tq_get_task_count() is MT safe
sge_tq_get_waiting_count() -- Returns number of waiting threads
u_long32 sge_tq_get_waiting_count(sge_tq_queue_t *queue)
This function returns the number of waiting threads. If this number is bigger than 0 than this indicates that threads are waiting in the function sge_tq_wait_for_task().
sge_tq_queue_t *queue - task queue
u_long32 - number of threads waiting
MT-NOTE: sge_tq_get_waiting_count() is MT safe
sge_tq_store_notify() -- Appends a new task at the end of queue
bool sge_tq_store_notify(sge_tq_queue_t *queue, sge_tq_type_t type, void *data)
This function creates a new task using 'type' and 'data'. The new task will then be appended to 'queue'. If there are threads waiting in sge_tq_wait_for_task() then one of those waiting threads will be triggered so that it will wake up. If there are multiple threads waiting then it might happen that always the same thread wakes up to catch the task (starvation).
sge_tq_queue_t *queue - task queue sge_tq_type_t type - task type void *data - task data
bool - error state true - success false - error
MT-NOTE: sge_tq_store_notify() is MT safe
sge_tq_task_compare_type() -- compare two tasks
static int sge_tq_task_compare_type(const void *data1, const void *data2)
This function compares two tasks and returns if the first ('data1') is smaller or bigger that the second ('data2'). It is equal if the type field of the elements are equal. If the type field in 'data1' is SGE_TQ_UNKNOWN then the function will will always return 0 to indicate that independent of the type field inf 'data2' all tasks are identified as equal. This makes it possible to use this function as a search function where SGE_TQ_UNKNOWN matches any object in a list like a wild card '*'.
const void *data1 - key or task object const void *data2 - task
static int - compare result -1, 1 or 0
MT-NOTE: sge_tq_task_compare_type() is MT safe
sge_tq_task_create() -- creates a task element
static bool sge_tq_task_create(sge_tq_task_t **task, sge_tq_type_t type, void *data)
Creates a task element that can be added to a queue. Each task has a type and a data pointer. The type makes it possible to identify the type of the data pointer.
sge_tq_task_t **task - new task element sge_tq_type_t type - type id void *data - data pointer
static bool - error state true - success false - error
MT-NOTE: sge_tq_task_create() is MT safe
sge_tq_task_destroy() -- Destroy a task
static bool sge_tq_task_destroy(sge_tq_task_t **task)
Destroy a task.
sge_tq_task_t **task - task to be destroyed
static bool - error state true - success false - error
MT-NOTE: sge_tq_task_destroy() is MT safe
sge_tq_wait_for_task() -- Waits for a task
bool sge_tq_wait_for_task(sge_tq_queue_t *queue, int seconds, sge_tq_type_t type, void **data);
This function tries to get a task of 'type'. If there is one available then the data pointer will be returned in 'data'. If there is none available the this function will sleep a number of 'seconds' before it checks again if there is a task available. The sleep time might be interrupted by another thread that adds a task to the queue via sge_tq_store_notify() or by a thread that called sge_tq_wakeup_waiting(). The function returns either if a task of the correct type is available of if sge_thread_has_shutdown_started() returns true to indicate that the shutdown of the thread/process has been triggered. In that case the function might return with NULL in *data.
sge_tq_queue_t *queue - task queue int seconds - max number of seconds to sleep sge_tq_type_t type - type of the task that should be returned void **data - NULL in case of thread/process shutdown or the data pointer of the task
bool - error state true - success false - error
MT-NOTE: sge_tq_wait_for_task() is MT safe
sge_tq_wakeup_waiting() -- wake up all waitng threads
bool sge_tq_wakeup_waiting(sge_tq_queue_t *queue)
This function wakes up all waiting threads that are blocking in sge_tq_wait_for_task().
sge_tq_queue_t *queue - task queue
bool - error state true - success false - error
MT-NOTE: sge_tq_wakeup_waiting() is MT safe
get_admin_user() -- Get user and group id of admin user.
static int get_admin_user(uid_t* theUID, gid_t* theGID)
Get user and group id of admin user. 'theUID' and 'theGID' will contain the user and group id respectively, upon successful completion. If the admin user has not been set by a call to 'set_admin_user()' previously, an error is returned. In case of an error, the locations pointed to by 'theUID' and 'theGID' remain unchanged.
uid_t* theUID - pointer to user id storage. gid_t* theGID - pointer to group id storage.
int - Returns ESRCH, if no admin user has been initialized.
uid_t uid; gid_t gid; if (get_admin_user(&uid, &gid) == ESRCH) { printf("error: no admin user\n"); } else { printf("uid = %d, gid =%d\n", (int)uid, (int)gid); }
MT-NOTE: get_admin_user() is MT safe.
get_admin_user_name() -- Returns the admin user name
const char* get_admin_user_name(void)
Returns the admin user name.
void - None
const char* - Admin user name
MT-NOTE: get_admin_user_name() is MT safe
get_file_line_size() - helper function that counts the characters in current line of file
int get_file_line_size(FILE* fp)
This helper function counts the characters in current line of file, it restores file position pointer to the position that was before entering function. Function can be called on any opened file with read permissions.
FILE* fp - handler of the file in which the characters in current line are counted
int - returns number of characters in current line of file, if number of characters is bigger than MAX_LENGTH_LINE, it returns MAX_LINE_LENGTH+1 value
MT-NOTE: get_file_line_size() is not MT safe
get_group_buffer_size() -- get the buffer size required for getgr*_r
int get_group_buffer_size(void)
Returns the buffer size required for functions like getgrnam_r. It can either be retrieved via sysconf, or a big (20k) buffer size is taken.
int - buffer size in bytes
MT-NOTE: get_group_buffer_size() is MT safe
get_pw_buffer_size() -- get the buffer size required for getpw*_r
int get_pw_buffer_size(void)
Returns the buffer size required for functions like getpwnam_r. It can either be retrieved via sysconf, or a big (20k) buffer size is taken.
int - buffer size in bytes
MT-NOTE: get_pw_buffer_size() is MT safe
password_get_size() - count number of lines in sgepasswd file
static int password_get_size(const char *filename)
This function counts the lines in the sgepasswd file, it also checks that each line is not too long. If any line has more than MAX_LINE_LENGTH characters the function returns error state -1
const char *filename - name of the file on which the function is run
int - returns number of lines in sgepasswd file if function has run successfully -1 - if there is a line in a file that is longer than MAX_LINE_LENGTH
MT-NOTE: password_get_size() is not MT safe
password_read_file() - read in sgepasswd file
int password_read_file(char **users[], char**encryped_pwds[], const char *filename)
This function reads usernames and encrypted passwords from sgepasswd file and saves them in arrays that are part if function output, if the file could not be opened for reading or the file contains corrupted line, (too long line, line that doesn't contain username and password), the proper error state is returned
const char* filename - name with path of the sgepasswd file that is going to be read
char** users[] - array of strings to which are written the usernames that are read from sgepasswd, if sgepasswd could not be opened there are reserved 2 entries with NULL values, if the sgepasswd file is corrupted, no entries are reserved char** encrypted_pwds[] - array of strings to which are written encrypted passwords that are read from sgepasswd if sgepasswd could not be opened there are reserved 2 entries with NULL values, if the sgepasswd file is corrupted, no entries are reserved
int - error state 0 - OK, no errors 1 - sgepasswd could not be opened for reading 2 - sgepasswd file is corrupted
MT-NOTE: password_read_file() is not MT safe
set_admin_user() -- Set user and group id of admin user.
static void set_admin_user(uid_t theUID, gid_t theGID)
Set user and group id of admin user.
uid_t theUID - user id of admin user gid_t theGID - group id of admin user
static void - none
MT-NOTE: set_admin_user() is MT safe.
sge_add_group() -- Add a gid to the list of additional group ids
int sge_add_group(gid_t add_grp_id, char *err_str)
Add a gid to the list of additional group ids. If 'add_grp_id' is 0 don't add value to group id list (but return successfully). If an error occurs, a descriptive string will be written to err_str.
gid_t add_grp_id - new gid char *err_str - if points to a valid string buffer error descriptions will be written here size_t lstr - size of err_str bool skip_silently - skip silently if setting the group is skipped because this would exceed the NGROUPS_MAX limit.
MT-NOTE: sge_add_group() is MT safe
int - error state 0 - Success -1 - Error
sge_getgrgid_r() -- Return group information for a given group ID.
struct group* sge_getgrgid_r(gid_t gid, struct group *pg, char *buffer, size_t bufsize, int retries)
Search account database for a group. This function is just a wrapper for 'getgrgid_r()', taking into account some additional possible errors. For a detailed description see 'getgrgid_r()' man page.
gid_t gid - group ID struct group *pg - points to structure which will be updated upon success char *buffer - points to memory referenced by 'pg' size_t buflen - size of 'buffer' in bytes int retries - number of retries to connect to NIS
struct group* - Pointer to entry matching group information upon success, NULL otherwise.
MT-NOTE: sge_getpwnam_r() is MT safe.
sge_getpwnam_r() -- Return password file entry for a given user name.
struct passwd* sge_getpwnam_r(const char*, struct passwd*, char*, int)
Search user database for a name. This function is just a wrapper for 'getpwnam_r()', taking into account some additional possible errors. For a detailed description see 'getpwnam_r()' man page.
const char *name - points to user name struct passwd *pw - points to structure which will be updated upon success char *buffer - points to memory referenced by 'pw' size_t buflen - size of 'buffer' in bytes
struct passwd* - Pointer to entry matching user name upon success, NULL otherwise.
MT-NOTE: sge_getpwnam_r() is MT safe.
sge_gid2group() -- Resolves gid to group name.
int sge_gid2group(gid_t gid, char *dst, size_t sz, int retries)
Resolves gid to group name. if 'dst' is NULL the function checks only if the gid is resolvable.
uid_t gid - group id char *dst - buffer for the group name size_t sz - buffer size int retries - number of retries
MT-NOTE: sge_gid2group() is MT safe.
int - error state 0 - OK 1 - Error
sge_group2gid() -- Resolve a group name to its gid
int sge_group2gid(const char *gname, gid_t *gidp, int retries)
Resolves a groupname ('gname') to its gid (stored in 'gidp'). 'retries' defines the number of (e.g. NIS/DNS) retries. If 'gidp' is NULL the group name is resolved without saving it.
const char *gname - group name gid_t *gidp - gid pointer int retries - number of retries
MT-NOTE: sge_group2gid() is MT safe.
int - exit state 0 - OK 1 - Error
sge_has_admin_user() -- is there a admin user configured and set
bool sge_has_admin_user(void)
Returns if there is a admin user setting configured and set.
void - None
bool - result true - there is a setting
MT-NOTE: sge_has_admin_user() is MT safe
sge_is_admin_user() -- Check if user is SGE admin user
bool sge_is_admin_user(const char *username)
Checks if the given user is the SGE admin user.
const char *username - given user name
bool - true if the given user is the SGE admin user false if not.
MT-NOTE: sge_is_admin_user() is MT safe.
sge_is_start_user_superuser() -- return true/false is current real user is superuser (root/Administrator)
bool sge_is_start_user_superuser(void)
Check the real user id to determine if it is the superuser. If so, return true, else return false. This function relies on getuid == 0 for UNIX. On INTERIX, this function determines if the user is the built-in local admin user or the domain administrator. Other members of the Administrators group do not have the permission to "su" without password!
true - root was start user false - otherwise
MT-NOTE: sge_is_start_user_superuser() is MT safe.
sge_is_user_superuser() -- check if provided user is the superuser
bool sge_is_user_superuser(const char *name);
Checks platform independently if the provided user is the superuser.
const char *name - name of the user to check
bool - true if it is the superuser, false if not.
MT-NOTE: sge_is_user_superuser() is MT safe.
sge_run_as_user() -- Set euid to uid
int sge_run_as_user(void)
Set euid to uid
int - error state 0 - OK -1 - setegid()/seteuid() failed
MT-NOTE: sge_run_as_user() is MT safe
sge_set_admin_username() -- Set SGE/EE admin user
int sge_set_admin_username(const char *user, char *err_str, size_t lstr)
Set SGE/EE admin user. If 'user' is "none" then use the current uid/gid. Ignore if current user is not root.
const char *user - admin user name char *err_str - error message size_t lstr - size of err_str
int - error state 0 - OK -1 - Username does not exist -2 - Admin user was already set
MT-NOTE: sge_set_admin_username() is MT safe.
sge_set_uid_gid_addgrp() -- Set uid and gid of calling process
int sge_set_uid_gid_addgrp(const char *user, const char *intermediate_user, int min_gid, int min_uid, int add_grp, char *err_str, int use_qsub_gid, gid_t qsub_gid)
Set uid and gid of calling process. This can be done only by root.
const char *user - ??? const char *intermediate_user - ??? int min_gid - ??? int min_uid - ??? int add_grp - ??? char *err_str - ??? int use_qsub_gid - ??? gid_t qsub_gid - ??? bool skip_silently - skip silently when add_grp could not be added due to NGROUP_MAX limit
MT-NOTE: sge_set_uid_gid_addgrp() is MT safe TODO: This function needs to be rewritten from scratch! It calls 'initgroups()' which is not part of POSIX. The call to 'initgroups()' shall be replaced by a combination of 'getgroups()/getegid()/setgid()'. This function is used by 'shepherd' only anyway. Hence it shall be considered to move it from 'libuti' to 'shepherd'.
int - error state 0 - OK -1 - we can't switch to user since we are not root 1 - we can't switch to user or we can't set add_grp 2 - can't read sgepasswd file 3 - no password entry in sgepasswd file 4 - switch to user failed, likely wrong password for this user
sge_switch2admin_user() -- Set euid/egid to admin uid/gid
int sge_switch2admin_user(void)
Set euid/egid to admin uid/gid. Silently ignore if our uid is not root. Do nothing if out euid/egid is already the admin uid/gid. If the admin user was not set with sge_set_admin_username() the function will not return.
int - error state 0 - OK -1 - setegid()/seteuid() fails
MT-NOTE: sge_switch2admin_user() is MT safe.
sge_switch2start_user() -- set euid/egid to start uid/gid
int sge_switch2start_user(void)
Set euid/egid to the uid/gid of that user which started the application which calls this function. If our euid/egid is already the start uid/gid don't do anything. If the admin user was not set with sge_set_admin_username() the function will not return.
int - error state 0 - OK -1 - setegid()/seteuid() fails
MT-NOTE: sge_switch2start_user() is MT safe.
sge_uid2user() -- Resolves uid to user name.
int sge_uid2user(uid_t uid, char *dst, size_t sz, int retries)
Resolves uid to user name. if 'dst' is NULL the function checks only if the uid is resolvable.
uid_t uid - user id char *dst - buffer for the username size_t sz - buffer size int retries - number of retries
MT-NOTE: sge_uid2user() is MT safe.
int - error state 0 - OK 1 - Error
sge_user2uid() -- resolves user name to uid and gid
int sge_user2uid(const char *user, uid_t *puid, gid_t *pgid, int retries)
Resolves a username ('user') to it's uid (stored in 'puid') and it's primary gid (stored in 'pgid'). 'retries' defines the number of (e.g. NIS/DNS) retries. If 'puid' is NULL the user name is resolved without saving it.
const char *user - username uid_t *puid - uid pointer gid_t *pgid - gid pointer int retries - number of retries
MT-NOTE: sge_user2uid() is MT safe.
int - exit state 0 - OK 1 - Error
uidgid_mt_init() -- Initialize user and group oriented functions for multi threading use.
void uidgid_mt_init(void)
Set up user and group oriented functions. This function must be called at least once before any of the user and group functions can be used. This function is idempotent, i.e. it is safe to call it multiple times. Thread local storage for the user and group state information is reserved.
void - NONE
void - NONE
MT-NOTE: uidgid_mt_init() is MT safe
uidgid_once_init() -- One-time user and group function initialization.
static uidgid_once_init(void)
Create access key for thread local storage. Register cleanup function. This function must be called exactly once.
void - none
void - none
MT-NOTE: uidgid_once_init() is MT safe.
uidgid_state_destroy() -- Free thread local storage
static void uidgid_state_destroy(void* theState)
Free thread local storage.
void* theState - Pointer to memory which should be freed.
static void - none
MT-NOTE: uidgid_state_destroy() is MT safe.
uidgid_state_set_*() - read access to lib/uti/sge_uidgid.c global variables
Provides access to per thread global variable.
uidgid_state_init() -- Initialize user and group function state.
static void cull_state_init(struct cull_state_t* theState)
Initialize user and group function state.
struct cull_state_t* theState - Pointer to user and group state structure.
static void - none
MT-NOTE: cull_state_init() is MT safe.
uidgid_state_set_*() - write access to lib/uti/sge_uidgid.c global variables
Provides access to per thread global variable.
sge_chdir() -- Replacement for chdir()
int sge_chdir(const char *dir)
Change working directory
const char *dir - pathname
int - error state 0 - success != 0 - error
Might be used in shepherd because it does not use CRITICAL/ERROR. TODO: pass a dstring for the return of error messages.
sge_chdir_exit() -- Replacement for chdir()
int sge_chdir_exit(const char *path, int exit_on_error)
Change working directory
const char *path - pathname int exit_on_error - exit in case of errors
int - error state 0 - OK -1 - ERROR ('exit_on_error'==1 the function may not return)
sge_exit() -- Wrapped exit Function
void sge_exit(int i)
Calls 'exit_func' if installed. Stops monitoring with DCLOSE
sge_gdi_ctx_class_t **ref_ctx - address of the context, the context is freed in exit_func int i - exit state
sge_is_directory() -- Does 'name' exist and is it a directory?
int sge_is_directory(const char *name)
Does 'name' exist and is it a directory?
const char *name - directory name
int - error state 0 - No 1 - Yes
sge_is_file() -- Does 'name' exist and is it a file?
int sge_is_file(const char *name)
Does 'name' exist and is it a file?
const char *name - filename
int - error state 0 - No 1 - Yes
sge_mkdir() -- Create a directory (and necessary parents)
int sge_mkdir(const char *path, int fmode, bool exit_on_error, bool may_not_exist)
Create a directory
const char *path - path int fmode - file mode bool exit_on_error - as it says bool may_not_exist - if true an error is returned if the last component of the path exists
int - error state 0 - OK -1 - Error (The function may never return)
sge_rmdir() -- Recursive rmdir
int sge_rmdir(const char *cp, dstring *error)
Remove a directory tree. In case of errors a message may be found in 'error' afterwards.
const char *cp - path dstring *error - destination for error message if non-NULL
int - error state 0 - OK -1 - Error
sge_sleep() -- sleep for x microseconds
void sge_sleep(int sec, int usec)
Delays the calling application for 'sec' seconds and 'usec' microseconds
int sec - seconds int usec - microseconds
sge_unlink() -- delete a name and possibly the file it refers to
bool sge_unlink(const char *prefix, const char *suffix)
Replacement for unlink(). 'prefix' and 'suffix' will be combined to a filename. This file will be deleted. 'prefix' may be NULL.
const char *prefix - pathname or NULL const char *suffix - filename
int - error state true - OK false - Error
--Bitfield
: uti bitfield --Bitfield--Hashtable
: uti htable --Hashtable--Profiling
: uti profiling --Profiling--SimpleList
: uti sl --SimpleList-Bitfield_Typedefs
: uti bitfield -Bitfield_Typedefs-Compare-Functions
: uti htable -Compare-Functions-Dup-Functions
: uti htable -Dup-Functions-Hash-Functions
: uti htable -Hash-Functions-Profiling-Defines
: uti profiling -Profiling-Definesappend_time
: uti time append_timebinding_explicit_has_correct_syntax
: sge_binding_hlp binding_explicit_has_correct_syntaxbinding_get_topology_for_job
: uti binding_hlp binding_get_topology_for_jobbinding_linear_parse_number
: sge_binding_hlp binding_linear_parse_numberbinding_parse_type
: sge_binding_hlp binding_parse_typebinding_striding_parse_first_core
: sge_binding_hlp binding_striding_parse_first_corebinding_striding_parse_first_socket
: sge_binding_hlp binding_striding_parse_first_socketbinding_striding_parse_number
: sge_binding_hlp binding_striding_parse_numberbinding_striding_parse_step_size
: sge_binding_hlp binding_striding_parse_step_sizebindingLinearParseCoreOffset
: sge_binding_hlp bindingLinearParseCoreOffsetbindingLinearParseSocketOffset
: sge_binding_hlp bindingLinearParseSocketOffsetBIT_MANIPULATION_MAKROS
: uti bitfield BIT_MANIPULATION_MAKROSbootstrap_mt_init
: uti bootstrap bootstrap_mt_initbootstrap_state_destroy
: uti bootstrap bootstrap_state_destroybootstrap_thread_local_destroy
: uti bootstrap bootstrap_thread_local_destroybootstrap_thread_local_init
: uti bootstrap bootstrap_thread_local_initbootstrap_thread_local_once_init
: uti bootstrap bootstrap_thread_local_once_initcheck_explicit_binding_string
: sge_binding_hlp check_explicit_binding_stringCLOSE
: uti stdio CLOSEconvert_arg_list_to_vector
: sge_parse_args convert_arg_list_to_vectorCRITICAL
: uti log CRITICALDEBUG
: uti log DEBUGDSTRING_INIT
: uti dstring DSTRING_INITduration_add_offset
: uti time duration_add_offsetERROR
: uti log ERRORext_edt_output
: uti monitor ext_edt_outputext_gdi_output
: uti monitor ext_gdi_outputext_lis_output
: uti monitor ext_lis_outputext_sch_output
: uti monitor ext_sch_outputext_tet_output
: uti monitor ext_tet_outputFCLOSE
: uti stdio FCLOSEfd_compare
: uti os fd_comparefile_exists
: uti file_existsfork_no_pty
: uti pty fork_no_ptyfork_pty
: uti pty fork_ptyFPRINTF
: uti stdio FPRINTFFPRINTF_ASSIGN
: uti stdio FPRINTF_ASSIGNFSCANF
: uti stdio FSCANFget_admin_user
: uti uidgid get_admin_userget_admin_user_name
: uti uidgid get_admin_user_nameget_cgroup_double_value
: cgroup get_cgroup_double_valueget_explicit_number
: sge_binding_hlp get_explicit_numberget_file_line_size
: uti uidgid get_file_line_sizeget_group_buffer_size
: uti uidgid get_group_buffer_sizeget_pw_buffer_size
: uti uidgid get_pw_buffer_sizeget_thread_info
: uti profiling get_thread_infoid_callback_impl
: libs lck id_callback_implINFO
: uti log INFOinit_array
: uti profiling init_arrayinit_thread_info
: uti profiling init_thread_infoIntroduction
: sge_lock IntroductionIntroduction
: rmon Introductionis_digit
: sge_binding_hlp is_digitis_hgroup_name
: uti hostname is_hgroup_namelock_once_init
: libs lck lock_once_initlog_buffer_destroy
: uti log log_buffer_destroylog_buffer_getspecific
: uti log log_buffer_getspecificlog_buffer_once_init
: uti log log_buffer_once_initlog_context_destroy
: uti log log_context_destroylog_context_getspecific
: uti log log_context_getspecificlog_context_once_init
: uti log log_context_once_initlog_get_log_buffer
: uti log log_get_log_bufferlog_get_log_context
: uti log log_get_log_contextlog_set_log_context
: uti log log_set_log_contextlog_state_get_log_as_admin_user
: uti log log_state_get_log_as_admin_userlog_state_get_log_file
: uti sge_log log_state_get_log_filelog_state_get_log_gui
: uti log log_state_get_log_guilog_state_get_log_level
: uti log log_state_get_log_levellog_state_get_log_verbose
: uti log log_state_get_log_verboselog_state_set_log_as_admin_user
: uti log log_state_set_log_as_admin_userlog_state_set_log_gui
: uti log log_state_set_log_guilog_state_set_log_level
: uti log log_state_set_log_levellog_state_set_log_verbose
: uti log log_state_set_log_verbosemain
: test_sge_lock_main mainmwrite
: rmon_macros mwriteNOTICE
: uti log NOTICEparse_binding_parameter_string
: sge_binding_hlp parse_binding_parameter_stringparse_quoted_command_line
: sge_parse_args parse_quoted_command_lineparse_script_params
: uti parse_script_paramspassword_get_size
: uti uidgid password_get_sizepassword_read_file
: uti uidgid password_read_filepath_mt_init
: uti path path_mt_initpath_once_init
: uti path path_once_initpath_state_destroy
: uti path path_state_destroypath_state_get_
: uti path path_state_get_path_state_init
: uti path path_state_initpath_state_set_
: uti path path_state_set_prof_get_info_string
: uti profiling prof_get_info_stringprof_get_measurement_stime
: uti profiling prof_get_measurement_stimeprof_get_measurement_utime
: uti profiling prof_get_measurement_utimeprof_get_measurement_wallclock
: uti profiling prof_get_measurement_wallclockprof_get_total_busy
: uti profiling prof_get_total_busyprof_get_total_stime
: uti profiling prof_get_total_stimeprof_get_total_utime
: uti profiling prof_get_total_utimeprof_get_total_wallclock
: uti profiling prof_get_total_wallclockprof_info_init
: uti profiling prof_info_initprof_info_level_init
: uti profiling prof_info_level_initprof_is_active
: uti profiling prof_is_activeprof_reset
: uti profiling prof_resetprof_reset_thread
: uti profiling prof_reset_threadprof_set_level_name
: uti profiling prof_set_level_nameprof_start
: uti profiling prof_startprof_start_measurement
: uti profiling prof_start_measurementPROF_START_MEASUREMENT
: uti profiling PROF_START_MEASUREMENTprof_stop
: uti profiling prof_stopprof_stop_measurement
: uti profiling prof_stop_measurementPROF_STOP_MEASUREMENT
: uti profiling PROF_STOP_MEASUREMENTprof_thread_local_once_init
: uti profiling prof_thread_local_once_initPROFILING
: uti log PROFILINGprog_once_init
: uti prog prog_once_initprog_state_destroy
: uti prog prog_state_destroyprog_state_getspecific
: uti prog prog_state_getspecificprog_state_init
: uti prog prog_state_initptym_open
: uti pty ptym_openptys_open
: uti pty ptys_openredirect_to_dev_null
: uti os redirect_to_dev_nullrmon_condition
: rmon_macros rmon_conditionrmon_debug_client_callback
: rmon_macros rmon_debug_client_callbackrmon_is_enabled
: rmon_macros rmon_is_enabledrmon_menter
: rmon_macros rmon_menterrmon_mexit
: rmon_macros rmon_mexitrmon_mopen
: rmon_macros rmon_mopenrmon_mprintf
: rmon_macros rmon_mprintfrmon_mtrace
: rmon_macros rmon_mtracesanitize_environment
: uti sanitize_environmentset_admin_user
: uti uidgid set_admin_userset_debug_level_from_env
: rmon_macros set_debug_level_from_envset_debug_target_from_env
: rmon_macros set_debug_target_from_envset_thread_name
: uti profiling set_thread_nameset_thread_prof_status_by_id
: uti profiling set_thread_prof_status_by_idset_thread_prof_status_by_name
: uti profiling set_thread_prof_status_by_namesge_add_group
: uti uidgid sge_add_groupsge_afs_extend_token
: uti afsutil sge_afs_extend_tokenSGE_ASSERT
: uti log SGE_ASSERTsge_at_time
: uti time sge_at_timesge_basename
: uti string sge_basenamesge_bin2string
: uti io sge_bin2stringsge_bitfield_bitwise_copy
: uti bitfield sge_bitfield_bitwise_copysge_bitfield_changed
: uti bitfield sge_bitfield_changedsge_bitfield_clear
: uti bitfield sge_bitfield_clearsge_bitfield_copy
: uti bitfield sge_bitfield_copysge_bitfield_free
: uti bitfield sge_bitfield_freesge_bitfield_free_data
: uti bitfield sge_bitfield_free_datasge_bitfield_get
: uti bitfield sge_bitfield_getsge_bitfield_init
: uti bitfield sge_bitfield_initsge_bitfield_new
: uti bitfield sge_bitfield_newsge_bitfield_print
: uti bitfield sge_bitfield_printsge_bitfield_reset
: uti bitfield sge_bitfield_resetsge_bitfield_set
: uti bitfield sge_bitfield_setsge_bootstrap
: uti bootstrap sge_bootstrapsge_chdir
: uti unistd sge_chdirsge_chdir_exit
: uti unistd sge_chdir_exitsge_checkprog
: uti os sge_checkprogsge_close_all_fds
: uti os sge_close_all_fdssge_close_fd
: uti os sge_close_fdsge_compress_slashes
: uti string sge_compress_slashessge_contains_pid
: uti os sge_contains_pidsge_copy_append
: uti io sge_copy_appendsge_copy_hostent
: uti host sge_copy_hostentsge_copy_sanitize_env
: uti sge_copy_sanitize_envsge_ctime
: uti time sge_ctimesge_ctime32
: uti time sge_ctime32sge_delim_str
: uti string sge_delim_strsge_dirname
: uti string sge_dirnamesge_dlopen
: uti sge_dlopensge_do_log
: uti sge_log sge_do_logsge_dstring_append
: uti dstring sge_dstring_appendsge_dstring_append_dstring
: uti dstring sge_dstring_append_dstringsge_dstring_clear
: uti dstring sge_dstring_clearsge_dstring_copy_dstring
: uti dstring sge_dstring_copy_dstringsge_dstring_copy_string
: uti dstring sge_dstring_copy_stringsge_dstring_free
: uti dstring sge_dstring_freesge_dstring_get_string
: uti dstring sge_dstring_get_stringsge_dstring_init
: uti dstring sge_dstring_initsge_dstring_remaining
: uti dstring sge_dstring_remainingsge_dstring_split
: uti dstring sge_dstring_splitsge_dstring_sprintf
: uti dstring sge_dstring_sprintfsge_dstring_sprintf_append
: uti dstring sge_dstring_sprintf_appendsge_dstring_strip_white_space_at_eol
: uti dstring sge_dstring_strip_white_space_at_eolsge_dstring_strlen
: uti dstring sge_dstring_strlensge_dstring_ulong_to_binstring
: uti dstring sge_dstring_ulong_to_binstringsge_dstring_vsprintf
: uti dstring sge_dstring_vsprintfsge_dup_fd_above_stderr
: uti os sge_dup_fd_above_stderrsge_execvlp
: uti sge_execvlpsge_exit
: uti unistd sge_exitsge_fifo_lock
: lib lock sge_fifo_locksge_fifo_lock_init
: lib lock sge_fifo_lock_initsge_fifo_ulock
: lib lock sge_fifo_ulocksge_file2string
: uti io sge_file2stringsge_file_path_format_t
: uti spool sge_file_path_format_tsge_file_path_id_t
: uti spool sge_file_path_id_tsge_filecmp
: uti io sge_filecmpsge_free
: uti stdlib sge_freesge_free_saved_vars
: uti string sge_free_saved_varssge_get_active_job_file_path
: uti spool sge_get_active_job_file_pathsge_get_alias_path
: uti prog sge_get_alias_pathsge_get_arch
: uti prog sge_get_archsge_get_confval
: uti spool sge_get_confvalsge_get_confval_array
: uti spool sge_get_confval_arraysge_get_default_cell
: uti prog sge_get_default_cellsge_get_file_path
: uti spool sge_get_file_pathsge_get_gmt
: uti time sge_get_gmtsge_get_ja_tasks_per_directory
: uti spool sge_get_ja_tasks_per_directorysge_get_ja_tasks_per_file
: uti spool sge_get_ja_tasks_per_filesge_get_lib_dir
: uti prog sge_get_lib_dirsge_get_management_entry
: uti spool sge_get_management_entrysge_get_max_fd
: uti os sge_get_max_fdsge_get_message_id_output
: uti language sge_get_message_id_outputsge_get_message_id_output_implementation
: uti language sge_get_message_id_output_implementationsge_get_pids
: uti os sge_get_pidssge_get_qmaster_port
: sge_hostname sge_get_qmaster_portsge_get_root_dir
: uti prog sge_get_root_dirsge_get_token_cmd
: uti afsutil sge_get_token_cmdsge_getcpuload
: uti os sge_getcpuloadsge_getenv
: uti stdlib sge_getenvsge_getgrgid_r
: uti uidgid sge_getgrgid_rsge_gethostbyaddr
: uti host sge_gethostbyaddrsge_gethostbyname
: uti host sge_gethostbynamesge_gethostbyname_retry
: uti hostname sge_gethostbyname_retrysge_getme
: uti prog sge_getmesge_getpwnam_r
: uti uidgid sge_getpwnam_rsge_gettext
: uti language sge_gettextsge_gettext_
: uti language sge_gettext_sge_gettext__
: uti language sge_gettext__sge_gid2group
: uti uidgid sge_gid2groupsge_group2gid
: uti uidgid sge_group2gidsge_has_admin_user
: uti uidgid sge_has_admin_usersge_host_delete
: uti hostname sge_host_deletesge_host_get_mainname
: uti hostname sge_host_get_mainnamesge_host_list_print
: uti hostname sge_host_list_printsge_host_print
: uti hostname sge_host_printsge_host_search
: uti hostname sge_host_searchsge_host_search_pred_alias
: uti hostname sge_host_search_pred_aliassge_hostcmp
: uti hostname sge_hostcmpsge_hostcpy
: uti hostname sge_hostcpysge_hostmatch
: uti hostname sge_hostmatchsge_htable_create
: uti htable sge_htable_createsge_htable_delete
: uti htable sge_htable_deletesge_htable_destroy
: uti htable sge_htable_destroysge_htable_for_each
: uti htable sge_htable_for_eachsge_htable_lookup
: uti htable sge_htable_lookupsge_htable_resize
: uti htable sge_htable_resizesge_htable_statistics
: uti htable sge_htable_statisticssge_htable_store
: uti htable sge_htable_storesge_init_language
: uti language sge_init_languagesge_init_language_func
: uti language sge_init_language_funcsge_is_admin_user
: uti uidgid sge_is_admin_usersge_is_directory
: uti unistd sge_is_directorysge_is_expression
: uti string sge_is_expressionsge_is_file
: uti unistd sge_is_filesge_is_pattern
: uti string sge_is_patternsge_is_start_user_superuser
: uti uidgid sge_is_start_user_superusersge_is_user_superuser
: uti uidgid sge_is_user_superusersge_jobname
: uti string sge_jobnamesge_lock
: sge_lock sge_locksge_locker_id
: sge_lock sge_locker_idsge_log
: uti log sge_logsge_malloc
: uti stdlib sge_mallocsge_map_signal
: uti signal sge_map_signalsge_maybe_set_dumpable
: uti stdlib sge_maybe_set_dumpablesge_mem_info_t
: uti os sge_mem_info_tsge_mkdir
: uti unistd sge_mkdirsge_mkstemp
: uti sge_tmpnam sge_mkstempsge_mode_t
: uti io sge_mode_tsge_monitor_free
: uti monitor sge_monitor_freesge_monitor_init
: uti monitor sge_monitor_initsge_monitor_output
: uti monitor sge_monitor_outputsge_monitor_reset
: uti monitor sge_monitor_resetsge_monitor_status
: uti monitor sge_monitor_statussge_mutex_lock
: sge_mtutil sge_mutex_locksge_mutex_unlock
: sge_mtutil sge_mutex_unlocksge_nprocs
: uti os sge_nprocssge_occupy_first_three
: uti os sge_occupy_first_threesge_patternnullcmp
: uti string sge_patternnullcmpsge_peclose
: uti stdio sge_peclosesge_peopen_r
: uti stdio sge_peopen_rsge_prof_cleanup
: uti profiling sge_prof_cleanupsge_prof_set_enabled
: uti profiling sge_prof_set_enabledsge_putenv
: uti stdlib sge_putenvsge_read_token
: uti afsutil sge_read_tokensge_readnbytes
: uti io sge_readnbytessge_readpid
: uti spool sge_readpidsge_realloc
: uti stdlib sge_reallocsge_relative_timespec
: sge_mtutil sge_relative_timespecsge_replace_substring
: uti string sge_replace_substringsge_rmdir
: uti unistd sge_rmdirsge_run_as_user
: uti uidgid sge_run_as_usersge_set_admin_username
: uti uidgid sge_set_admin_usernamesge_set_def_sig_mask
: uti signal sge_set_def_sig_masksge_set_last_wait_time
: uti monitor sge_set_last_wait_timesge_set_message_id_output
: uti language sge_set_message_id_outputsge_set_uid_gid_addgrp
: uti uidgid sge_set_uid_gid_addgrpsge_setegid
: uti stdlib sge_setegidsge_setenv
: uti stdlib sge_setenvsge_seteuid
: uti stdlib sge_seteuidsge_setgid
: uti stdlib sge_setgidsge_setuid
: uti stdlib sge_setuidsge_setup_paths
: uti path sge_setup_pathssge_shlib_ext
: uti sge_shlib_extsge_show_me
: uti prog sge_show_mesge_sig2str
: uti signal sge_sig2strsge_silent_get
: uti spool sge_silent_getsge_silent_set
: uti spool sge_silent_setsge_sl_append_after
: uti sl sge_sl_append_aftersge_sl_create
: uti sl sge_sl_createsge_sl_data
: uti sl sge_sl_datasge_sl_data_search
: uti sl sge_sl_data_searchsge_sl_dechain
: uti sl sge_sl_dechainsge_sl_delete
: uti sl sge_sl_deletesge_sl_delete_search
: uti sl sge_sl_delete_searchsge_sl_destroy
: uti sl sge_sl_destroysge_sl_elem_count
: uti sl sge_sl_elem_countsge_sl_elem_create
: uti sl sge_sl_elem_createsge_sl_elem_data
: uti sl sge_sl_elem_datasge_sl_elem_destroy
: uti sl sge_sl_elem_destroysge_sl_elem_next
: uti sl sge_sl_elem_nextsge_sl_elem_search
: uti sl sge_sl_elem_searchsge_sl_get_mutex
: uti sl sge_sl_get_mutexsge_sl_insert
: uti sl sge_sl_insertsge_sl_insert_before
: uti sl sge_sl_insert_beforesge_sl_insert_search
: uti sl sge_sl_insert_searchsge_sl_lock
: uti sl sge_sl_locksge_sl_sort
: uti sl sge_sl_sortsge_sl_unlock
: uti sl sge_sl_unlocksge_sleep
: uti unistd sge_sleepsge_spool_flags_t
: uti spool sge_spool_flags_tsge_spoolmsg_write
: uti spool sge_spoolmsg_writesge_status_end_turn
: uti spool sge_status_end_turnsge_status_next_turn
: uti spool sge_status_next_turnsge_status_set_type
: uti spool sge_status_set_typesge_stopwatch_log
: uti time sge_stopwatch_logsge_stopwatch_start
: uti time sge_stopwatch_startsge_str2signal
: uti signal sge_str2signalsge_str_is_number
: uti string sge_str_is_numbersge_stracasecmp
: uti string sge_stracasecmpsge_stradup
: uti string sge_stradupsge_strafree
: uti string sge_strafreesge_stramemncpy
: uti string sge_stramemncpysge_strdup
: uti string sge_strdupsge_stream2string
: uti io sge_stream2stringsge_strerror
: uti string sge_strerrorsge_string2bin
: uti io sge_string2binsge_string2file
: uti io sge_string2filesge_strip_blanks
: uti string sge_strip_blankssge_strip_quotes
: uti string sge_strip_quotessge_strip_slash_at_eol
: uti string sge_strip_slash_at_eolsge_strip_white_space_at_eol
: uti string sge_strip_white_space_at_eolsge_strisint
: uti string sge_strisintsge_strlcat
: uti string sge_strlcatsge_strlcpy
: uti string sge_strlcpysge_strlen
: uti string sge_strlensge_strnullcasecmp
: uti string sge_strnullcasecmpsge_strnullcmp
: uti string sge_strnullcmpsge_strtok
: uti string sge_strtoksge_strtok_r
: uti string sge_strtok_rsge_strtolower
: uti hostname sge_strtolowersge_strtoupper
: uti string sge_strtouppersge_switch2admin_user
: uti uidgid sge_switch2admin_usersge_switch2start_user
: uti uidgid sge_switch2start_usersge_sys_sig2str
: uti signal sge_sys_sig2strsge_sys_str2signal
: uti signal sge_sys_str2signalsge_thread_block_all_signals
: uti signal sge_thread_block_all_signalssge_thread_has_shutdown_started
: uti thread_ctrl sge_thread_has_shutdown_startedsge_thread_notify_all_waiting
: uti thread_ctrl sge_thread_notify_all_waitingsge_thread_wait_for_signal
: uti thread_ctrl sge_thread_wait_for_signalsge_tq_create
: uti tq sge_tq_createsge_tq_destroy
: uti tq sge_tq_destroysge_tq_get_task_count
: uti tq sge_tq_get_task_countsge_tq_get_waiting_count
: uti tq sge_tq_get_waiting_countsge_tq_store_notify
: uti tq sge_tq_store_notifysge_tq_task_compare_type
: uti tq sge_tq_task_compare_typesge_tq_task_create
: uti tq sge_tq_task_createsge_tq_task_destroy
: uti tq sge_tq_task_destroysge_tq_wait_for_task
: uti tq sge_tq_wait_for_tasksge_tq_wakeup_waiting
: uti tq sge_tq_wakeup_waitingsge_uid2user
: uti uidgid sge_uid2usersge_unblock_all_signals
: uti signal sge_unblock_all_signalssge_unlink
: uti unistd sge_unlinksge_unlock
: sge_lock sge_unlocksge_unmap_signal
: uti signal sge_unmap_signalsge_unsetenv
: uti stdlib sge_unsetenvsge_user2uid
: uti uidgid sge_user2uidsge_usleep
: uti time sge_usleepsge_write_pid
: uti spool sge_write_pidsge_writenbytes
: uti io sge_writenbytesstra_from_str
: uti string stra_from_strterminal_enter_raw_mode
: uti pty terminal_enter_raw_modeterminal_leave_raw_mode
: uti pty terminal_leave_raw_modethread_function
: test_sge_lock_simple thread_functionthread_function
: test_sge_lock_multiple thread_functionthread_function_1
: test_sge_lock_simple thread_function_1thread_function_2
: test_sge_deadlock thread_function_2thread_output_profiling
: uti profiling thread_output_profilingthread_prof_active_by_id
: uti profiling thread_prof_active_by_idthread_prof_active_by_name
: uti profiling thread_prof_active_by_namethread_start_stop_profiling
: uti profiling thread_start_stop_profilingtopology_string_to_socket_core_lists
: sge_binding_hlp topology_string_to_socket_core_listsuidgid_mt_init
: uti uidgid uidgid_mt_inituidgid_once_init
: uti uidgid uidgid_once_inituidgid_state_destroy
: uti uidgid uidgid_state_destroyuidgid_state_get_
: uti uidgid uidgid_state_get_uidgid_state_init
: uti uidgid uidgid_state_inituidgid_state_set_
: uti uidgid uidgid_state_set_unescape_env_value
: sge_var unescape_env_valueuti_state_get_
: uti prog uti_state_get_uti_state_get_exit_func
: uti prog uti_state_get_exit_funcuti_state_set_
: uti prog uti_state_set_uti_state_set_exit_func
: uti prog uti_state_set_exit_funcWARNING
: uti log WARNING