Changeset 3bacee1 in mainline for kernel/generic/src/synch/workqueue.c
- Timestamp:
- 2018-04-12T16:27:17Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/synch/workqueue.c
r76d0981d r3bacee1 133 133 static void wait_for_workers(struct work_queue *workq); 134 134 static int _workq_enqueue(struct work_queue *workq, work_t *work_item, 135 135 work_func_t func, bool can_block); 136 136 static void init_work_item(work_t *work_item, work_func_t func); 137 137 static signal_op_t signal_worker_logic(struct work_queue *workq, bool can_block); … … 185 185 186 186 /** Creates and initializes a work queue. Returns NULL upon failure. */ 187 struct work_queue * 187 struct work_queue *workq_create(const char *name) 188 188 { 189 189 struct work_queue *workq = malloc(sizeof(struct work_queue), 0); … … 269 269 270 270 thread_t *thread = thread_create(worker_thread, workq, TASK, 271 271 THREAD_FLAG_NONE, workq->name); 272 272 273 273 if (!thread) { … … 428 428 */ 429 429 bool workq_enqueue_noblock(struct work_queue *workq, work_t *work_item, 430 430 work_func_t func) 431 431 { 432 432 return _workq_enqueue(workq, work_item, func, false); … … 473 473 */ 474 474 static int _workq_enqueue(struct work_queue *workq, work_t *work_item, 475 475 work_func_t func, bool can_block) 476 476 { 477 477 assert(!workq_corrupted(workq)); … … 614 614 615 615 size_t remaining_idle = 616 616 workq->idle_worker_cnt - workq->activate_pending; 617 617 618 618 /* Idle workers still exist - activate one. */ … … 628 628 } else { 629 629 /* No idle workers remain. Request that a new one be created. */ 630 bool need_worker = (active < max_concurrent_workers) 631 &&(workq->cur_worker_cnt < max_worker_cnt);630 bool need_worker = (active < max_concurrent_workers) && 631 (workq->cur_worker_cnt < max_worker_cnt); 632 632 633 633 if (need_worker && can_block) { … … 780 780 781 781 _condvar_wait_timeout_irq_spinlock(&workq->activate_worker, 782 782 &workq->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE); 783 783 784 784 assert(!workq_corrupted(workq)); … … 855 855 bool worker_surplus = worker_unnecessary(workq); 856 856 const char *load_str = worker_surplus ? "decreasing" : 857 857 (0 < workq->activate_pending) ? "increasing" : "stable"; 858 858 859 859 irq_spinlock_unlock(&workq->lock, true); 860 860 861 861 printf( 862 "Configuration: max_worker_cnt=%zu, min_worker_cnt=%zu,\n" 863 " max_concurrent_workers=%zu, max_items_per_worker=%zu\n" 864 "Workers: %zu\n" 865 "Active: %zu (workers currently processing work)\n" 866 "Blocked: %zu (work functions sleeping/blocked)\n" 867 "Idle: %zu (idle workers waiting for more work)\n" 868 "Items: %zu (queued not yet dispatched work)\n" 869 "Stopping: %d\n" 870 "Load: %s\n", 871 max_worker_cnt, min_worker_cnt, 872 max_concurrent_workers, max_items_per_worker, 873 total, 874 active, 875 blocked, 876 idle, 877 items, 878 stopping, 879 load_str 880 ); 862 "Configuration: max_worker_cnt=%zu, min_worker_cnt=%zu,\n" 863 " max_concurrent_workers=%zu, max_items_per_worker=%zu\n" 864 "Workers: %zu\n" 865 "Active: %zu (workers currently processing work)\n" 866 "Blocked: %zu (work functions sleeping/blocked)\n" 867 "Idle: %zu (idle workers waiting for more work)\n" 868 "Items: %zu (queued not yet dispatched work)\n" 869 "Stopping: %d\n" 870 "Load: %s\n", 871 max_worker_cnt, min_worker_cnt, 872 max_concurrent_workers, max_items_per_worker, 873 total, 874 active, 875 blocked, 876 idle, 877 items, 878 stopping, 879 load_str); 881 880 } 882 881 … … 896 895 while (list_empty(&info->work_queues) && !stop) { 897 896 errno_t ret = _condvar_wait_timeout_irq_spinlock(&info->req_cv, 898 897 &info->lock, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_INTERRUPTIBLE); 899 898 900 899 stop = (ret == EINTR); … … 903 902 if (!stop) { 904 903 *pworkq = list_get_instance(list_first(&info->work_queues), 905 904 struct work_queue, nb_link); 906 905 907 906 assert(!workq_corrupted(*pworkq)); … … 933 932 934 933 nonblock_adder.thread = thread_create(thr_nonblock_add_worker, 935 934 &nonblock_adder, TASK, THREAD_FLAG_NONE, "kworkq-nb"); 936 935 937 936 if (nonblock_adder.thread) {
Note:
See TracChangeset
for help on using the changeset viewer.