2003-05-07 23:42:17 +00:00
|
|
|
#ifndef _APP_IPC_
|
|
|
|
#define _APP_IPC_
|
|
|
|
|
|
|
|
// Communication between the core client and the BOINC app library.
|
|
|
|
// This code is linked into both core client and app lib.
|
|
|
|
// Includes the following:
|
|
|
|
// - shared memory (APP_CLIENT_SHM)
|
|
|
|
// - main init file
|
|
|
|
// - fd init file
|
|
|
|
// - graphics init file
|
|
|
|
|
|
|
|
// Shared memory is arranged as follows:
|
|
|
|
// 4 1K segments
|
|
|
|
// First byte of each segment is nonzero if
|
|
|
|
// segment contains unread data, remaining 1023
|
|
|
|
// bytes contain data
|
|
|
|
|
|
|
|
#define SHM_SEG_SIZE 1024
|
2003-05-28 22:39:08 +00:00
|
|
|
#define NUM_SEGS 4
|
|
|
|
#define CORE_APP_WORKER_SEG 0
|
|
|
|
#define APP_CORE_WORKER_SEG 1
|
|
|
|
#define CORE_APP_GFX_SEG 2
|
|
|
|
#define APP_CORE_GFX_SEG 3
|
|
|
|
#define APP_CLIENT_SHMEM_SIZE (sizeof(char)*NUM_SEGS*SHM_SEG_SIZE)
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
class APP_CLIENT_SHM {
|
|
|
|
public:
|
|
|
|
char *shm;
|
|
|
|
|
|
|
|
bool pending_msg(int); // returns true a message is waiting
|
|
|
|
// in the specified segment
|
2003-05-09 20:33:57 +00:00
|
|
|
bool get_msg(char *,int); // returns the message from the specified
|
2003-05-07 23:42:17 +00:00
|
|
|
// segment and resets the message flag
|
2003-05-09 20:33:57 +00:00
|
|
|
bool send_msg(char *,int); // if there is not already a message in the segment,
|
2003-05-07 23:42:17 +00:00
|
|
|
// writes specified message and sets message flag
|
2003-05-09 20:33:57 +00:00
|
|
|
bool send_graphics_mode_msg(int seg, int mode);
|
|
|
|
bool get_graphics_mode_msg(int seg, int& mode);
|
|
|
|
void reset_msgs(); // resets all messages and clears their flags
|
|
|
|
void reset_msg(int); // resets specified message and clears its flag
|
2003-05-07 23:42:17 +00:00
|
|
|
};
|
|
|
|
|
2003-05-28 22:39:08 +00:00
|
|
|
struct APP_INIT_DATA {
|
|
|
|
char app_preferences[4096];
|
|
|
|
char user_name[256];
|
|
|
|
char team_name[256];
|
|
|
|
char comm_obj_name[256]; // name to identify shared memory segments, signals, etc
|
2003-06-06 22:08:46 +00:00
|
|
|
double wu_cpu_time; // cpu time from previous sessions
|
2003-05-28 22:39:08 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double host_total_credit;
|
|
|
|
double host_expavg_credit;
|
|
|
|
double checkpoint_period; // recommended checkpoint period
|
|
|
|
int shm_key;
|
|
|
|
double fraction_done_update_period;
|
|
|
|
};
|
|
|
|
|
|
|
|
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_fd_init_file(FILE*, char*, int, int);
|
|
|
|
int parse_fd_init_file(FILE*);
|
|
|
|
int write_graphics_file(FILE* f, GRAPHICS_INFO* gi);
|
|
|
|
int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi);
|
|
|
|
|
|
|
|
#define INIT_DATA_FILE "init_data.xml"
|
|
|
|
#define GRAPHICS_DATA_FILE "graphics.xml"
|
|
|
|
#define FD_INIT_FILE "fd_init.xml"
|
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
// possible graphics modes of an application
|
|
|
|
//
|
2003-05-07 23:42:17 +00:00
|
|
|
#define MODE_UNSUPPORTED 0
|
|
|
|
#define MODE_HIDE_GRAPHICS 1
|
|
|
|
#define MODE_WINDOW 2
|
|
|
|
#define MODE_FULLSCREEN 3
|
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
#define END_SS_MSG "BOINC_SS_END"
|
2003-05-09 00:00:39 +00:00
|
|
|
|
2003-05-28 22:39:08 +00:00
|
|
|
#define STDERR_FILE "stderr.txt"
|
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
extern char* xml_graphics_modes[5];
|
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
#endif
|