2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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-03-08 00:09:40 +00:00
|
|
|
|
2003-07-02 02:02:18 +00:00
|
|
|
#ifndef SCHED_UTIL_H
|
|
|
|
#define SCHED_UTIL_H
|
2003-03-08 00:09:40 +00:00
|
|
|
|
2005-02-23 00:11:59 +00:00
|
|
|
#include "boinc_db.h"
|
|
|
|
|
2003-03-08 00:09:40 +00:00
|
|
|
// "average credit" uses an exponential decay so that recent
|
|
|
|
// activity is weighted more heavily.
|
2004-04-07 06:51:42 +00:00
|
|
|
// CREDIT_HALF_LIFE is the "half-life" period:
|
2003-08-12 20:58:24 +00:00
|
|
|
// the average decreases by 1/2 if idle for this period.
|
|
|
|
//
|
2003-03-08 00:09:40 +00:00
|
|
|
#define SECONDS_IN_DAY (3600*24)
|
2004-04-07 06:51:42 +00:00
|
|
|
#define CREDIT_HALF_LIFE (SECONDS_IN_DAY*7)
|
2003-03-08 00:09:40 +00:00
|
|
|
|
2006-06-09 19:07:34 +00:00
|
|
|
// Historical note: named after Jeff Cobb
|
|
|
|
//
|
|
|
|
#define COBBLESTONE_FACTOR 100.0
|
|
|
|
|
2003-06-20 01:31:03 +00:00
|
|
|
extern void write_pid_file(const char* filename);
|
2003-06-11 23:36:40 +00:00
|
|
|
extern void set_debug_level(int);
|
2004-05-03 19:30:01 +00:00
|
|
|
extern void check_stop_daemons();
|
|
|
|
extern bool check_stop_sched();
|
2003-12-31 23:09:21 +00:00
|
|
|
extern void install_stop_signal_handler();
|
2005-02-16 23:17:43 +00:00
|
|
|
extern int try_fopen(const char* path, FILE*& f, const char* mode);
|
|
|
|
extern void get_log_path(char*, const char*);
|
2003-03-08 00:09:40 +00:00
|
|
|
|
2005-01-08 06:54:03 +00:00
|
|
|
// convert filename to path in a hierarchical directory system
|
|
|
|
//
|
|
|
|
extern int dir_hier_path(
|
2005-09-23 21:09:00 +00:00
|
|
|
const char* filename, const char* root, int fanout,
|
2005-01-08 06:54:03 +00:00
|
|
|
char* result, bool create=false
|
|
|
|
);
|
|
|
|
|
|
|
|
// convert filename to URL in a hierarchical directory system
|
|
|
|
//
|
|
|
|
extern int dir_hier_url(
|
2005-09-23 21:09:00 +00:00
|
|
|
const char* filename, const char* root, int fanout,
|
2005-01-08 06:54:03 +00:00
|
|
|
char* result
|
|
|
|
);
|
|
|
|
|
2005-02-10 06:21:58 +00:00
|
|
|
// extract filename from result name, needed for locality scheduling.
|
|
|
|
//
|
|
|
|
extern int extract_filename(char* in, char* out);
|
|
|
|
|
2005-02-23 00:11:59 +00:00
|
|
|
extern void compute_avg_turnaround(HOST& host, double turnaround);
|
|
|
|
|
2005-05-04 16:31:25 +00:00
|
|
|
// used to track execution time of cgi scripts
|
2005-09-15 15:07:41 +00:00
|
|
|
extern double elapsed_wallclock_time();
|
2005-05-04 16:31:25 +00:00
|
|
|
|
2005-05-17 21:08:48 +00:00
|
|
|
// returns zero if we get lock on file with file descriptor fd.
|
|
|
|
// returns < 0 if error
|
|
|
|
// returns PID > 0 if another process has lock
|
|
|
|
//
|
|
|
|
extern int mylockf(int fd);
|
|
|
|
|
2006-06-09 19:07:34 +00:00
|
|
|
// Returns credit that should be granted for a given number of
|
|
|
|
// floating-point and integer ops
|
|
|
|
//
|
|
|
|
extern double fpops_to_credit(double fpops, double intops);
|
|
|
|
|
2007-06-20 16:27:27 +00:00
|
|
|
extern int count_unsent_results(int&, int appid);
|
|
|
|
extern int count_workunits(int&, const char* query);
|
2005-05-04 16:31:25 +00:00
|
|
|
|
2003-03-08 00:09:40 +00:00
|
|
|
#endif
|