Author: adrian Date: Mon Jan 7 09:18:39 2019 New Revision: 350543 URL: http://llvm.org/viewvc/llvm-project?rev=350543&view=rev Log: Fine-tune and document the barrier in TestQueues.
Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c?rev=350543&r1=350542&r2=350543&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c (original) +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c Mon Jan 7 09:18:39 2019 @@ -10,6 +10,8 @@ atomic_int thread_count = 0; void doing_the_work_1(void *in) { + // This is only counted once because the first job in the queue + // starves all the others. atomic_fetch_add(&thread_count, 1); while (1) sleep (1); @@ -29,13 +31,15 @@ submit_work_1b(void *in) dispatch_queue_t *work_performer_1 = (dispatch_queue_t*) in; dispatch_async_f (*work_performer_1, NULL, doing_the_work_1); dispatch_async_f (*work_performer_1, NULL, doing_the_work_1); + atomic_fetch_add(&thread_count, 1); while (1) - sleep (1); + sleep (1); } void doing_the_work_2(void *in) { + atomic_fetch_add(&thread_count, 1); while (1) sleep (1); } @@ -45,7 +49,7 @@ submit_work_2(void *in) { dispatch_queue_t *work_performer_2 = (dispatch_queue_t*) in; int i = 0; - while (i++ < 5000) + while (i++ < 5000) { dispatch_async_f (*work_performer_2, NULL, doing_the_work_2); dispatch_async_f (*work_performer_2, NULL, doing_the_work_2); @@ -57,8 +61,10 @@ submit_work_2(void *in) void doing_the_work_3(void *in) { + // This counts four times, since the queue is marked as CONCURRENT. + atomic_fetch_add(&thread_count, 1); while (1) - sleep(1); + sleep (1); } void @@ -105,40 +111,40 @@ int main (int argc, const char **argv) atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{ pthread_setname_np ("user interactive QoS"); atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ pthread_setname_np ("default QoS"); atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{ pthread_setname_np ("utility QoS"); atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ pthread_setname_np ("background QoS"); atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{ pthread_setname_np ("unspecified QoS"); atomic_fetch_add(&thread_count, 1); while (1) sleep (10); - }); + }); // Unfortunately there is no pthread_barrier on darwin. - while (atomic_load(&thread_count) < 7) + while (atomic_load(&thread_count) < 13) sleep(1); while (finished_enqueueing_work == 0) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits