mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=2287
This commit is contained in:
parent
662e8ffa43
commit
54957d4f58
|
@ -6206,3 +6206,12 @@ Karl 2003/09/05
|
||||||
|
|
||||||
Sched/
|
Sched/
|
||||||
handle_request.C
|
handle_request.C
|
||||||
|
|
||||||
|
David Sept 6 2003
|
||||||
|
- fixed bug where do_select wasn't sleeping
|
||||||
|
when there are no fds (doh!!)
|
||||||
|
|
||||||
|
client/
|
||||||
|
net_xfer.C,h
|
||||||
|
lib/
|
||||||
|
util.C
|
||||||
|
|
|
@ -296,13 +296,11 @@ int NET_XFER_SET::remove(NET_XFER* nxp) {
|
||||||
bool NET_XFER_SET::poll() {
|
bool NET_XFER_SET::poll() {
|
||||||
double bytes_xferred;
|
double bytes_xferred;
|
||||||
int retval;
|
int retval;
|
||||||
struct timeval timeout;
|
|
||||||
time_t t = time(0);
|
time_t t = time(0);
|
||||||
bool action = false;
|
bool action = false;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
timeout.tv_sec = timeout.tv_usec = 0;
|
retval = do_select(bytes_xferred, 0);
|
||||||
retval = do_select(bytes_xferred, timeout);
|
|
||||||
if (retval) break;
|
if (retval) break;
|
||||||
if (bytes_xferred == 0) break;
|
if (bytes_xferred == 0) break;
|
||||||
action = true;
|
action = true;
|
||||||
|
@ -311,6 +309,11 @@ bool NET_XFER_SET::poll() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void double_to_timeval(double x, timeval& t) {
|
||||||
|
t.tv_sec = (int)x;
|
||||||
|
t.tv_usec = (int)(1000000*(x - (int)x));
|
||||||
|
}
|
||||||
|
|
||||||
// Wait at most x seconds for network I/O to become possible,
|
// Wait at most x seconds for network I/O to become possible,
|
||||||
// then do up to about .5 seconds of I/O.
|
// then do up to about .5 seconds of I/O.
|
||||||
// This is used only by the cmdline client, to sleep without slowing down I/O.
|
// This is used only by the cmdline client, to sleep without slowing down I/O.
|
||||||
|
@ -318,11 +321,8 @@ bool NET_XFER_SET::poll() {
|
||||||
int NET_XFER_SET::net_sleep(double x) {
|
int NET_XFER_SET::net_sleep(double x) {
|
||||||
int retval;
|
int retval;
|
||||||
double bytes_xferred;
|
double bytes_xferred;
|
||||||
struct timeval timeout;
|
|
||||||
|
|
||||||
timeout.tv_sec = (int)x;
|
retval = do_select(bytes_xferred, x);
|
||||||
timeout.tv_usec = (int)(1000000*(x - (int)x));
|
|
||||||
retval = do_select(bytes_xferred, timeout);
|
|
||||||
if (retval) return retval;
|
if (retval) return retval;
|
||||||
if (bytes_xferred) {
|
if (bytes_xferred) {
|
||||||
return poll();
|
return poll();
|
||||||
|
@ -334,10 +334,11 @@ int NET_XFER_SET::net_sleep(double x) {
|
||||||
// then do I/O on as many sockets as possible, subject to rate limits
|
// then do I/O on as many sockets as possible, subject to rate limits
|
||||||
// Transfer at most one block per socket.
|
// Transfer at most one block per socket.
|
||||||
//
|
//
|
||||||
int NET_XFER_SET::do_select(double& bytes_transferred, timeval& timeout) {
|
int NET_XFER_SET::do_select(double& bytes_transferred, double timeout) {
|
||||||
int n, fd, retval, nsocks_queried;
|
int n, fd, retval, nsocks_queried;
|
||||||
socklen_t i;
|
socklen_t i;
|
||||||
NET_XFER *nxp;
|
NET_XFER *nxp;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
ScopeMessages scope_messages(log_messages, ClientMessages::DEBUG_NET_XFER);
|
ScopeMessages scope_messages(log_messages, ClientMessages::DEBUG_NET_XFER);
|
||||||
|
|
||||||
|
@ -387,8 +388,13 @@ int NET_XFER_SET::do_select(double& bytes_transferred, timeval& timeout) {
|
||||||
}
|
}
|
||||||
FD_SET(nxp->socket, &error_fds);
|
FD_SET(nxp->socket, &error_fds);
|
||||||
}
|
}
|
||||||
if (nsocks_queried==0) return 0;
|
if (nsocks_queried==0) {
|
||||||
n = select(FD_SETSIZE, &read_fds, &write_fds, &error_fds, &timeout);
|
boinc_sleep(timeout);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double_to_timeval(timeout, tv);
|
||||||
|
n = select(FD_SETSIZE, &read_fds, &write_fds, &error_fds, &tv);
|
||||||
scope_messages.printf(
|
scope_messages.printf(
|
||||||
"NET_XFER_SET::do_select(): queried %d, returned %d\n",
|
"NET_XFER_SET::do_select(): queried %d, returned %d\n",
|
||||||
nsocks_queried, n
|
nsocks_queried, n
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
int remove(NET_XFER*);
|
int remove(NET_XFER*);
|
||||||
bool poll();
|
bool poll();
|
||||||
int net_sleep(double);
|
int net_sleep(double);
|
||||||
int do_select(double& bytes_transferred, struct timeval& timeout);
|
int do_select(double& bytes_transferred, double timeout);
|
||||||
NET_XFER* lookup_fd(int); // lookup by fd
|
NET_XFER* lookup_fd(int); // lookup by fd
|
||||||
void check_active(bool&, bool&);
|
void check_active(bool&, bool&);
|
||||||
};
|
};
|
||||||
|
|
20
doc/api.php
20
doc/api.php
|
@ -35,7 +35,6 @@ For example, instead of
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
the application might use
|
the application might use
|
||||||
<p>
|
|
||||||
<pre>
|
<pre>
|
||||||
char resolved_name[256];
|
char resolved_name[256];
|
||||||
retval = boinc_resolve_filename(\"my_file\", resolved_name);
|
retval = boinc_resolve_filename(\"my_file\", resolved_name);
|
||||||
|
@ -70,8 +69,16 @@ then call
|
||||||
<pre>
|
<pre>
|
||||||
void boinc_checkpoint_completed();
|
void boinc_checkpoint_completed();
|
||||||
</pre>
|
</pre>
|
||||||
A call to <tt>boinc_time_to_checkpoint()</tt> is extremely fast,
|
<tt>boinc_time_to_checkpoint()</tt> is fast
|
||||||
so there is little penalty in calling it frequently.
|
(it usually makes no system calls),
|
||||||
|
so can be called frequently (hundreds or thousands of times a second).
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<tt>boinc_time_to_checkpoint()</tt> performs other time-based functions;
|
||||||
|
e.g. it periodically measures the application's CPU time and
|
||||||
|
reports it to the core client.
|
||||||
|
So, even for applications that don't do checkpointing,
|
||||||
|
it should be called at least once a second.
|
||||||
|
|
||||||
<h3>Atomic file update</h3>
|
<h3>Atomic file update</h3>
|
||||||
<p>
|
<p>
|
||||||
|
@ -111,14 +118,13 @@ This is done using
|
||||||
<h3>Communicating with the core client</h3>
|
<h3>Communicating with the core client</h3>
|
||||||
<p>
|
<p>
|
||||||
The core client GUI displays the percent done of workunits in progress.
|
The core client GUI displays the percent done of workunits in progress.
|
||||||
To keep this display current, an application should
|
To keep this display current, an application should periodically call
|
||||||
periodically call
|
|
||||||
<pre>
|
<pre>
|
||||||
boinc_fraction_done(double fraction_done);
|
boinc_fraction_done(double fraction_done);
|
||||||
</pre>
|
</pre>
|
||||||
The <tt>fraction_done</tt> argument is a rough estimate of the
|
The <tt>fraction_done</tt> argument is a rough estimate of the
|
||||||
workunit fraction complete (0 to 1).
|
workunit fraction complete (0 to 1).
|
||||||
This function is extremely fast and can be called often.
|
This function is fast and can be called frequently.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The following functions get information from the core client;
|
The following functions get information from the core client;
|
||||||
|
@ -150,7 +156,7 @@ list_item("team_expavg_credit", " team's recent average work per day.");
|
||||||
list_end();
|
list_end();
|
||||||
echo "
|
echo "
|
||||||
<p>
|
<p>
|
||||||
It may call
|
An application may call
|
||||||
<pre>
|
<pre>
|
||||||
int boinc_cpu_time(double &cpu_time, double& working_set_size);
|
int boinc_cpu_time(double &cpu_time, double& working_set_size);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -175,7 +175,8 @@ void boinc_sleep(double seconds) {
|
||||||
::Sleep((int)(1000*seconds));
|
::Sleep((int)(1000*seconds));
|
||||||
#else
|
#else
|
||||||
sleep((int)seconds);
|
sleep((int)seconds);
|
||||||
usleep((int)fmod(seconds*1000000,1000000));
|
int x = (int)fmod(seconds*1000000,1000000);
|
||||||
|
if (x) usleep(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue