task.c revision 8bdb4ab2d14e9f7ddcb082cee397eab60a5e7316
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1998, 1999 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
71d0d898fb6eababc18793e95d9851fd366a678dAutomatic Updater * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
fb756ba3047770957173ba546257ca43af7ba3e4Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
082f42dcf2f38509a8c842013548f680a6ad06f3Mark Andrews#define XTRACE(m) printf("%s task %p thread %lu\n", (m), \
26b49e84597ab3ebaa9ae1eb0fe01befa46a8107Mark Andrewstypedef enum {
26b49e84597ab3ebaa9ae1eb0fe01befa46a8107Mark Andrews task_state_idle, task_state_ready, task_state_running,
struct isc_task {
unsigned int magic;
unsigned int references;
unsigned int quantum;
struct isc_taskmgr {
unsigned int magic;
unsigned int workers;
unsigned int default_quantum;
static inline isc_event_t *
return (NULL);
return (event);
return (NULL);
if (type < 0)
return (NULL);
return (NULL);
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTED);
return (ISC_R_SUCCESS);
if (free_task)
if (disallowed)
return (result);
if (was_idle) {
return (ISC_R_SUCCESS);
unsigned int purge_count;
purge_count = 0;
purge_count++;
return (purge_count);
return (result);
NULL,
arg,
sizeof *event);
return (ISC_R_NOMEMORY);
if (disallowed)
return (result);
static isc_threadresult_t
#ifdef _WIN32
unsigned int dispatch_count = 0;
while (!done) {
if (free_task)
if (requeue) {
return ((isc_threadresult_t)0);
unsigned int i, started = 0;
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTED);
if (default_quantum == 0)
return (ISC_R_UNEXPECTED);
for (i = 0; i < workers; i++) {
started++;
if (started == 0) {
return (ISC_R_NOTHREADS);
return (ISC_R_SUCCESS);