swiftlang / swiftlang/swift-corelibs-libdispatch

[SR-7241] libdispatch: queues getting background prio

Open
#660 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug libdispatch
Dominant language
C
Stars
2.6k
Forks
496
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Previous ID SR-7241
Radar None
Original Reporter Kurkin (JIRA User)
Type Bug
Environment

linux without pthread_workqueue_init, so HAVE_PTHREAD_WORKQUEUE_QOS is 0

Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug
Assignee None
Priority Medium

md5: 713ccb4651173e9742d05928621b4bd0

Issue Description:

dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);

goes to

 dispatch_queue_t
  dispatch_get_global_queue(long priority, unsigned long flags)
  {
          if (flags & ~(unsigned long)DISPATCH_QUEUE_OVERCOMMIT) {
                  return DISPATCH_BAD_INPUT;
          }    
          dispatch_qos_t qos = _dispatch_qos_from_queue_priority(priority); <---
  #if !HAVE_PTHREAD_WORKQUEUE_QOS
          if (qos == QOS_CLASS_MAINTENANCE) {
                  qos = DISPATCH_QOS_BACKGROUND;
          } else if (qos == QOS_CLASS_USER_INTERACTIVE) {
                  qos = DISPATCH_QOS_USER_INITIATED;
          }    
  #endif
          if (qos == DISPATCH_QOS_UNSPECIFIED) {
                  return DISPATCH_BAD_INPUT;
          }    
          return _dispatch_get_root_queue(qos, flags & DISPATCH_QUEUE_OVERCOMMIT);
  }
 

goes to
_dispatch_qos_from_queue_priority where DISPATCH_QUEUE_PRIORITY_HIGH mapped to DISPATCH_QOS_USER_INITIATED(5) and DISPATCH_QOS_USER_INITIATED(5) is equal to QOS_CLASS_MAINTENANCE(5) and we are getting queue with wrong prio

Expected Results:
High prio queue

Actual Results:
Background prio queue

Version/Build:
master libdispatch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing dispatch_get_global_queue through _dispatch_qos_from_queue_priority on Linux when HAVE_PTHREAD_WORKQUEUE_QOS is 0, focusing on the shown priority and QoS values. Reproduce the DISPATCH_QUEUE_PRIORITY_HIGH call and verify that it produces a high-priority queue rather than a background-priority queue.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.