2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-10-29 11:05:39 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-10-29 11:05:39 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
#ifndef _APP_IPC_
|
|
|
|
#define _APP_IPC_
|
|
|
|
|
2004-06-16 19:21:11 +00:00
|
|
|
#include "hostinfo.h"
|
|
|
|
|
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
|
|
|
|
|
|
|
// Shared memory is arranged as follows:
|
|
|
|
// 4 1K segments
|
|
|
|
// First byte of each segment is nonzero if
|
2004-06-29 01:15:51 +00:00
|
|
|
// segment contains unread data.
|
|
|
|
// 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.
|
|
|
|
//
|
2003-05-07 23:42:17 +00:00
|
|
|
|
|
|
|
#define SHM_SEG_SIZE 1024
|
2004-06-29 01:15:51 +00:00
|
|
|
#define NUM_SEGS 6
|
2004-06-17 21:37:59 +00:00
|
|
|
|
|
|
|
// The following 2 segs are used by the timer interrupt handler
|
2004-06-29 01:15:51 +00:00
|
|
|
// in the worker program
|
|
|
|
//
|
2003-05-28 22:39:08 +00:00
|
|
|
#define CORE_APP_WORKER_SEG 0
|
2004-06-29 01:15:51 +00:00
|
|
|
// <heartbeat/> sent every second, even while app is suspended
|
|
|
|
// <disable_heartbeat/> disables heartbeat mechanism
|
|
|
|
// <enable_heartbeat/> enable heartbeat mechanism (default)
|
|
|
|
// <have_new_trickle_down/> a new trickle-down message is available
|
2003-05-28 22:39:08 +00:00
|
|
|
#define APP_CORE_WORKER_SEG 1
|
2004-06-29 01:15:51 +00:00
|
|
|
// status message every second, of the form
|
2004-06-17 21:37:59 +00:00
|
|
|
// <current_cpu_time>...
|
|
|
|
// <checkpoint_cpu_time>...
|
|
|
|
// <working_set_size>...
|
|
|
|
// <fraction_done> ...
|
|
|
|
// [ <have_new_trickle_up/> ]
|
|
|
|
|
|
|
|
// The following 2 segs are used by the graphics thread
|
2004-06-29 01:15:51 +00:00
|
|
|
// in the worker program
|
|
|
|
//
|
2003-05-28 22:39:08 +00:00
|
|
|
#define CORE_APP_GFX_SEG 2
|
2004-06-17 21:37:59 +00:00
|
|
|
// request a graphics mode:
|
|
|
|
// <mode_hide_graphics/>
|
|
|
|
// ...
|
|
|
|
// <mode_blankscreen/>
|
2003-05-28 22:39:08 +00:00
|
|
|
#define APP_CORE_GFX_SEG 3
|
2004-06-17 21:37:59 +00:00
|
|
|
// acknowledge graphics mode
|
|
|
|
// same msgs as above
|
|
|
|
|
2004-06-29 01:15:51 +00:00
|
|
|
// The following 2 segs are used by the coordinator program
|
|
|
|
// NOT IMPLEMENTED, here as a placeholder
|
|
|
|
//
|
|
|
|
#define CORE_APP_COORD_SEG 4
|
|
|
|
// control commands:
|
|
|
|
// <quit/>
|
|
|
|
// <suspend/>
|
|
|
|
// <resume/>
|
|
|
|
#define APP_CORE_COORD_SEG 5
|
|
|
|
// acknowledge control commands
|
|
|
|
// same msgs as above
|
|
|
|
|
2003-05-28 22:39:08 +00:00
|
|
|
#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
|
|
|
|
2003-10-30 23:23:52 +00:00
|
|
|
// graphics modes of an application
|
|
|
|
//
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define NGRAPHICS_MODES 5
|
2003-10-30 23:23:52 +00:00
|
|
|
|
|
|
|
// graphics messages
|
|
|
|
//
|
|
|
|
#define GRAPHICS_MSG_SET_MODE 1
|
|
|
|
#define GRAPHICS_MSG_REREAD_PREFS 2
|
|
|
|
|
2004-06-16 10:01:28 +00:00
|
|
|
#include <cstdio>
|
2003-10-30 23:23:52 +00:00
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
class APP_CLIENT_SHM {
|
|
|
|
public:
|
|
|
|
char *shm;
|
|
|
|
|
2003-09-27 17:53:43 +00:00
|
|
|
bool pending_msg(int); // returns true if a message is waiting
|
2003-05-07 23:42:17 +00:00
|
|
|
// in the specified segment
|
2003-09-27 17:53:43 +00:00
|
|
|
bool get_msg(char*, int); // returns the message from the specified
|
|
|
|
// segment and clears pending flag
|
|
|
|
bool send_msg(char*, int); // if there is not a message in the segment,
|
|
|
|
// writes specified message and sets pending flag
|
2003-10-30 23:23:52 +00:00
|
|
|
bool send_graphics_msg(int seg, int msg, int mode);
|
|
|
|
bool get_graphics_msg(int seg, int& msg, int& mode);
|
2003-05-09 20:33:57 +00:00
|
|
|
void reset_msgs(); // resets all messages and clears their flags
|
|
|
|
void reset_msg(int); // resets specified message and clears its flag
|
2004-02-09 05:11:05 +00:00
|
|
|
|
|
|
|
APP_CLIENT_SHM();
|
2003-05-07 23:42:17 +00:00
|
|
|
};
|
|
|
|
|
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 {
|
2003-09-27 17:53:43 +00:00
|
|
|
char app_name[256];
|
2004-07-02 05:06:30 +00:00
|
|
|
char project_preferences[65536];
|
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;
|
2004-06-16 19:21:11 +00:00
|
|
|
HOST_INFO host_info;
|
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-03-26 18:32:57 +00:00
|
|
|
#ifdef _WIN32
|
2003-09-27 17:53:43 +00:00
|
|
|
char comm_obj_name[256]; // identifies shared memory segments, signals, etc
|
2004-03-26 18:32:57 +00:00
|
|
|
#else
|
|
|
|
int shm_key;
|
|
|
|
#endif
|
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;
|
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&);
|
2003-09-27 17:53:43 +00:00
|
|
|
int write_fd_init_file(FILE*, char*, int, bool);
|
2003-05-07 23:42:17 +00:00
|
|
|
int parse_fd_init_file(FILE*);
|
|
|
|
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"
|
|
|
|
#define GRAPHICS_DATA_FILE "graphics.xml"
|
|
|
|
#define FD_INIT_FILE "fd_init.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"
|
2003-05-28 22:39:08 +00:00
|
|
|
|
2004-01-08 00:27:59 +00:00
|
|
|
extern char* xml_graphics_modes[NGRAPHICS_MODES];
|
2003-10-29 11:05:39 +00:00
|
|
|
int boinc_link(const char* existing, const char* new_link);
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2003-05-08 18:11:05 +00:00
|
|
|
#endif
|