Skip to content

Commit

Permalink
Unix priority bug
Browse files Browse the repository at this point in the history
svn path=/trunk/boinc/; revision=9906
  • Loading branch information
davidpanderson committed Apr 14, 2006
1 parent 46f31b4 commit e592ab4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 79 deletions.
59 changes: 5 additions & 54 deletions apps/upper_case.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
// -exit: exit with status -10 (for testing exit handler)
//

// NOTE: this is NOT a sample BOINC application.
// Look in boinc_samples/uppercase for that.
// This is a bare-bones application (no graphics)
// that's used by the test_uc.py script.

#ifdef _WIN32
#include "boinc_win.h"
#else
Expand All @@ -41,13 +46,6 @@
#include <unistd.h>
#endif

#define BOINC_APP_GRAPHICS

#ifdef BOINC_APP_GRAPHICS
#include "boinc_gl.h"
#include "graphics_api.h"
#endif

#include "diagnostics.h"
#include "util.h"
#include "filesys.h"
Expand All @@ -60,12 +58,6 @@ using std::string;
#define INPUT_FILENAME "in"
#define OUTPUT_FILENAME "out"

#ifdef BOINC_APP_GRAPHICS
char display_buf[10];
double xPos=0, yPos=0;
double xDelta=0.03, yDelta=0.07;
#endif

bool run_slow;
bool raise_signal;
bool random_exit;
Expand Down Expand Up @@ -160,9 +152,6 @@ void worker() {
c = fgetc(in);

if (c == EOF) break;
#ifdef BOINC_APP_GRAPHICS
sprintf(display_buf, "%c -> %c", c, toupper(c));
#endif
c = toupper(c);
out._putchar(c);
nchars++;
Expand Down Expand Up @@ -236,47 +225,9 @@ int main(int argc, char **argv) {

fprintf(stderr, "APP: upper_case: starting, argc %d\n", argc);

#ifdef BOINC_APP_GRAPHICS
strcpy(display_buf, "(none)\0");
retval = boinc_init_graphics(worker);
if (retval) exit(retval);
#else
retval = boinc_init();
if (retval) exit(retval);
worker();
#endif
}

#ifdef BOINC_APP_GRAPHICS
extern GLuint main_font;

void app_init_gl() {}

bool app_render(int xs, int ys, double time_of_day) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glColor3f(1,1,1);

glRasterPos2f(xPos, yPos);
//glPrint(main_font, display_buf);

xPos += xDelta;
yPos += yDelta;
if (xPos < -1 || xPos > 1) xDelta *= -1;
if (yPos < -1 || yPos > 1) yDelta *= -1;

glRasterPos2f(-0.9, 0.9);
//glPrint(main_font, "User: %s", uc_aid.user_name);

glRasterPos2f(-0.9, 0.8);
//glPrint(main_font, "Team: %s", uc_aid.team_name);

glRasterPos2f(-0.9, 0.7);
//glPrint(main_font, "CPU Time: %f", uc_aid.wu_cpu_time);

return true; // Everything Went OK
}

#endif

const char *BOINC_RCSID_33ac47a071 = "$Id$";
16 changes: 16 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -3835,3 +3835,19 @@ Charlie 14 Apr 2006
clientgui/
BOINCGUIApp.cpp
MainFrame.cpp, .h

David 14 Apr 2006
- Core client: change the way that application priority is set on Unix
Old: fork/exec app, then setpriority(pid)
PROBLEM: race condition. When the app starts,
it's initially at regular priority.
If it immediately creates another process,
the child process has regular priority
(and continues to even after the app's priority is lowered).
New: fork, lower priority, exec.
(From Mike Fleetwood)

apps/
upper_case.C
client/
app_start.C
13 changes: 6 additions & 7 deletions client/app_start.C
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@ int ACTIVE_TASK::start(bool first_time) {
//
freopen(STDERR_FILE, "a", stderr);

// set idle process priority
#ifdef HAVE_SETPRIORITY
if (setpriority(PRIO_PROCESS, 0, PROCESS_IDLE_PRIORITY)) {
perror("setpriority");
}
#endif
argv[0] = exec_name;
char cmdline[8192];
strcpy(cmdline, wup->command_line.c_str());
Expand All @@ -556,13 +562,6 @@ int ACTIVE_TASK::start(bool first_time) {

scope_messages.printf("ACTIVE_TASK::start(): forked process: pid %d\n", pid);

// set idle process priority
#ifdef HAVE_SETPRIORITY
if (setpriority(PRIO_PROCESS, pid, PROCESS_IDLE_PRIORITY)) {
perror("setpriority");
}
#endif

#endif
task_state = PROCESS_EXECUTING;
return 0;
Expand Down
15 changes: 15 additions & 0 deletions doc/boinc_news.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<?

$project_news = array(
array("April 13, 2006",
"According to various <a href=links.php>statistics sites</a>,
over one million computers have now contributed
processing power to BOINC projects.
We're currently achieving a sustained processing rate
of over 400 TeraFLOPS - the world's most powerful supercomputer
by a wide margin.
Congratulations and thanks to everyone!
"),
array("April 13, 2006",
"We have developed an <a href=example.php>example application</a>,
together with project files and Makefiles for Windows, Mac, and Linux.
The application demonstrates how to do checkpoint/restart and graphics.
Projects can use this as a framework for building their own applications.
"),
array("April 6, 2006",
"Thanks to the efforts of
<a href=http://alioth.debian.org/projects/pkg-boinc/>volunteers</a>,
Expand Down
2 changes: 1 addition & 1 deletion doc/create_project.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
</ul>
<li> Application development
<ul>
<li><a href=example.php>Example application</a>
<li><a href=app_dev.php>Application development tips</a>
<li> <a href=app_debug.php>Application debugging</a>
<li><a href=myers.txt>App development cookbook</a> (courtesy of Eric Myers from Vassar)
</ul>
<li><a href=fortran.php>FORTRAN applications</a>
<li><a href=compound_app.php>Compound applications</a>
Expand Down
43 changes: 26 additions & 17 deletions doc/source_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@
page_head("Getting source code");
echo "
<p>
You will need certain
<a href=build.php>software prerequisites</a>
before compiling BOINC.
<h2>CVS repositories</h2>
The BOINC source code is maintained two CVS modules:
<ul>
<li><b>boinc</b> contains the source code for all parts of BOINC itself
(client, server, web, database).
<li><b>boinc_samples</b> contains a sample BOINC application, <b>upper_case</b>,
together with Windows and Mac project files and a Linux makefile
for building the application.
It also includes some bits of code (GLUT, jpeglib, etc.)
that many applications will need, but which are not part of BOINC.
</ul>
If you are developing an application,
you should check out these modules in the same parent directory.
<h2>CVS branches</h2>
<h2>CVS tags</h2>
<p>
The BOINC source code is maintained in CVS.
The trunk is the development version,
which may not compile or run.
In the <b>boinc</b> module,
the trunk is the development version;
it may not compile or run.
Other versions are tagged as follows:
<dl>
<dt>
Expand Down Expand Up @@ -51,16 +62,14 @@
to get the stable version.
<p>
<li>
Browse the CVS repository via a
<a href=http://boinc.berkeley.edu/cgi-bin/cvsweb.cgi/boinc/>web-based interface</a>
(this is useful for getting individual files,
or seeing the revision history).
Browse the
<a href=http://boinc.berkeley.edu/cgi-bin/cvsweb.cgi/boinc/>boinc</a>
or
<a href=http://setiathome.berkeley.edu/cgi-bin/cvsweb.cgi/boinc_samples/>boinc_samples</a> modules
via a web-based interface.
This is useful for getting individual files, or seeing the revision history.
</ul>
<p>
The BOINC source code is about 20-25 Mbytes.
<p>
Source code for a typical BOINC application,
SETI@home, is <a href=http://setiweb.ssl.berkeley.edu/sah/sah_porting.php>here</a>.
";

Expand Down

0 comments on commit e592ab4

Please sign in to comment.