Académique Documents
Professionnel Documents
Culture Documents
=RPCs
When sending messages over a socket that multiple threads send messages
on, it is best to have a queue for messages, and have a single thread
asynchronously send the messages. This avoids making worker threads
block on sending due to the other side being slow, etc.
=Threads=
Thread is short for thread of control, a running program with its own
program counter, stack pointer, etc. (For this class a process is a
one of more threads executing in a single address space.)
Re-rentrant locks
- If you lock a mutex within a thread and call a method that tries
to lock it again, a re-entrant lock will allow the thread to
re-acquire the lock.
- The default in pthreads is to not be re-entrant, which Frans
agrees with, since you can't analyze your invariants as easily if you
don't have a clean interface that you can make correctness arguments
for in your locks. Try to only lock once, so you know when locks happen.
- One argument for re-entrancy is composability, or reuse of functions
which already lock at a fine level, but you need to lock as well in the
caller function.