summaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-01-07 17:18:39 +0000
committerAdrian Prantl <aprantl@apple.com>2019-01-07 17:18:39 +0000
commit3ece1984329309286b3703cfc2a00ac602e736a6 (patch)
tree3f801e04a354675446ba0b547edee1900ef75105 /lldb
parentdddb7f2996a3c6f1a0252f0b4dac1e49e5160843 (diff)
Fine-tune and document the barrier in TestQueues.
Diffstat (limited to 'lldb')
-rw-r--r--lldb/packages/Python/lldbsuite/test/macosx/queues/main.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c b/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c
index 910853642a6..34b4607c662 100644
--- a/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c
+++ b/lldb/packages/Python/lldbsuite/test/macosx/queues/main.c
@@ -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)