![]() |
MAOS
Multithreaded Adaptive Optics Simulator
|
Macros | |
| #define | MAOS_DISABLE_SCHEDULER 0 |
| #define | CATCH_ERR(A) |
Functions | |
| void | wait_cpu (int nthread) |
| void | parse_host (const char *line) |
| void | free_hosts () |
| void | init_hosts () |
| const char * | lookup_hostaddr (const char *hostname) |
| const char * | lookup_hostname (const char *hostaddr) |
| char * | scheduler_password (int create) |
| int | scheduler_auth (int sock) |
| int | scheduler_connect (const char *hostname) |
| int | scheduler_connect_self (int block) |
| void | scheduler_report_path (const char *path) |
| void | scheduler_start (int nthread, int ngpu, int waiting) |
| void | scheduler_finish (int status) |
| void | scheduler_report (status_t *status) |
| pthread_t | scheduler_listen (thread_fun fun) |
| int | scheduler_launch_exe (char *hostarr, int argc, const char *argv[]) |
| int | scheduler_socket (int dir, int *sfd, int id) |
| int | call_addr2line (char *ans, int nans, const char *cmdstr) |
| int | print_backtrace_symbol (void *const *buffer, int size) |
| void | print_backtrace () |
Contains routines that will be used to talk to the scheduler. The following usage are supported:
1) by maos or skyc to ask permission to go or report status. 2) by monitor to show process information or request plotting. 3) by maos or skyc to print backtrace.
| #define CATCH_ERR | ( | A | ) |
| void wait_cpu | ( | int | nthread | ) |
Wait until enough CPUs are idle to run nthread threads (capped at NCPU), polling every 5 seconds. Used when the scheduler is not available. A lock file in HOME serializes waiting processes.
| [in] | nthread | Number of threads needed. |
| void parse_host | ( | const char * | line | ) |
Parse and add host info to hosts[] and hostaddr[]. hosts contains the shortcut name, without dot and hostaddr contains the FQDN and optionally the port
| [in] | line | Contains hostname[=hostaddr:port]. Empty lines and lines starting with # are ignored. |
| void free_hosts | ( | ) |
free hosts[] and hostsaddr[]
| void init_hosts | ( | ) |
Initialize hosts and associate an id number
| const char * lookup_hostaddr | ( | const char * | hostname | ) |
Translate hostname to address based on ~/.aos/hosts
| [in] | hostname | The host name. |
| const char * lookup_hostname | ( | const char * | hostaddr | ) |
Translate address to hostname based on ~/.aos/hosts
| [in] | hostaddr | The host address. |
| char * scheduler_password | ( | int | create | ) |
Read the password that authenticates TCP connections to the scheduler, including the browser monitor, from the first line of ~/.aos/htpasswd.
| [in] | create | If the file does not exist, create it with a random password. |
| int scheduler_auth | ( | int | sock | ) |
Authenticate a TCP connection to the scheduler. The scheduler sends a random nonce and the client replies with base64(sha1(nonce+password)), so that the password is not sent over the network.
| [in] | sock | Socket connected to the scheduler. |
| int scheduler_connect | ( | const char * | hostname | ) |
Connect to the scheduler at hostname using PORT and authenticate. Returns the socket or -1 if failed or the scheduler is disabled.
| [in] | hostname | Host name or address of the scheduler. |
| int scheduler_connect_self | ( | int | block | ) |
To open a port and connect to scheduler in the local host. Launches the scheduler if it is not running.
| [in] | block | Nonzero to retry up to 100 times; otherwise retry twice. |
| void scheduler_report_path | ( | const char * | path | ) |
Report the job path (command line) to the scheduler via a persistent connection. The path is saved so that it can be resent with path=NULL after reconnection.
| [in] | path | The job path. NULL to resend the saved path. |
| void scheduler_start | ( | int | nthread, |
| int | ngpu, | ||
| int | waiting ) |
Called by maos to report a job start to scheduler and wait for signal before proceeding if waiting is set.
| [in] | nthread | Number of threads the job uses. |
| [in] | ngpu | Number of GPUs the job uses. |
| [in] | waiting | Nonzero to wait for the scheduler (or for idle CPUs if the scheduler is unavailable) before returning. |
| void scheduler_finish | ( | int | status | ) |
Called by maos to notify scheduler the completion of a job
| [in] | status | 0 for success; a crash signal reports a crash; otherwise the job is reported as killed. |
| void scheduler_report | ( | status_t * | status | ) |
called by sim.c to report job status. Do not try to reconnect. If not connected, a thread is launched to connect in the background.
| [in] | status | The job status. |
| pthread_t scheduler_listen | ( | thread_fun | fun | ) |
Started by maos to listen to the sock which connects to the scheduler for commands. It reuses existing connection.
| [in] | fun | Thread function that is called with the socket as its argument. |
| int scheduler_launch_exe | ( | char * | hostarr, |
| int | argc, | ||
| const char * | argv[] ) |
Ask scheduler (maybe in another machine) to launch executable. Host may be null or contain coma separated hosts
| [in,out] | hostarr | Coma separated host names; NULL means localhost. Temporarily modified but restored. |
| [in] | argc | Number of arguments. |
| [in] | argv | Arguments. argv[0] is the executable. |
| int scheduler_socket | ( | int | dir, |
| int * | sfd, | ||
| int | id ) |
send a drawing sock to the scheduler for caching (dir=1) or request an existing sock (dir=-1) or new sock (dir=0) for drawing. abs(id) should be between 1 and 9999. the id send to the scheduler has the following meaning: -10000<id<0: request existing socket (drawdaemon). preferably for the same id<-10000: request new socket (drawdaemon). id>0: save socket (drawdaemon) for reuse.
| [in] | dir | 1: send sfd for caching; -1: request an existing socket; 0: request a new socket. |
| [in,out] | sfd | The socket to send (dir=1) or the received socket (dir=0 or -1). |
| [in] | id | Drawing id (sign is ignored). |
| int call_addr2line | ( | char * | ans, |
| int | nans, | ||
| const char * | cmdstr ) |
Execute addr2line as specified in cmdstr and combine the answer into a string. If it fails, the program name and addresses are copied instead.
| [out] | ans | Output string. |
| [in] | nans | Size of ans. |
| [in] | cmdstr | The addr2line command. |
| int print_backtrace_symbol | ( | void *const * | buffer, |
| int | size ) |
Convert backtrace address to source line. Do not call routines that may call malloc as the mutex in malloc may already be locked.
| [in] | buffer | Addresses returned by backtrace(). |
| [in] | size | Number of addresses. |
| void print_backtrace | ( | ) |
Print the backtrace of the current call stack with symbol names.