diff --git a/src/or/scheduler.c b/src/or/scheduler.c index 49ac1b939a..ae2e950b00 100644 --- a/src/or/scheduler.c +++ b/src/or/scheduler.c @@ -1,11 +1,6 @@ /* * Copyright (c) 2013-2016, The Tor Project, Inc. */ /* See LICENSE for licensing information */ -/** - * \file scheduler.c - * \brief Relay scheduling system - **/ - #include "or.h" #define TOR_CHANNEL_INTERNAL_ /* For channel_flush_some_cells() */ @@ -32,66 +27,102 @@ static uint32_t sched_q_high_water = 32768; static uint32_t sched_max_flush_cells = 16; -/* - * Write scheduling works by keeping track of which channels can +/** + * \file scheduler.c + * \brief Channel scheduling system: decides which channels should send and + * receive when. + * + * This module implements a scheduler algorithm, to decide + * which channels should send/receive when. + * + * The earliest versions of Tor approximated a kind of round-robin system among + * active connections, but only approximated it. + * + * Now, write scheduling works by keeping track of which channels can * accept cells, and have cells to write. From the scheduler's perspective, * a channel can be in four possible states: * - * 1.) Not open for writes, no cells to send - * - Not much to do here, and the channel will have scheduler_state == + *
    + *
  1. + * Not open for writes, no cells to send . + * * - * 2.) Open for writes, no cells to send - * - Not much here either; this will be the state an idle but open channel + *
  2. Open for writes, no cells to send + * * - * 3.) Not open for writes, cells to send - * - This is the state of a busy circuit limited by output bandwidth; + *
  3. Not open for writes, cells to send + * * - * 4.) Open for writes, cells to send - * - This connection is ready to relay some cells and waiting for + *
  4. Open for writes, cells to send + * + *
* * Other event-driven parts of the code move channels between these scheduling * states by calling scheduler functions; the scheduler only runs on open-for-