Lines Matching defs:manager
45 * when built without threads we share a single global task manager and use
50 * is expected to have a separate manager; no "worker threads" are shared by
98 isc__taskmgr_t * manager;
112 /* Locked by task manager lock. */
138 /* Locked by task manager lock. */
247 empty_readyq(isc__taskmgr_t *manager);
250 pop_readyq(isc__taskmgr_t *manager);
253 push_readyq(isc__taskmgr_t *manager, isc__task_t *task);
304 isc__taskmgr_t *manager = task->manager;
314 LOCK(&manager->lock);
315 UNLINK(manager->tasks, task, link);
317 if (FINISHED(manager)) {
320 * task manager is exiting. Wake up
324 BROADCAST(&manager->work_available);
327 UNLOCK(&manager->lock);
332 isc_mem_put(manager->mctx, task, sizeof(*task));
339 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
344 REQUIRE(VALID_MANAGER(manager));
347 task = isc_mem_get(manager->mctx, sizeof(*task));
351 task->manager = manager;
354 isc_mem_put(manager->mctx, task, sizeof(*task));
373 LOCK(&manager->lock);
374 if (!manager->exiting) {
376 task->quantum = manager->default_quantum;
377 APPEND(manager->tasks, task, link);
380 UNLOCK(&manager->lock);
384 isc_mem_put(manager->mctx, task, sizeof(*task));
458 * Caller must NOT hold manager lock.
462 isc__taskmgr_t *manager = task->manager;
467 REQUIRE(VALID_MANAGER(manager));
472 LOCK(&manager->lock);
473 push_readyq(manager, task);
475 if (manager->mode == isc_taskmgrmode_normal || has_privilege)
476 SIGNAL(&manager->work_available);
478 UNLOCK(&manager->lock);
594 * ready requires locking the manager. If we tried to do
822 event = isc_event_allocate(task->manager->mctx,
840 isc_mem_put(task->manager->mctx, event, sizeof(*event));
940 * Return ISC_TRUE if the current ready list for the manager, which is
942 * the manager is currently in normal or privileged execution mode.
944 * Caller must hold the task manager lock.
947 empty_readyq(isc__taskmgr_t *manager) {
950 if (manager->mode == isc_taskmgrmode_normal)
951 queue = manager->ready_tasks;
953 queue = manager->ready_priority_tasks;
960 * list for the manager.
964 * Caller must hold the task manager lock.
967 pop_readyq(isc__taskmgr_t *manager) {
970 if (manager->mode == isc_taskmgrmode_normal)
971 task = HEAD(manager->ready_tasks);
973 task = HEAD(manager->ready_priority_tasks);
976 DEQUEUE(manager->ready_tasks, task, ready_link);
978 DEQUEUE(manager->ready_priority_tasks, task,
989 * Caller must hold the task manager lock.
992 push_readyq(isc__taskmgr_t *manager, isc__task_t *task) {
993 ENQUEUE(manager->ready_tasks, task, ready_link);
995 ENQUEUE(manager->ready_priority_tasks, task,
997 manager->tasks_ready++;
1001 dispatch(isc__taskmgr_t *manager) {
1010 REQUIRE(VALID_MANAGER(manager));
1066 LOCK(&manager->lock);
1068 while (!FINISHED(manager)) {
1073 * the task while only holding the manager lock, and then
1080 while ((empty_readyq(manager) || manager->pause_requested ||
1081 manager->exclusive_requested) && !FINISHED(manager))
1086 WAIT(&manager->work_available, &manager->lock);
1093 empty_readyq(manager))
1099 task = pop_readyq(manager);
1110 * Note we only unlock the manager lock if we actually
1111 * have a task to do. We must reacquire the manager
1114 manager->tasks_ready--;
1115 manager->tasks_running++;
1116 UNLOCK(&manager->lock);
1231 LOCK(&manager->lock);
1232 manager->tasks_running--;
1234 if (manager->exclusive_requested &&
1235 manager->tasks_running == 1) {
1236 SIGNAL(&manager->exclusive_granted);
1237 } else if (manager->pause_requested &&
1238 manager->tasks_running == 0) {
1239 SIGNAL(&manager->paused);
1263 push_readyq(manager, task);
1281 if (manager->tasks_running == 0 && empty_readyq(manager)) {
1282 manager->mode = isc_taskmgrmode_normal;
1283 if (!empty_readyq(manager))
1284 BROADCAST(&manager->work_available);
1290 ISC_LIST_APPENDLIST(manager->ready_tasks, new_ready_tasks, ready_link);
1291 ISC_LIST_APPENDLIST(manager->ready_priority_tasks, new_priority_tasks,
1293 manager->tasks_ready += tasks_ready;
1294 if (empty_readyq(manager))
1295 manager->mode = isc_taskmgrmode_normal;
1298 UNLOCK(&manager->lock);
1307 isc__taskmgr_t *manager = uap;
1312 dispatch(manager);
1326 manager_free(isc__taskmgr_t *manager) {
1330 (void)isc_condition_destroy(&manager->exclusive_granted);
1331 (void)isc_condition_destroy(&manager->work_available);
1332 (void)isc_condition_destroy(&manager->paused);
1333 isc_mem_free(manager->mctx, manager->threads);
1335 DESTROYLOCK(&manager->lock);
1336 DESTROYLOCK(&manager->excl_lock);
1337 manager->common.impmagic = 0;
1338 manager->common.magic = 0;
1339 mctx = manager->mctx;
1340 isc_mem_put(mctx, manager, sizeof(*manager));
1354 isc__taskmgr_t *manager;
1357 * Create a new task manager.
1378 manager = isc_mem_get(mctx, sizeof(*manager));
1379 if (manager == NULL)
1381 manager->common.methods = &taskmgrmethods;
1382 manager->common.impmagic = TASK_MANAGER_MAGIC;
1383 manager->common.magic = ISCAPI_TASKMGR_MAGIC;
1384 manager->mode = isc_taskmgrmode_normal;
1385 manager->mctx = NULL;
1386 result = isc_mutex_init(&manager->lock);
1389 result = isc_mutex_init(&manager->excl_lock);
1391 DESTROYLOCK(&manager->lock);
1396 manager->workers = 0;
1397 manager->threads = isc_mem_allocate(mctx,
1399 if (manager->threads == NULL) {
1403 if (isc_condition_init(&manager->work_available) != ISC_R_SUCCESS) {
1411 if (isc_condition_init(&manager->exclusive_granted) != ISC_R_SUCCESS) {
1419 if (isc_condition_init(&manager->paused) != ISC_R_SUCCESS) {
1430 manager->default_quantum = default_quantum;
1431 INIT_LIST(manager->tasks);
1432 INIT_LIST(manager->ready_tasks);
1433 INIT_LIST(manager->ready_priority_tasks);
1434 manager->tasks_running = 0;
1435 manager->tasks_ready = 0;
1436 manager->exclusive_requested = ISC_FALSE;
1437 manager->pause_requested = ISC_FALSE;
1438 manager->exiting = ISC_FALSE;
1439 manager->excl = NULL;
1441 isc_mem_attach(mctx, &manager->mctx);
1444 LOCK(&manager->lock);
1449 if (isc_thread_create(run, manager,
1450 &manager->threads[manager->workers]) ==
1454 isc_thread_setname(manager->threads[manager->workers],
1456 manager->workers++;
1460 UNLOCK(&manager->lock);
1463 manager_free(manager);
1469 manager->refs = 1;
1470 taskmgr = manager;
1473 *managerp = (isc_taskmgr_t *)manager;
1479 (void)isc_condition_destroy(&manager->exclusive_granted);
1481 (void)isc_condition_destroy(&manager->work_available);
1483 isc_mem_free(mctx, manager->threads);
1485 DESTROYLOCK(&manager->lock);
1488 isc_mem_put(mctx, manager, sizeof(*manager));
1494 isc__taskmgr_t *manager;
1503 manager = (isc__taskmgr_t *)*managerp;
1504 REQUIRE(VALID_MANAGER(manager));
1511 manager->refs--;
1512 if (manager->refs > 0) {
1522 * task manager, it should ask some non-worker thread to call
1528 * Detach the exclusive task before acquiring the manager lock
1530 LOCK(&manager->excl_lock);
1531 if (manager->excl != NULL)
1532 isc__task_detach((isc_task_t **) &manager->excl);
1533 UNLOCK(&manager->excl_lock);
1541 * task manager lock and a task lock at the same time.
1544 LOCK(&manager->lock);
1549 INSIST(!manager->exiting);
1550 manager->exiting = ISC_TRUE;
1555 manager->mode = isc_taskmgrmode_normal;
1561 for (task = HEAD(manager->tasks);
1566 push_readyq(manager, task);
1573 * it will cause the workers to see manager->exiting.
1575 BROADCAST(&manager->work_available);
1576 UNLOCK(&manager->lock);
1581 for (i = 0; i < manager->workers; i++)
1582 (void)isc_thread_join(manager->threads[i], NULL);
1587 UNLOCK(&manager->lock);
1588 while (isc__taskmgr_ready((isc_taskmgr_t *)manager))
1589 (void)isc__taskmgr_dispatch((isc_taskmgr_t *)manager);
1590 if (!ISC_LIST_EMPTY(manager->tasks))
1592 INSIST(ISC_LIST_EMPTY(manager->tasks));
1598 manager_free(manager);
1605 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1607 LOCK(&manager->lock);
1608 manager->mode = mode;
1609 UNLOCK(&manager->lock);
1614 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1616 LOCK(&manager->lock);
1617 mode = manager->mode;
1618 UNLOCK(&manager->lock);
1625 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1629 if (manager == NULL)
1630 manager = taskmgr;
1632 if (manager == NULL)
1635 LOCK(&manager->lock);
1636 is_ready = !empty_readyq(manager);
1637 UNLOCK(&manager->lock);
1644 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1647 if (manager == NULL)
1648 manager = taskmgr;
1650 if (manager == NULL)
1653 dispatch(manager);
1661 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1662 manager->pause_requested = ISC_TRUE;
1663 LOCK(&manager->lock);
1664 while (manager->tasks_running > 0) {
1665 WAIT(&manager->paused, &manager->lock);
1667 UNLOCK(&manager->lock);
1672 isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
1674 LOCK(&manager->lock);
1675 if (manager->pause_requested) {
1676 manager->pause_requested = ISC_FALSE;
1677 BROADCAST(&manager->work_available);
1679 UNLOCK(&manager->lock);
1719 isc__taskmgr_t *manager = task->manager;
1723 * TODO REQUIRE(task == task->manager->excl);
1727 LOCK(&manager->lock);
1728 if (manager->exclusive_requested) {
1729 UNLOCK(&manager->lock);
1732 manager->exclusive_requested = ISC_TRUE;
1733 while (manager->tasks_running > 1) {
1734 WAIT(&manager->exclusive_granted, &manager->lock);
1736 UNLOCK(&manager->lock);
1747 isc__taskmgr_t *manager = task->manager;
1750 LOCK(&manager->lock);
1751 REQUIRE(manager->exclusive_requested);
1752 manager->exclusive_requested = ISC_FALSE;
1753 BROADCAST(&manager->work_available);
1754 UNLOCK(&manager->lock);
1763 isc__taskmgr_t *manager = task->manager;
1777 LOCK(&manager->lock);
1779 ENQUEUE(manager->ready_priority_tasks, task,
1782 DEQUEUE(manager->ready_priority_tasks, task,
1784 UNLOCK(&manager->lock);
2107 isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode) {
2108 REQUIRE(ISCAPI_TASKMGR_VALID(manager));
2111 isc__taskmgr_setmode(manager, mode);
2113 manager->methods->setmode(manager, mode);
2117 isc_taskmgr_mode(isc_taskmgr_t *manager) {
2118 REQUIRE(ISCAPI_TASKMGR_VALID(manager));
2121 return (isc__taskmgr_mode(manager));
2123 return (manager->methods->mode(manager));
2127 isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
2130 REQUIRE(ISCAPI_TASKMGR_VALID(manager));
2134 return (isc__task_create(manager, quantum, taskp));
2136 return (manager->methods->taskcreate(manager, quantum, taskp));