2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2003-07-01 20:37:09 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2003-07-01 20:37:09 +00:00
|
|
|
|
2017-04-08 06:54:49 +00:00
|
|
|
#ifndef BOINC_APP_IPC_H
|
|
|
|
#define BOINC_APP_IPC_H
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2012-06-11 12:51:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2004-09-14 21:29:52 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2005-04-28 23:19:58 +00:00
|
|
|
#include <cstdio>
|
2004-09-14 21:29:52 +00:00
|
|
|
|
2015-10-20 17:33:10 +00:00
|
|
|
#include "filesys.h"
|
2004-06-16 19:21:11 +00:00
|
|
|
#include "hostinfo.h"
|
2004-10-06 19:09:37 +00:00
|
|
|
#include "proxy_info.h"
|
|
|
|
#include "prefs.h"
|
2006-09-01 21:06:30 +00:00
|
|
|
#include "common_defs.h"
|
2004-06-16 19:21:11 +00:00
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
// Communication between the core client and the BOINC app library.
|
|
|
|
// This code is linked into both core client and app lib.
|
2004-06-29 01:15:51 +00:00
|
|
|
//
|
|
|
|
// Some apps may involve separate "coordinator" and "worker" programs.
|
|
|
|
// The coordinator runs one or more worker programs in sequence,
|
|
|
|
// and don't do work themselves.
|
|
|
|
//
|
2003-05-07 23:42:17 +00:00
|
|
|
// Includes the following:
|
|
|
|
// - shared memory (APP_CLIENT_SHM)
|
|
|
|
// - main init file
|
|
|
|
// - fd init file
|
|
|
|
// - graphics init file
|
2003-06-14 20:24:29 +00:00
|
|
|
// - conversion of symbolic links
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2004-07-08 03:38:52 +00:00
|
|
|
// Shared memory is a set of MSG_CHANNELs.
|
|
|
|
// First byte of a channel is nonzero if
|
|
|
|
// the channel contains an unread data.
|
2004-06-29 01:15:51 +00:00
|
|
|
// This is set by the sender and cleared by the receiver.
|
|
|
|
// The sender doesn't write if the flag is set.
|
|
|
|
// Remaining 1023 bytes contain data.
|
|
|
|
//
|
2004-07-08 03:38:52 +00:00
|
|
|
#define MSG_CHANNEL_SIZE 1024
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2004-07-08 03:38:52 +00:00
|
|
|
struct MSG_CHANNEL {
|
|
|
|
char buf[MSG_CHANNEL_SIZE];
|
|
|
|
bool get_msg(char*); // returns a message and clears pending flag
|
2012-01-13 19:00:16 +00:00
|
|
|
inline bool has_msg() {
|
|
|
|
return buf[0]?true:false;
|
|
|
|
}
|
2005-02-16 23:17:43 +00:00
|
|
|
bool send_msg(const char*); // if there is not a message in the segment,
|
2004-07-08 03:38:52 +00:00
|
|
|
// writes specified message and sets pending flag
|
2005-02-16 23:17:43 +00:00
|
|
|
void send_msg_overwrite(const char*);
|
2004-08-23 22:06:48 +00:00
|
|
|
// write message, overwriting any msg already there
|
2004-07-08 03:38:52 +00:00
|
|
|
};
|
2004-06-29 01:15:51 +00:00
|
|
|
|
2004-07-08 03:38:52 +00:00
|
|
|
struct SHARED_MEM {
|
|
|
|
MSG_CHANNEL process_control_request;
|
|
|
|
// core->app
|
|
|
|
// <quit/>
|
|
|
|
// <suspend/>
|
|
|
|
// <resume/>
|
|
|
|
MSG_CHANNEL process_control_reply;
|
|
|
|
// app->core
|
|
|
|
MSG_CHANNEL graphics_request;
|
|
|
|
// core->app
|
2013-07-09 23:22:10 +00:00
|
|
|
// not currently used
|
2004-07-08 03:38:52 +00:00
|
|
|
MSG_CHANNEL graphics_reply;
|
|
|
|
// app->core
|
2013-07-09 23:22:10 +00:00
|
|
|
// <web_graphics_url>
|
|
|
|
// <remote_desktop_addr>
|
2004-07-08 03:38:52 +00:00
|
|
|
MSG_CHANNEL heartbeat;
|
|
|
|
// core->app
|
2007-11-29 19:48:04 +00:00
|
|
|
// <heartbeat/> sent every second, even while app is suspended
|
|
|
|
// <wss> app's current working set size
|
|
|
|
// <max_wss> max working set size
|
2004-07-08 03:38:52 +00:00
|
|
|
MSG_CHANNEL app_status;
|
|
|
|
// app->core
|
|
|
|
// status message every second, of the form
|
|
|
|
// <current_cpu_time>...
|
|
|
|
// <checkpoint_cpu_time>...
|
|
|
|
// <working_set_size>...
|
|
|
|
// <fraction_done> ...
|
|
|
|
MSG_CHANNEL trickle_up;
|
|
|
|
// app->core
|
|
|
|
// <have_new_trickle_up/>
|
|
|
|
MSG_CHANNEL trickle_down;
|
|
|
|
// core->app
|
|
|
|
// <have_new_trickle_down/>
|
|
|
|
};
|
2003-05-28 22:39:08 +00:00
|
|
|
|
2005-04-28 23:19:58 +00:00
|
|
|
// MSG_QUEUE provides a queuing mechanism for shared-mem messages
|
|
|
|
// (which don't have one otherwise)
|
|
|
|
//
|
2004-09-13 05:27:28 +00:00
|
|
|
struct MSG_QUEUE {
|
|
|
|
std::vector<std::string> msgs;
|
|
|
|
char name[256];
|
2006-12-09 00:10:53 +00:00
|
|
|
double last_block; // last time we found message channel full
|
|
|
|
void init(char*);
|
2005-02-16 23:17:43 +00:00
|
|
|
void msg_queue_send(const char*, MSG_CHANNEL& channel);
|
2004-09-13 05:27:28 +00:00
|
|
|
void msg_queue_poll(MSG_CHANNEL& channel);
|
2006-11-21 00:45:22 +00:00
|
|
|
int msg_queue_purge(const char*);
|
2006-12-09 00:10:53 +00:00
|
|
|
bool timeout(double);
|
2004-09-13 05:27:28 +00:00
|
|
|
};
|
|
|
|
|
2003-05-28 22:39:08 +00:00
|
|
|
#define DEFAULT_CHECKPOINT_PERIOD 300
|
|
|
|
|
|
|
|
#define SHM_PREFIX "shm_"
|
|
|
|
#define QUIT_PREFIX "quit_"
|
2003-05-07 23:42:17 +00:00
|
|
|
|
|
|
|
class APP_CLIENT_SHM {
|
|
|
|
public:
|
2004-07-08 03:38:52 +00:00
|
|
|
SHARED_MEM *shm;
|
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
void reset_msgs(); // resets all messages and clears their flags
|
2004-02-09 05:11:05 +00:00
|
|
|
|
|
|
|
APP_CLIENT_SHM();
|
2003-05-07 23:42:17 +00:00
|
|
|
};
|
|
|
|
|
2004-08-31 21:02:17 +00:00
|
|
|
#ifdef _WIN32
|
2004-08-31 21:20:31 +00:00
|
|
|
typedef char SHMEM_SEG_NAME[256];
|
2004-08-31 21:02:17 +00:00
|
|
|
#else
|
|
|
|
typedef int SHMEM_SEG_NAME;
|
|
|
|
#endif
|
|
|
|
|
2003-07-15 18:19:29 +00:00
|
|
|
// parsed version of main init file
|
2009-02-11 22:36:33 +00:00
|
|
|
// If you add anything here, update copy()
|
2003-07-15 18:19:29 +00:00
|
|
|
//
|
2003-05-28 22:39:08 +00:00
|
|
|
struct APP_INIT_DATA {
|
2013-07-30 17:47:54 +00:00
|
|
|
int major_version; // BOINC client version info
|
2005-08-31 00:18:36 +00:00
|
|
|
int minor_version;
|
|
|
|
int release;
|
2005-10-12 18:40:53 +00:00
|
|
|
int app_version;
|
2003-09-27 17:53:43 +00:00
|
|
|
char app_name[256];
|
2013-07-30 17:47:54 +00:00
|
|
|
char symstore[256]; // symstore URL (Windows)
|
2006-05-28 14:45:29 +00:00
|
|
|
char acct_mgr_url[256];
|
2013-07-30 17:47:54 +00:00
|
|
|
// if client is using account manager, its URL
|
2004-10-06 19:09:37 +00:00
|
|
|
char* project_preferences;
|
2013-07-30 17:47:54 +00:00
|
|
|
// project prefs XML
|
2011-01-13 22:40:48 +00:00
|
|
|
int userid;
|
2013-07-30 17:47:54 +00:00
|
|
|
// project's DB ID for this user/team/host
|
2011-01-13 22:40:48 +00:00
|
|
|
int teamid;
|
2004-10-06 19:09:37 +00:00
|
|
|
int hostid;
|
2003-05-28 22:39:08 +00:00
|
|
|
char user_name[256];
|
|
|
|
char team_name[256];
|
2013-07-30 17:47:54 +00:00
|
|
|
char project_dir[256]; // where project files are stored on host
|
2015-10-20 17:33:10 +00:00
|
|
|
char boinc_dir[MAXPATHLEN]; // BOINC data directory
|
2013-07-30 17:47:54 +00:00
|
|
|
char wu_name[256]; // workunit name
|
2010-07-30 21:43:23 +00:00
|
|
|
char result_name[256];
|
2013-07-30 17:47:54 +00:00
|
|
|
char authenticator[256]; // user's authenticator
|
|
|
|
int slot; // the slot this job is running in (0, 1, ...)
|
|
|
|
int client_pid; // process ID of BOINC client
|
2003-05-28 22:39:08 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double host_total_credit;
|
|
|
|
double host_expavg_credit;
|
2013-07-30 17:47:54 +00:00
|
|
|
double resource_share_fraction; // this project's resource share frac
|
2004-06-16 19:21:11 +00:00
|
|
|
HOST_INFO host_info;
|
2013-07-30 17:47:54 +00:00
|
|
|
PROXY_INFO proxy_info; // in case app wants to use network
|
2004-10-06 19:09:37 +00:00
|
|
|
GLOBAL_PREFS global_prefs;
|
2009-07-01 17:35:56 +00:00
|
|
|
double starting_elapsed_time; // elapsed time, counting previous episodes
|
2013-07-30 17:47:54 +00:00
|
|
|
bool using_sandbox; // client is using account-based sandboxing
|
2013-10-04 03:52:05 +00:00
|
|
|
bool vm_extensions_disabled;
|
|
|
|
// client has already been notified that the VM extensions of
|
|
|
|
// the processor have been disabled
|
2003-07-15 18:19:29 +00:00
|
|
|
|
2006-06-09 02:33:00 +00:00
|
|
|
// info about the WU
|
|
|
|
double rsc_fpops_est;
|
|
|
|
double rsc_fpops_bound;
|
|
|
|
double rsc_memory_bound;
|
|
|
|
double rsc_disk_bound;
|
2008-06-12 19:05:14 +00:00
|
|
|
double computation_deadline;
|
2006-06-09 02:33:00 +00:00
|
|
|
|
2006-12-19 22:52:58 +00:00
|
|
|
// the following are used for compound apps,
|
2007-11-29 19:48:04 +00:00
|
|
|
// where each stage of the computation is a fixed fraction of the total.
|
2011-10-21 06:58:35 +00:00
|
|
|
//
|
2006-12-19 22:52:58 +00:00
|
|
|
double fraction_done_start;
|
|
|
|
double fraction_done_end;
|
|
|
|
|
2011-09-11 03:28:22 +00:00
|
|
|
// info for GPU apps
|
2011-10-21 06:58:35 +00:00
|
|
|
//
|
2011-09-11 03:28:22 +00:00
|
|
|
char gpu_type[64];
|
|
|
|
int gpu_device_num;
|
2012-01-20 13:30:47 +00:00
|
|
|
int gpu_opencl_dev_index;
|
2013-03-21 03:37:26 +00:00
|
|
|
double gpu_usage; // APP_VERSION.gpu_usage.usage
|
2011-09-11 03:28:22 +00:00
|
|
|
|
2011-12-01 18:44:19 +00:00
|
|
|
// info for multicore apps: how many cores to use
|
|
|
|
//
|
|
|
|
double ncpus;
|
|
|
|
|
2020-07-24 07:58:45 +00:00
|
|
|
// client configuration info, from cc_config.h
|
2012-05-18 17:38:16 +00:00
|
|
|
//
|
2013-07-30 17:47:54 +00:00
|
|
|
bool vbox_window; // whether to open a console window for VM apps
|
2012-05-18 17:38:16 +00:00
|
|
|
|
2020-07-24 07:58:45 +00:00
|
|
|
// the following for wrappers
|
|
|
|
//
|
|
|
|
bool no_priority_change;
|
|
|
|
int process_priority;
|
|
|
|
int process_priority_special;
|
|
|
|
|
2015-08-20 04:01:09 +00:00
|
|
|
// list of files in the app version (for wrappers)
|
|
|
|
//
|
|
|
|
std::vector<std::string> app_files;
|
|
|
|
|
2013-07-30 17:47:54 +00:00
|
|
|
// Items used by the BOINC runtime system
|
2003-07-15 18:19:29 +00:00
|
|
|
//
|
2003-05-28 22:39:08 +00:00
|
|
|
double checkpoint_period; // recommended checkpoint period
|
2004-08-31 21:02:17 +00:00
|
|
|
SHMEM_SEG_NAME shmem_seg_name;
|
2004-05-24 04:03:34 +00:00
|
|
|
double wu_cpu_time; // cpu time from previous episodes
|
2005-02-16 23:17:43 +00:00
|
|
|
|
|
|
|
APP_INIT_DATA();
|
2005-06-15 19:27:09 +00:00
|
|
|
APP_INIT_DATA(const APP_INIT_DATA&); // copy constructor
|
2008-08-19 00:08:01 +00:00
|
|
|
APP_INIT_DATA &operator=(const APP_INIT_DATA&);
|
2005-06-16 01:59:33 +00:00
|
|
|
void copy(const APP_INIT_DATA&); // actually do the copy here
|
2010-01-18 23:01:43 +00:00
|
|
|
void clear();
|
2005-02-16 23:17:43 +00:00
|
|
|
~APP_INIT_DATA();
|
2003-05-28 22:39:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GRAPHICS_INFO {
|
|
|
|
int xsize;
|
|
|
|
int ysize;
|
|
|
|
double refresh_period;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct GRAPHICS_INFO GRAPHICS_INFO;
|
2003-05-07 23:42:17 +00:00
|
|
|
|
|
|
|
int write_init_data_file(FILE* f, APP_INIT_DATA&);
|
|
|
|
int parse_init_data_file(FILE* f, APP_INIT_DATA&);
|
|
|
|
int write_graphics_file(FILE* f, GRAPHICS_INFO* gi);
|
|
|
|
int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi);
|
|
|
|
|
2004-06-29 04:34:55 +00:00
|
|
|
// filenames used in the slot directory
|
|
|
|
//
|
2003-05-07 23:42:17 +00:00
|
|
|
#define INIT_DATA_FILE "init_data.xml"
|
2004-04-04 01:59:47 +00:00
|
|
|
#define BOINC_FINISH_CALLED_FILE "boinc_finish_called"
|
2009-12-13 05:16:40 +00:00
|
|
|
#define TEMPORARY_EXIT_FILE "boinc_temporary_exit"
|
2004-04-23 00:05:16 +00:00
|
|
|
#define TRICKLE_UP_FILENAME "trickle_up.xml"
|
2003-05-28 22:39:08 +00:00
|
|
|
#define STDERR_FILE "stderr.txt"
|
2004-03-22 20:21:28 +00:00
|
|
|
#define STDOUT_FILE "stdout.txt"
|
2004-06-29 04:34:55 +00:00
|
|
|
#define LOCKFILE "boinc_lockfile"
|
2005-04-28 23:19:58 +00:00
|
|
|
#define UPLOAD_FILE_REQ_PREFIX "boinc_ufr_"
|
|
|
|
#define UPLOAD_FILE_STATUS_PREFIX "boinc_ufs_"
|
2003-05-28 22:39:08 +00:00
|
|
|
|
2006-07-18 01:46:55 +00:00
|
|
|
// other filenames
|
|
|
|
#define PROJECT_DIR "projects"
|
|
|
|
|
2005-04-28 23:19:58 +00:00
|
|
|
extern int boinc_link(const char* phys_name, const char* logical_name);
|
2011-09-27 19:45:27 +00:00
|
|
|
extern int boinc_resolve_filename_s(const char*, std::string&);
|
2015-09-23 07:02:52 +00:00
|
|
|
extern std::string resolve_soft_link(const char* project_dir, const char* file);
|
2016-02-18 06:53:37 +00:00
|
|
|
extern void url_to_project_dir(char* url, char* dir, int dirsize);
|
2006-07-17 22:11:59 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2006-07-17 22:29:02 +00:00
|
|
|
|
2006-07-17 20:02:12 +00:00
|
|
|
extern int boinc_resolve_filename(const char*, char*, int len);
|
2006-07-17 22:29:02 +00:00
|
|
|
|
2006-07-17 22:11:59 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
#endif
|