2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2003-07-01 20:37:09 +00:00
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
#ifndef _APP_IPC_
|
|
|
|
#define _APP_IPC_
|
|
|
|
|
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
|
|
|
|
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"
|
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
|
2004-10-14 22:01:05 +00:00
|
|
|
bool has_msg();
|
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
|
|
|
|
// same as above
|
|
|
|
MSG_CHANNEL graphics_request;
|
|
|
|
// core->app
|
|
|
|
// request a graphics mode:
|
|
|
|
// <mode_hide_graphics/>
|
|
|
|
// ...
|
|
|
|
// <mode_blankscreen/>
|
|
|
|
MSG_CHANNEL graphics_reply;
|
|
|
|
// app->core
|
|
|
|
// same as above
|
|
|
|
MSG_CHANNEL heartbeat;
|
|
|
|
// core->app
|
|
|
|
// <heartbeat/> sent every second, even while app is suspended
|
|
|
|
// <disable_heartbeat/> disables heartbeat mechanism
|
|
|
|
// <enable_heartbeat/> enable heartbeat mechanism (default)
|
|
|
|
MSG_CHANNEL app_status;
|
|
|
|
// app->core
|
|
|
|
// status message every second, of the form
|
|
|
|
// <current_cpu_time>...
|
|
|
|
// <checkpoint_cpu_time>...
|
|
|
|
// <working_set_size>...
|
|
|
|
// <fraction_done> ...
|
2005-08-17 21:05:26 +00:00
|
|
|
// <non_cpu_intensive>x</non_cpu_intensive>
|
2004-07-08 03:38:52 +00:00
|
|
|
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];
|
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);
|
|
|
|
};
|
|
|
|
|
2003-05-28 22:39:08 +00:00
|
|
|
#define DEFAULT_FRACTION_DONE_UPDATE_PERIOD 1
|
|
|
|
#define DEFAULT_CHECKPOINT_PERIOD 300
|
|
|
|
|
|
|
|
#define SHM_PREFIX "shm_"
|
|
|
|
#define QUIT_PREFIX "quit_"
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2004-07-08 03:38:52 +00:00
|
|
|
// graphics messages
|
2003-10-30 23:23:52 +00:00
|
|
|
//
|
|
|
|
#define MODE_UNSUPPORTED 0
|
|
|
|
#define MODE_HIDE_GRAPHICS 1
|
|
|
|
#define MODE_WINDOW 2
|
|
|
|
#define MODE_FULLSCREEN 3
|
2004-01-08 00:27:59 +00:00
|
|
|
#define MODE_BLANKSCREEN 4
|
2004-07-08 03:38:52 +00:00
|
|
|
#define MODE_REREAD_PREFS 5
|
2004-11-17 20:06:44 +00:00
|
|
|
#define MODE_QUIT 6
|
2004-01-08 00:27:59 +00:00
|
|
|
|
2004-11-17 20:06:44 +00:00
|
|
|
#define NGRAPHICS_MSGS 7
|
2003-10-30 23:23:52 +00:00
|
|
|
|
2004-11-17 19:19:26 +00:00
|
|
|
struct GRAPHICS_MSG {
|
|
|
|
int mode;
|
|
|
|
char window_station[256];
|
|
|
|
char desktop[256];
|
2005-02-15 06:32:43 +00:00
|
|
|
char display[256];
|
2004-11-17 19:19:26 +00:00
|
|
|
|
|
|
|
GRAPHICS_MSG();
|
|
|
|
};
|
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
class APP_CLIENT_SHM {
|
|
|
|
public:
|
2004-07-08 03:38:52 +00:00
|
|
|
SHARED_MEM *shm;
|
|
|
|
|
2004-11-17 19:19:26 +00:00
|
|
|
int decode_graphics_msg(char*, GRAPHICS_MSG&);
|
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
|
|
|
|
//
|
2003-05-28 22:39:08 +00:00
|
|
|
struct APP_INIT_DATA {
|
2005-08-31 00:18:36 +00:00
|
|
|
int major_version;
|
|
|
|
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];
|
2006-05-22 09:54:31 +00:00
|
|
|
char symstore[256];
|
2006-05-28 14:45:29 +00:00
|
|
|
char acct_mgr_url[256];
|
2004-10-06 19:09:37 +00:00
|
|
|
char* project_preferences;
|
|
|
|
int userid;
|
|
|
|
int teamid;
|
|
|
|
int hostid;
|
2003-05-28 22:39:08 +00:00
|
|
|
char user_name[256];
|
|
|
|
char team_name[256];
|
2004-04-23 00:05:16 +00:00
|
|
|
char project_dir[256];
|
2004-04-23 22:51:28 +00:00
|
|
|
char boinc_dir[256];
|
2004-04-23 00:05:16 +00:00
|
|
|
char wu_name[256];
|
2004-04-23 22:51:28 +00:00
|
|
|
char authenticator[256];
|
|
|
|
int slot;
|
2003-05-28 22:39:08 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double host_total_credit;
|
|
|
|
double host_expavg_credit;
|
2006-06-26 17:09:23 +00:00
|
|
|
double resource_share_fraction;
|
2004-06-16 19:21:11 +00:00
|
|
|
HOST_INFO host_info;
|
2006-06-09 02:33:00 +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;
|
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;
|
|
|
|
|
2003-07-15 18:19:29 +00:00
|
|
|
// Items below here are for implementation only
|
2004-04-23 00:05:16 +00:00
|
|
|
// (not used by app developers)
|
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
|
2003-05-28 22:39:08 +00:00
|
|
|
double fraction_done_update_period;
|
2004-05-24 04:03:34 +00:00
|
|
|
// the following 2 are used for compound apps,
|
|
|
|
// where each stage of the computation is a fixed
|
|
|
|
// fraction of the total.
|
|
|
|
double fraction_done_start;
|
|
|
|
double fraction_done_end;
|
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
|
|
|
|
void operator=(const APP_INIT_DATA&);
|
2005-06-16 01:59:33 +00:00
|
|
|
void copy(const APP_INIT_DATA&); // actually do the copy here
|
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"
|
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
|
|
|
|
2005-02-16 23:17:43 +00:00
|
|
|
extern const char* xml_graphics_modes[NGRAPHICS_MSGS];
|
2005-04-28 23:19:58 +00:00
|
|
|
extern int boinc_link(const char* phys_name, const char* logical_name);
|
2006-07-17 20:02:12 +00:00
|
|
|
extern int boinc_resolve_filename(const char*, char*, int len);
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
#endif
|