Skip to content
Snippets Groups Projects
Select Git revision
  • 3a47d683aaf70a11affe9dd5031342f2d42b3316
  • master default protected
  • antenna-patterns
  • qt5-qopenglwidget
  • license-demo
  • isolated
  • isolated-fixedprofile
  • release_1.1
  • press-conference
  • rim-only
  • release_1.0
11 results

main.cpp

Blame
  • boinc_api.cpp 39.20 KiB
    // This file is part of BOINC.
    // http://boinc.berkeley.edu
    // Copyright (C) 2008 University of California
    //
    // BOINC 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 3 of the License, or (at your option) any later version.
    //
    // BOINC 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.
    //
    // You should have received a copy of the GNU Lesser General Public License
    // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
    
    // The BOINC API and runtime system.
    //
    // Notes:
    // 1) Thread structure:
    //  Sequential apps
    //    Unix
    //      getting CPU time and suspend/resume have to be done
    //      in the worker thread, so we use a SIGALRM signal handler.
    //      However, many library functions and system calls
    //      are not "asynch signal safe": see, e.g.
    //      http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
    //      (e.g. sprintf() in a signal handler hangs Mac OS X)
    //      so we do as little as possible in the signal handler,
    //      and do the rest in a separate "timer thread".
    //    Win
    //      the timer thread does everything
    //  Parallel apps.
    //    Unix:
    //      fork
    //      original process runs timer loop:
    //        handle suspend/resume/quit, heartbeat (use signals)
    //      new process call boinc_init_options() with flags to
    //        send status messages and handle checkpoint stuff,
    //        and returns from boinc_init_parallel()
    //    Win:
    //      like sequential case, except suspend/resume must enumerate
    //      all threads (except timer) and suspend/resume them all
    //
    // 2) All variables that are accessed by two threads (i.e. worker and timer)
    //  MUST be declared volatile.
    //
    // 3) For compatibility with C, we use int instead of bool various places
    //
    // Terminology:
    // The processing of a result can be divided
    // into multiple "episodes" (executions of the app),
    // each of which resumes from the checkpointed state of the previous episode.
    // Unless otherwise noted, "CPU time" refers to the sum over all episodes
    // (not counting the part after the last checkpoint in an episode).
    
    #if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_)
    #include "boinc_win.h"
    #endif
    
    #ifdef _WIN32
    #include "version.h"
    #include "win_util.h"
    #else
    #include "config.h"
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <cstdarg>