diff options
| author | bunnei <bunneidev@gmail.com> | 2015-03-23 23:55:21 -0400 | 
|---|---|---|
| committer | bunnei <bunneidev@gmail.com> | 2015-04-09 19:05:21 -0400 | 
| commit | 7b9f428b23e1761e7b6c177d2e8eb9219ac6b7f6 (patch) | |
| tree | 597dff81a4b2935daaa7890c932b00cea4d6ae53 /src/common | |
| parent | ee3377b67da3640940d0936f7ebd8472fc1fe31b (diff) | |
Thread: Implement priority boost for starved threads.
SVC: Return correct error code on invalid CreateThread processor ID.
SVC: Assert when creating a thread with an invalid userland priority.
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/thread_queue_list.h | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h index 444abf115..4f27fc899 100644 --- a/src/common/thread_queue_list.h +++ b/src/common/thread_queue_list.h @@ -40,6 +40,18 @@ struct ThreadQueueList {          return -1;      } +    T get_first() { +        Queue *cur = first; +        while (cur != nullptr) { +            if (!cur->data.empty()) { +                return cur->data.front(); +            } +            cur = cur->next_nonempty; +        } + +        return T(); +    } +      T pop_first() {          Queue *cur = first;          while (cur != nullptr) { @@ -79,6 +91,12 @@ struct ThreadQueueList {          cur->data.push_back(thread_id);      } +    void move(const T& thread_id, Priority old_priority, Priority new_priority) { +        remove(old_priority, thread_id); +        prepare(new_priority); +        push_back(new_priority, thread_id); +    } +      void remove(Priority priority, const T& thread_id) {          Queue *cur = &queues[priority];          boost::remove_erase(cur->data, thread_id); | 
