isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
- result = isc_task_create(taskmgr, 0, &global_task);
+ result = isc_task_create(taskmgr, 0, &global_task, 0);
check_result(result, "isc_task_create");
isc_task_setname(global_task, "dig", NULL);
isc_managers_create(mctx, ntasks, 0, &netmgr, &taskmgr, NULL);
main_task = NULL;
- result = isc_task_create(taskmgr, 0, &main_task);
+ result = isc_task_create(taskmgr, 0, &main_task, 0);
if (result != ISC_R_SUCCESS) {
fatal("failed to create task: %s", isc_result_totext(result));
}
tasks = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *));
for (i = 0; i < (int)ntasks; i++) {
tasks[i] = NULL;
- result = isc_task_create(taskmgr, 0, &tasks[i]);
+ result = isc_task_create(taskmgr, 0, &tasks[i], i);
if (result != ISC_R_SUCCESS) {
fatal("failed to create task: %s",
isc_result_totext(result));
* startup and shutdown of the server, as well as all exclusive
* tasks.
*/
- CHECKFATAL(isc_task_create_bound(named_g_taskmgr, 0, &server->task, 0),
+ CHECKFATAL(isc_task_create(named_g_taskmgr, 0, &server->task, 0),
"creating server task");
isc_task_setname(server->task, "server", server);
isc_taskmgr_setexcltask(named_g_taskmgr, server->task);
result = dns_dispatchmgr_create(gmctx, netmgr, &dispatchmgr);
check_result(result, "dns_dispatchmgr_create");
- result = isc_task_create(taskmgr, 0, &global_task);
+ result = isc_task_create(taskmgr, 0, &global_task, 0);
check_result(result, "isc_task_create");
result = dst_lib_init(gmctx, NULL);
isc_mem_create(&rndc_mctx);
isc_managers_create(rndc_mctx, 1, 0, &netmgr, &taskmgr, NULL);
- DO("create task", isc_task_create(taskmgr, 0, &rndc_task));
+ DO("create task", isc_task_create(taskmgr, 0, &rndc_task, 0));
isc_log_create(rndc_mctx, &log, &logconfig);
isc_log_setcontext(log);
isc_log_settag(logconfig, progname);
RUNCHECK(dst_lib_init(mctx, NULL));
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
- RUNCHECK(isc_task_create(taskmgr, 0, &task));
+ RUNCHECK(isc_task_create(taskmgr, 0, &task, 0));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
RUNCHECK(dns_dispatch_createudp(
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
- RUNCHECK(isc_task_create(taskmgr, 0, &task));
+ RUNCHECK(isc_task_create(taskmgr, 0, &task, 0));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
isc_sockaddr_any(&bind_any);
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
- RUNCHECK(isc_task_create(taskmgr, 0, &task));
+ RUNCHECK(isc_task_create(taskmgr, 0, &task, 0));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
isc_sockaddr_any(&bind_any);
RUNCHECK(dns_dispatch_createudp(dispatchmgr, &bind_any, &dispatchv4));
}
isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL);
- RUNCHECK(isc_task_create(taskmgr, 0, &task));
+ RUNCHECK(isc_task_create(taskmgr, 0, &task, 0));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
set_source_ports(dispatchmgr);
/*
* Allocate an internal task.
*/
- result = isc_task_create(adb->taskmgr, 0, &adb->task);
+ result = isc_task_create(adb->taskmgr, 0, &adb->task, 0);
if (result != ISC_R_SUCCESS) {
goto free_lock;
}
}
if (taskmgr != NULL) {
dbtask = NULL;
- result = isc_task_create(taskmgr, 1, &dbtask);
+ result = isc_task_create(taskmgr, 1, &dbtask, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_db;
}
}
if (taskmgr != NULL && timermgr != NULL) {
- result = isc_task_create(taskmgr, 1, &cleaner->task);
+ result = isc_task_create(taskmgr, 1, &cleaner->task, 0);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_task_create() failed: %s",
new_zones->timermgr = timermgr;
new_zones->taskmgr = taskmgr;
- result = isc_task_create(taskmgr, 0, &new_zones->updater);
+ result = isc_task_create(taskmgr, 0, &new_zones->updater, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_ht;
}
isc_mutex_init(&client->readylock);
isc_condition_init(&client->ready);
- result = isc_task_create(client->taskmgr, 0, &client->task);
+ result = isc_task_create(client->taskmgr, 0, &client->task, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_lock;
}
ntatable = isc_mem_get(view->mctx, sizeof(*ntatable));
ntatable->task = NULL;
- result = isc_task_create(taskmgr, 0, &ntatable->task);
+ result = isc_task_create(taskmgr, 0, &ntatable->task, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_ntatable;
}
* Since we have a pool of tasks we bind them to task
* queues to spread the load evenly
*/
- result = isc_task_create_bound(taskmgr, 0, &res->tasks[i], i);
+ result = isc_task_create(taskmgr, 0, &res->tasks[i], i);
if (result != ISC_R_SUCCESS) {
goto cleanup_tasks;
}
isc_mutex_init(&res->lock);
isc_mutex_init(&res->primelock);
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_primelock;
}
goto cleanup_rbt;
}
- result = isc_task_create(taskmgr, 0, &rpzs->updater);
+ result = isc_task_create(taskmgr, 0, &rpzs->updater, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_task;
}
ncpus = isc_os_ncpus();
isc_managers_create(dt_mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr);
- CHECK(isc_task_create(taskmgr, 0, &maintask));
+ CHECK(isc_task_create(taskmgr, 0, &maintask, 0));
return (ISC_R_SUCCESS);
cleanup:
result = dns_test_makeview("view", &myview);
assert_int_equal(result, ISC_R_SUCCESS);
- result = isc_task_create(taskmgr, 0, &myview->task);
+ result = isc_task_create(taskmgr, 0, &myview->task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_view_initsecroots(myview, dt_mctx);
REQUIRE(!view->frozen);
REQUIRE(view->resolver == NULL);
- result = isc_task_create(taskmgr, 0, &view->task);
+ result = isc_task_create(taskmgr, 0, &view->task, 0);
if (result != ISC_R_SUCCESS) {
return (result);
}
isc_rwlock_init(&zmgr->urlock, 0, 0);
/* Create a single task for queueing of SOA queries. */
- result = isc_task_create(taskmgr, 1, &zmgr->task);
+ result = isc_task_create(taskmgr, 1, &zmgr->task, 0);
if (result != ISC_R_SUCCESS) {
goto free_urlock;
}
zmgr->mctx, zmgr->workers * sizeof(zmgr->zonetasks[0]));
memset(zmgr->zonetasks, 0, zmgr->workers * sizeof(zmgr->zonetasks[0]));
for (size_t i = 0; i < zmgr->workers; i++) {
- result = isc_task_create_bound(zmgr->taskmgr, 2,
- &zmgr->zonetasks[i], i);
+ result = isc_task_create(zmgr->taskmgr, 2, &zmgr->zonetasks[i],
+ i);
if (result != ISC_R_SUCCESS) {
goto free_zonetasks;
}
zmgr->mctx, zmgr->workers * sizeof(zmgr->loadtasks[0]));
memset(zmgr->loadtasks, 0, zmgr->workers * sizeof(zmgr->loadtasks[0]));
for (size_t i = 0; i < zmgr->workers; i++) {
- result = isc_task_create_bound(zmgr->taskmgr, UINT_MAX,
- &zmgr->loadtasks[i], i);
+ result = isc_task_create(zmgr->taskmgr, UINT_MAX,
+ &zmgr->loadtasks[i], i);
if (result != ISC_R_SUCCESS) {
goto free_loadtasks;
}
* \section purge Purging and Unsending
*
* Events which have been queued for a task but not delivered may be removed
- * from the task's event queue by purging or unsending.
- *
- * With both types, the caller specifies a matching pattern that selects
- * events based upon their sender, type, and tag.
+ * from the task's event queue by purging the event.
*
* Purging calls isc_event_free() on the matching events.
*
*** Types
***/
-#define isc_task_create(m, q, t) \
- isc__task_create_bound(m, q, t, -1 ISC__TASKFILELINE)
-#define isc_task_create_bound(m, q, t, i) \
- isc__task_create_bound(m, q, t, i ISC__TASKFILELINE)
+#define isc_task_create(m, q, t, i) \
+ isc__task_create(m, q, t, i ISC__TASKFILELINE)
isc_result_t
-isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
- isc_task_t **taskp, int tid ISC__TASKFLARG);
+isc__task_create(isc_taskmgr_t *manager, unsigned int quantum,
+ isc_task_t **taskp, int tid ISC__TASKFLARG);
/*%<
- * Create a task, optionally bound to a particular tid.
+ * Create a task, bound to a particular thread id.
*
* Notes:
*
* Returns:
*
*\li #ISC_R_SUCCESS
- *\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*\li #ISC_R_SHUTTINGDOWN
*/
void
isc_task_send(isc_task_t *task, isc_event_t **eventp);
/*%<
- * Send '*event' to 'task', if task is idle try starting it on cpu 'c'
+ * Send '*event' to 'task'.
*
* Requires:
*
isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
/*%<
* Send '*event' to '*taskp' and then detach '*taskp' from its
- * task. If task is idle try starting it on cpu 'c'
+ * task.
*
* Requires:
*
/*%<
* Purge 'event' from a task's event queue.
*
- * XXXRTH: WARNING: This method may be removed before beta.
- *
* Notes:
*
- *\li If 'event' is on the task's event queue, it will be purged,
- * unless it is marked as unpurgeable. 'event' does not have to be
- * on the task's event queue; in fact, it can even be an invalid
- * pointer. Purging only occurs if the event is actually on the task's
- * event queue.
+ *\li If 'event' is on the task's event queue, it will be purged. 'event'
+ * does not have to be on the task's event queue; in fact, it can even be
+ * an invalid pointer. Purging only occurs if the event is actually on the
+ * task's event queue.
*
* \li Purging never changes the state of the task.
*
* Returns:
*
*\li #true The event was purged.
- *\li #false The event was not in the event queue,
- * or was marked unpurgeable.
+ *\li #false The event was not in the event queue.
*/
void
*
* Returns:
*\li A non-NULL pointer to a null-terminated string.
- * If the task has not been named, the string is
- * empty.
+ * If the task has not been named, the string is
+ * empty.
*
*/
* locality on CPU.
*
* To make load even some tasks (from task pools) are bound to specific
- * queues using isc_task_create_bound. This way load balancing between
+ * queues using isc_task_create. This way load balancing between
* CPUs/queues happens on the higher layer.
*/
isc_time_t tnow;
char name[16];
void *tag;
- bool bound;
/* Protected by atomics */
atomic_bool shuttingdown;
/* Locked by task manager lock. */
}
isc_result_t
-isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
- isc_task_t **taskp, int tid ISC__TASKFLARG) {
+isc__task_create(isc_taskmgr_t *manager, unsigned int quantum,
+ isc_task_t **taskp, int tid ISC__TASKFLARG) {
isc_task_t *task = NULL;
bool exiting;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(taskp != NULL && *taskp == NULL);
+ REQUIRE(tid >= 0 && tid < (int)manager->nworkers);
XTRACE("isc_task_create");
task = isc_mem_get(manager->mctx, sizeof(*task));
- *task = (isc_task_t){ 0 };
+ *task = (isc_task_t){
+ .state = task_state_idle,
+ .tid = tid,
+ };
#if TASKMGR_TRACE
strlcpy(task->func, func, sizeof(task->func));
isc_taskmgr_attach(manager, &task->manager);
- if (tid == -1) {
- /*
- * Task is not pinned to a queue, it's tid will be
- * randomly chosen when first task will be sent to it.
- */
- task->bound = false;
- task->tid = -1;
- } else {
- /*
- * Task is pinned to a queue, it'll always be run
- * by a specific thread.
- */
- task->bound = true;
- task->tid = tid % task->manager->nworkers;
- }
-
isc_mutex_init(&task->lock);
- task->state = task_state_idle;
isc_refcount_init(&task->references, 1);
INIT_LIST(task->events);
- task->nevents = 0;
task->quantum = (quantum > 0) ? quantum : manager->default_quantum;
atomic_init(&task->shuttingdown, false);
- task->now = 0;
isc_time_settoepoch(&task->tnow);
memset(task->name, 0, sizeof(task->name));
- task->tag = NULL;
INIT_LINK(task, link);
task->magic = TASK_MAGIC;
isc_task_attach(task, &(isc_task_t *){ NULL });
LOCK(&task->lock);
- if (task->tid < 0) {
- task->tid = (int)isc_random_uniform(manager->nworkers);
- }
isc_nm_task_enqueue(manager->netmgr, task, task->tid);
UNLOCK(&task->lock);
}
if (task->state == task_state_idle) {
was_idle = true;
- if (!task->bound) {
- task->tid = (int)isc_random_uniform(
- task->manager->nworkers);
- }
INSIST(EMPTY(task->events));
task->state = task_state_ready;
}
REQUIRE(VALID_TASK(task));
/*
- * If 'event' is on the task's event queue, it will be purged,
- * unless it is marked as unpurgeable. 'event' does not have to be
- * on the task's event queue; in fact, it can even be an invalid
- * pointer. Purging only occurs if the event is actually on the task's
- * event queue.
+ * If 'event' is on the task's event queue, it will be purged, 'event'
+ * does not have to be on the task's event queue; in fact, it can even
+ * be an invalid pointer. Purging only occurs if the event is actually
+ * on the task's event queue.
*
* Purging never changes the state of the task.
*/
isc_managers_create(test_mctx, workers, 0, &netmgr, &taskmgr,
&timermgr);
- CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
+ CHECK(isc_task_create(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);
return (ISC_R_SUCCESS);
UNUSED(state);
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_detach(&task);
atomic_init(&a, 0);
atomic_init(&b, 0);
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
/* First event */
UNUSED(state);
- result = isc_task_create(taskmgr, 0, &task1);
+ result = isc_task_create(taskmgr, 0, &task1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
- result = isc_task_create(taskmgr, 0, &task2);
+ result = isc_task_create(taskmgr, 0, &task2, 0);
assert_int_equal(result, ISC_R_SUCCESS);
- result = isc_task_create(taskmgr, 0, &task3);
+ result = isc_task_create(taskmgr, 0, &task3, 0);
assert_int_equal(result, ISC_R_SUCCESS);
- result = isc_task_create(taskmgr, 0, &task4);
+ result = isc_task_create(taskmgr, 0, &task4, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_interval_set(&interval, 1, 0);
if (i == 6) {
/* task chosen from the middle of the range */
- result = isc_task_create_bound(taskmgr, 0, &tasks[i],
- 0);
+ result = isc_task_create(taskmgr, 0, &tasks[i], 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_taskmgr_setexcltask(taskmgr, tasks[6]);
} else {
- result = isc_task_create(taskmgr, 0, &tasks[i]);
+ result = isc_task_create(taskmgr, 0, &tasks[i], 0);
assert_int_equal(result, ISC_R_SUCCESS);
}
/*
* Create a new task and forward the message.
*/
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_task_send(task, &event);
atomic_init(&done, false);
eventcnt = 0;
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
/*
LOCK(&mx);
- result = isc_task_create(taskmgr, 0, &task);
+ result = isc_task_create(taskmgr, 0, &task, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_mutex_lock(&lasttime_mx);
seconds = 1;
nanoseconds = 0;
- result = isc_task_create(taskmgr, 0, &task1);
+ result = isc_task_create(taskmgr, 0, &task1, 0);
assert_int_equal(result, ISC_R_SUCCESS);
- result = isc_task_create(taskmgr, 0, &task2);
+ result = isc_task_create(taskmgr, 0, &task2, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_interval_set(&interval, seconds, 0);
dns_aclenv_attach(aclenv, &manager->aclenv);
- result = isc_task_create_bound(manager->taskmgr, 20, &manager->task,
- manager->tid);
+ result = isc_task_create(manager->taskmgr, 20, &manager->task,
+ manager->tid);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_task_setname(manager->task, "clientmgr", NULL);
isc_mutex_init(&mgr->lock);
- result = isc_task_create_bound(taskmgr, 0, &mgr->task, 0);
+ result = isc_task_create(taskmgr, 0, &mgr->task, 0);
if (result != ISC_R_SUCCESS) {
goto cleanup_lock;
}
int ncpus = isc_os_ncpus();
isc_managers_create(mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr);
- CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0));
+ CHECK(isc_task_create(taskmgr, 0, &maintask, 0));
isc_taskmgr_setexcltask(taskmgr, maintask);
CHECK(ns_server_create(mctx, matchview, &sctx));