From 2573dfb69212dfc08c23a3bb7da11508faea9d22 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Wed, 21 Mar 2018 13:48:45 +0100 Subject: [PATCH] Fix wait_list::remove() --- kernel/include/conc/wait_list.hpp | 4 +++- kernel/src/conc/wait_list.cpp | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/include/conc/wait_list.hpp b/kernel/include/conc/wait_list.hpp index 8f87c11f..e97014a4 100644 --- a/kernel/include/conc/wait_list.hpp +++ b/kernel/include/conc/wait_list.hpp @@ -38,7 +38,9 @@ struct wait_list { bool waiting() const; /*! - * \brief Removes the current process from the list + * \brief Removes the current process from the list. + * + * The process must be in the list! */ void remove(); diff --git a/kernel/src/conc/wait_list.cpp b/kernel/src/conc/wait_list.cpp index 3bfd6d48..a257fd39 100644 --- a/kernel/src/conc/wait_list.cpp +++ b/kernel/src/conc/wait_list.cpp @@ -38,8 +38,13 @@ void wait_list::remove(){ auto pid = scheduler::get_pid(); auto& process = scheduler::get_process(pid); - if(head == &process.wait){ - head = head->next; + if (head == &process.wait) { + if(head == tail){ + tail = head = nullptr; + } else { + head = head->next; + } + return; } @@ -47,7 +52,12 @@ void wait_list::remove(){ while(node->next){ if(node->next == &process.wait){ + if(tail == node->next){ + tail = node->next->next; + } + node->next = node->next->next; + return; }