Fix wait_list::remove()

This commit is contained in:
Baptiste Wicht 2018-03-21 13:48:45 +01:00
parent 8c1fb92608
commit 2573dfb692
2 changed files with 15 additions and 3 deletions

View File

@ -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();

View File

@ -38,8 +38,13 @@ void wait_list::remove(){
auto pid = scheduler::get_pid();
auto& process = scheduler::get_process(pid);
if(head == &process.wait){
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;
}