summaryrefslogtreecommitdiff
path: root/wscript
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2018-06-20 13:38:19 +0200
committerRalph Boehme <slow@samba.org>2018-07-24 17:38:26 +0200
commit9656b8d8ee11ee351870286f16ea8fbe49112292 (patch)
tree9d34ab462c202fe2622b33864ddda45df34c8aca /wscript
parent5fa5764f30c47b46f12ceb7637985e8def0190ca (diff)
downloadsamba-9656b8d8ee11ee351870286f16ea8fbe49112292.tar.gz
pthreadpool: add some lockless coordination between the main and job threads
In the direction from the main process to the job thread, we have: - 'maycancel', which is set when tevent_req_cancel() is called, - 'orphaned' is the job request, tevent_context or pthreadpool_tevent was talloc_free'ed. The job function can consume these by using: /* * return true - if tevent_req_cancel() was called. */ bool pthreadpool_tevent_current_job_canceled(void); /* * return true - if talloc_free() was called on the job request, * tevent_context or pthreadpool_tevent. */ bool pthreadpool_tevent_current_job_orphaned(void); /* * return true if canceled and orphaned are both false. */ bool pthreadpool_tevent_current_job_continue(void); In the other direction we remember the following points in the job execution: - 'started' - set when the job is picked up by a worker thread - 'executed' - set once the job function returned. - 'finished' - set when pthreadpool_tevent_job_signal() is entered - 'dropped' - set when pthreadpool_tevent_job_signal() leaves with orphaned - 'signaled' - set when pthreadpool_tevent_job_signal() leaves normal There're only one side writing each element, either the main process or the job thread. This means we can do the coordination with a full memory barrier using atomic_thread_fence(memory_order_seq_cst). lib/replace provides fallbacks if C11 stdatomic.h is not available. A real pthreadpool requires pthread and atomic_thread_fence() (or an replacement) to be available, otherwise we only have pthreadpool_sync.c. But this should not make a real difference, as at least __sync_synchronize() is availabe since 2005 in gcc. We also require __thread which is available since 2002. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'wscript')
-rw-r--r--wscript12
1 files changed, 10 insertions, 2 deletions
diff --git a/wscript b/wscript
index 19fc6d12118..f11c49dde67 100644
--- a/wscript
+++ b/wscript
@@ -259,10 +259,18 @@ def configure(conf):
conf.DEFINE('WITH_NTVFS_FILESERVER', 1)
if Options.options.with_pthreadpool:
- if conf.CONFIG_SET('HAVE_PTHREAD'):
+ if conf.CONFIG_SET('HAVE_PTHREAD') and \
+ conf.CONFIG_SET('HAVE___THREAD') and \
+ conf.CONFIG_SET('HAVE_ATOMIC_THREAD_FENCE_SUPPORT'):
conf.DEFINE('WITH_PTHREADPOOL', '1')
else:
- Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
+ if not conf.CONFIG_SET('HAVE_PTHREAD'):
+ Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
+ if not conf.CONFIG_SET('HAVE_ATOMIC_THREAD_FENCE_SUPPORT'):
+ Logs.warn("""pthreadpool support cannot be enabled when there is
+ no support for atomic_thead_fence()""")
+ if not conf.CONFIG_SET('HAVE___THREAD'):
+ Logs.warn("pthreadpool support cannot be enabled when __thread support was not found")
conf.undefine('WITH_PTHREADPOOL')
conf.RECURSE('source3')