diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-11-15 09:27:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-11-15 09:28:12 -0500 |
commit | 8b91680d5c57fc35275b32aea57555d8ef7d61ba (patch) | |
tree | 5040bae10d88ba7810d5c9b5517e1e355a080f11 /src/lib/thread/threading.md | |
parent | 3a7369d0cfa567cdb02063e1dad176c92ef2c7fe (diff) | |
download | tor-8b91680d5c57fc35275b32aea57555d8ef7d61ba.tar.gz tor-8b91680d5c57fc35275b32aea57555d8ef7d61ba.zip |
Doxygen: rename all .dox files to end with .md
Using a standard ending here will let other tools that expect
markdown understand our output here.
This commit was automatically generated with:
for fn in $(find src -name '*.dox'); do \
git mv "$fn" "${fn%.dox}.md"; \
done
Diffstat (limited to 'src/lib/thread/threading.md')
-rw-r--r-- | src/lib/thread/threading.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/thread/threading.md b/src/lib/thread/threading.md new file mode 100644 index 0000000000..a1058c97de --- /dev/null +++ b/src/lib/thread/threading.md @@ -0,0 +1,26 @@ + +@page threading Threading in Tor + +Tor is based around a single main thread and one or more worker +threads. We aim (with middling success) to use worker threads for +CPU-intensive activities and the main thread for our networking. +Fortunately (?) we have enough cryptography that moving what we can +of the cryptographic processes to the workers should achieve good +parallelism under most loads. Unfortunately, we only have a small +fraction of our cryptography done in our worker threads right now. + +Our threads-and-workers abstraction is defined in workqueue.c, which +combines a work queue with a thread pool, and integrates the +signalling with libevent. Tor's main instance of a work queue is +instantiated in cpuworker.c. It will probably need some refactoring +as more types of work are added. + +On a lower level, we provide locks with tor_mutex_t in \refdir{lib/lock}, and +higher-level locking/threading tools in \refdir{lib/thread}, including +conditions (tor_cond_t), thread-local storage (tor_threadlocal_t), and more. + + +Try to minimize sharing between threads: it is usually best to simply +make the worker "own" all the data it needs while the work is in +progress, and to give up ownership when it's complete. + |