Discard: Add BURST argument.

Luigi Rizzo idea.
Add configuration check for __thread storage class.
atomic_uint32_t: Add objectless version of swap().
Configury: Add --disable-kqueue, etc. flags.

Which makes more sense to me.
Correct bug in select() code.

Which is obviously not being used -- poll() is, mostly, I guess.
User-level driver: Wake & then join other threads, rather than cancelling.

This is necessary on Mac using kqueue, because pthread_cancel'ing a thread
blocked on a kevent seems occasionally to hang (the close(_kqueue) call in
Master hangs).  It also seems a little safer somehow.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
User-level multithread: Make "current_processor_is_running()" fast.

Using thread-local storage, when available.

The following two-thread configuration frequently hangs:

i :: InfiniteSource(LIMIT 100000, STOP true, TIMESTAMP false, ACTIVE false)
  -> q :: Queue
  -> d :: Discard;

DriverManager(set a $(now), write i.active true, wait,
  set b $(now), print $(div $(i.limit) $(sub $b $a)))

StaticThreadSched(i 0, d 1)

Introducing more and more fences is not the way to fix this problem.
Behavior differences between "current processor is running" and "current
processor is not running" is more sensible.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
User-level multithread: Reduce hangs due to Task::reschedule() races.

Task::reschedule() now adds the task to the pending list whenever the
task's thread isn't the same as the rescheduling thread.  This is simpler
than introducing more barriers to attempt (futilely) to address races
between fast_unschedule() and reschedule().

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
User-level multithread: RouterThread::wake() writes to pipe

whenever the current thread is not running.

This reduces race conditions and may run faster in the common case.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Multithread: Improve debugging output.

Report whether a Task is on the pending list.
Multithread: Use compare_swap on Notifiers.

This appears to fix the bug with InfiniteSource->Queue->Discard, IS and D
on different threads, mentioned earlier.  Which makes some sense, although
I have not fully worked out an example.  There are disadvantages.  Now
every wake() or sleep() involves a compare_swap, which may be more
expensive than the previous click_fence()+atomic_or() pair.  But this is
unmeasured.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Internal: Remove unnecessary repeated assignment.
Linuxmodule compile: Fix atomic_uint32_t::swap().
And fix atomic_uint32_t::swap again.
Update version number to 2.0pre1.
Packet internals: Refactor initialization steps.

Now WritablePacket::WritablePacket() is the only constructor; a separate
initialize() function does initialization work.  Semantics should be
unchanged.

Together with the next commit, this improves performance by a couple
percent on Linux, but makes performance a couple percent worse on my iMac.
Configuration:

   InfiniteSource(LIMIT 100000000, STOP true, TIMESTAMP false)
     -> Queue -> Discard

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Packet internals: Arrange annotations so a single memset can clear them.

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Packet: Introduce a packet pool to speed allocations.

Freed packets accumulate and are directly reused.  Packet data is also
reused if it's the right size.  On multicore, packet data is reused per
thread, but then eventually pushed into a global list.  Inspired by Luigi
Rizzo.

The following configuration:

i :: InfiniteSource(LIMIT 10000000, STOP true, TIMESTAMP false, ACTIVE false)
  -> d :: Discard;
DriverManager(set a $(now), write i.active true, wait,
  set b $(now), print $(div $(i.limit) $(sub $b $a)))

on my iMac, pushes more than 2x as many packets with this patch as without
(25.3Mpps vs. 11.2Mpps).

Signed-off-by: Eddie Kohler <ekohler@gmail.com>
Tests: Add valgrind %ignores as necessary.
Tests: Improve Valgrind lines so errors cause test failures.