Commit Graph

1112 Commits

Author SHA1 Message Date
David Anderson a3b2be239f Compile fixes for C++11, from Rene Ladan 2013-11-05 09:19:27 -08:00
Rom Walton 3aaeadaf99 API: On Windows, when BOINC runs under 'boinc_master' and a project application runs under 'boinc_project' the new heartbeat mechanism was failing. OpenProcess would return a NULL handle and set GetLastError() to ERROR_ACCESS_DENIED. Account for that situation instead of claiming the client isn't running and shutting down the project application. 2013-11-05 11:24:24 -05:00
David Anderson e0dd68194e API (Android): workaround for Android bug in per-thread signal masking
Per-thread signal masking doesn't work in Android pre-4.1.
As a result, the SIGALRM signals used by the BOINC runtime system,
which are supposed to be handled by the worker thread,
sometimes are handled by the timer thread.
As a result, suspended apps never resume.
Workaround: in the SIGALRM handler, see if we're the timer thread.
If so, use pthread_kill() to send a SIGALRM to the work thread, and return.
2013-09-10 11:29:34 -07:00
David Anderson 174c90218c API (Android): fix typo 2013-08-07 09:11:45 -07:00
David Anderson 920df081e4 API (Android): check whether the SIGALRM signal is erroneously being handled by the timer thread 2013-08-02 13:43:58 -07:00
David Anderson 9eb232ab08 API (Android) sched_yield() before sleep() in signal handler
Trying to fix bug where timer thread stops doing anything
after first suspend on Android (old, 1-core devices).
I suspect that the sleep() in the worker thread's signal handle
is sleeping the entire process.
Insert a sched_yield() before the sleep so that the time thread will run.
2013-07-30 11:04:09 -07:00
David Anderson e85a18289e client (win): fix typo in last commit 2013-07-30 10:47:54 -07:00
David Anderson b290ad2e5f API: add debug-mode log messages for mutex acquire/release, to help diagnose Android bug 2013-07-25 14:14:16 -07:00
David Anderson dfcf23bea8 API: Win bug fix: need to create mutex initially free 2013-07-09 17:43:19 -07:00
David Anderson 67c20e9fce API: remove logic that makes new app graphics work with version 5 clients. 2013-07-09 16:22:10 -07:00
David Anderson 213d3a65dc API: fix last commit; need a DesiredAccess arg to OpenProcess() 2013-07-09 14:44:13 -07:00
David Anderson 85c845dde6 API: use OpenProcess(), not EnumProcesses(), to see if client is still alive 2013-07-09 14:27:36 -07:00
David Anderson a8485f3d3f Various: Fix some compile warnings; from Gianfranco 2013-07-09 10:34:32 -07:00
David Anderson d461ec37b1 API: compile fix for newer gcc on Unix 2013-07-07 16:35:46 -07:00
David Anderson 519a0bcbef API: add test harness for the runtime system
- If you run the client with --run_test_app,
  runs "test_app" in the current directory and interacts with it
  (and does nothing else).
  It can suspend/resume it with arbitrary timing;
  this is controlled in run_test_app() (app_start.cpp).
- example app: add --critical_section option.
  This lets you test the runtime system for apps that do
  most of their work in a critical section (like GPU apps).
- Add some logging messages (conditioned by DEBUG_BOINC_API)
  to the runtime system.
- boinc_finish() waits for the timer thread to write final messages;
  make sure it doesn't do anything else
  (like suspend the worker thread) during this period
2013-07-04 16:00:10 -07:00
David Anderson ed03f500b2 API: fix synchronization problem that could make apps nonresponsive 2013-07-03 18:08:09 -07:00
David Anderson 7b8bc56da3 Win build fixes 2013-06-06 18:22:51 -07:00
David Anderson 78f7610f6e remove dependency of boinc_api.h on str_replace.h (and hence config.h)
Any files that use strlcpy() or strlcat() must directly include str_replace.h
2013-06-06 17:31:46 -07:00
David Anderson 254d8318e8 Merge branch 'master' of ssh://boinc.berkeley.edu/boinc-v2 2013-06-05 15:42:37 -07:00
David Anderson dc43f0b375 API: tweaks to last commit 2013-06-05 15:42:17 -07:00
David Anderson b98bc309cc API: fix bug involving suspend and critical sections
Old: if the timer thread gets a <suspend> message while we're in
a critical section, it sets a "suspend_request" flag.
The timer then periodically (10X/sec) checks whether
suspend_request is set and we're no longer in a critical section;
if so it suspends the worker thread.

Problem (pointed out by Oliver): this doesn't work if the worker thread
is almost always in a critical section
(as is the case for GPU apps, which treat GPU kernels as critical sections).
The app never gets suspended.

New:
1) boinc_end_critical_section() checks suspend_request;
    if set, it calls suspend_activities()
2) On Unix, if suspend_activities() is called from the worker thread,
    it calls sleep() in a loop until the suspension is over.
    (Note: pthreads has no suspend/resume).
3) Add a mutex to protect the data structures shared between
    the timer and worker threads.

Oliver pointed out that
2013-06-05 15:22:39 -07:00
Rom Walton 8a542f13a8 API: Change some strcat's to strlcats 2013-06-05 12:11:20 -04:00
David Anderson 846b8c7757 all components: change strcpy() to strlcpy() when possible.
This commit should cover the client and manager code.
2013-06-03 20:24:48 -07:00
David Anderson 21248a00f8 API: replace strcpy() with strlcpy() various places 2013-06-03 15:04:20 -07:00
David Anderson f25cf0836a Include <cmath> instead of <math.h> various places 2013-05-27 16:44:22 -07:00
David Anderson 553abb040f API: tweaks 2013-05-21 10:26:15 -07:00
Charlie Fenton 507c82a6d6 OpenCL: remove dead code reported by Heinz-Bernd Eggenstein 2013-03-05 13:43:14 +01:00
Oliver Bock 9bef2edbf0 Merge branch 'master' of ssh://boinc.berkeley.edu/boinc 2013-03-04 17:47:10 +01:00
Charlie Fenton 59e303a57f OpenCL: fix bug reported by Heinz-Bernd Eggenstein 2013-03-04 17:46:44 +01:00
Rom Walton 4b3f9b4cb7 Fix build break for boinc_opencl.cpp and move the include of <vector> below the pre-compiled header file for Windows builds in boinc_api.cpp 2013-03-04 17:45:14 +01:00
Rom Walton 076858a729 LIB: Standardize on using windows_format_error_string and drop windows_error_string.
* Move the windows_format_error_string function to win_util.cpp, .h instead of it being scattered between util.h and str_util.cpp.
* Convert the Windows error string into UTF8 before allowing it to be used by the caller
* Remove windows_error_string from library
2013-03-04 17:39:24 +01:00
David Anderson e393203ff7 - API: improve log messages when detect dead client 2013-03-04 17:24:19 +01:00
David Anderson be553882bd - API: fix Unix bug when checking if client is alive based on PID.
Can't use waitpid() here; works only for children.
    Use kill(pid, 0) instead.
2013-03-04 17:24:19 +01:00
David Anderson 17a4ab8db9 David 11 Dec 2012
- Win process control (affects API and wrapper):
		Since Win doesn't have an API for process suspend/resume,
		we were suspending processes by
			1) enumerating all the threads in the system (typically several thousand)
			2) suspending those belonging to the given process
		The problem: for each thread, the code was calling a function
		in diagnostics_win.cpp to see if the thread was exempted from suspension.
		This check (which is unnecessary anyway if we're suspending another process)
		was surrounded by a semaphore acquire/release.
		The result: performance problems.
		It could take a minute to suspend the threads.
		Solution:
			1) do the check for exemption only if we're suspending threads
				in our own process (i.e. from the API)
			2) if we're suspending multiple processes, enumerate the threads
				only once, and see if each one belongs to any of the processes
			3) have the wrapper elevate itself to normal priority.
				Otherwise it can get preempted for long periods,
				sometimes in the middle of scanning the threads.
		Note: post-9x versions of Win have a process group API that includes suspend/resume.
		We'll switch to this soon.
2013-03-04 17:02:40 +01:00
David Anderson 5ad78a8b9d - client: replace ignore_nvidia_dev etc. with an array.
PRINCIPLE: AVOID PER-GPU-TYPE VARIABLES
- get rid of alloca() stuff in gutil.cpp; almost certainly not needed
- don't include malloc.h; it doesn't exist on BSD systems
2013-03-04 16:44:52 +01:00
Charlie Fenton 6314d1c7ea OpenCL: Change type argument of new boinc_get_opencl_ids() API from char* to int; it now accepts PROC_TYPE_NVIDIA_GPU, PROC_TYPE_AMD_GPU or PROC_TYPE_INTEL_GPU 2013-03-04 15:23:38 +01:00
David Anderson 865d50623e - code formatting 2013-03-04 15:23:38 +01:00
Charlie Fenton ed35d78490 OpenCL: Add a second API for boinc_get_opencl_ids() which is compatible with older clients (before BOINC 7.0.12) 2013-03-04 15:23:38 +01:00
Charlie Fenton e8abd328d1 OpenCL: Add a second API for boinc_get_opencl_ids() which is compatible with older clients (before BOINC 7.0.12) 2013-03-04 15:23:38 +01:00
Charlie Fenton b98fee99b3 OpenCL: Add a second API for boinc_get_opencl_ids() which is compatible with older clients (before BOINC 7.0.12) 2013-03-04 15:23:38 +01:00
Eric J Korpela 6f342d7c8a Another out-of-tree build fix 2013-03-01 16:19:16 +01:00
Rom Walton e3327452e3 - API: Use CloseWindow() to respond to the API Defined WM_SHUTDOWNGFX event just in case CloseWindow() does something more than just send the WM_CLOSE event to the window proc. 2013-03-01 16:03:32 +01:00
Rom Walton d4cf16944e - API: Remove the call to SendMessage(WM_QUIT, ...) after destroying the window.
There is no guarantee what order the event queue will be processed in and if
        WM_QUIT is processed before WM_DESTROY something might linger around.
2013-03-01 15:51:33 +01:00
David Anderson 76282d0a20 - Win compile fixes.
For now, include psapi.lib in various project properties.
		Try to figure out a different way.

svn path=/trunk/boinc/; revision=26149
2012-10-11 19:22:34 +00:00
David Anderson 7d40c46923 - client and API: improve the way an app checks for the death of the client
Old: heartbeat mechanism
    Problem: if the client is blocked for > 30 secs
        (e.g. because it takes a long time to write the state file,
        of because it's stopped in a debugger)
        then apps exit.
        This is bad is the app doesn't checkpoint and has been
        running for a long time.
    New: the client passes its PID to the app.
        The app periodically (10 sec) checks that the process still exists.
    Notes:
    - For backward compatibility (e.g. new API w/ old client,
        or vice versa) the client still sends heartbeats,
        and the API checks heartbeats if the client doesn't pass a PID.
    - The new mechanism works only if the client's PID isn't assigned
        to a new process within 10 secs of the client exiting.
        Windows 2000 reuses PIDs immediately, so check for Win2K
        and don't use this mechanism if so.

TODO: For Unix multithread apps,
    critical sections aren't currently being enforced.
    Need to fix this by masking signals.


svn path=/trunk/boinc/; revision=26147
2012-10-11 16:41:31 +00:00
David Anderson be540c8318 - API: if get a resume message from client while in a critical section,
clear the suspend_request flag.
    Otherwise we'll end up doing two suspends,
    and on Win the app will be suspended forever.


svn path=/trunk/boinc/; revision=26143
2012-09-30 20:30:58 +00:00
David Anderson aa289f0916 - A bunch of tweaks from Steffen Moller, e.g. using MAXPATHLEN
svn path=/trunk/boinc/; revision=26133
2012-09-21 03:52:24 +00:00
David Anderson 9ccb8fa38d - scheduler: add support for limited locality scheduling
- API: remove support for PPM files


svn path=/trunk/boinc/; revision=26062
2012-08-27 17:00:43 +00:00
David Anderson 25c2f6b49c - client: treat all 4xx HTTP errors as permanent
- code cleanup
- API: increase a buffer in timer_handler() from 256 to 512.


svn path=/trunk/boinc/; revision=26012
2012-08-13 18:23:20 +00:00
David Anderson cd1f79fbbc - API: add boinc_set_min_checkpoint_period(int).
Lets application specify a min checkpoint interval.
    The actual min checkpoint interval is the max of this
    and the user-specified pref for min disk interval.


svn path=/trunk/boinc/; revision=26005
2012-08-10 22:20:41 +00:00