From c663cfc21c90d3cbee1c92e867415f0c1c20946e Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Thu, 18 Aug 2016 22:00:56 +0200 Subject: [PATCH] Fix the sleep queue even more --- kernel/include/sleep_queue.hpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/include/sleep_queue.hpp b/kernel/include/sleep_queue.hpp index 30ebdc4b..b15d78e2 100644 --- a/kernel/include/sleep_queue.hpp +++ b/kernel/include/sleep_queue.hpp @@ -135,16 +135,18 @@ public: // If the queue still contains our pid, it means a wake up // from timeout - // If the pid is on top, pop it - if(queue.top() == pid){ - obtained = false; - queue.pop(); - } - // If the pid is inside the queue, replace it with an invalid pid - // If this happens too often, we'll need a better pid queue - else if(queue.contains(pid)){ - obtained = false; - queue.replace(pid, scheduler::INVALID_PID); + if(!queue.empty()){ + // If the pid is on top, pop it + if(queue.top() == pid){ + obtained = false; + queue.pop(); + } + // If the pid is inside the queue, replace it with an invalid pid + // If this happens too often, we'll need a better pid queue + else if(queue.contains(pid)){ + obtained = false; + queue.replace(pid, scheduler::INVALID_PID); + } } // Final release of the lock