-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/* | ||
* Copyright (C) 2025 Mihai Renea <[email protected]> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
|
@@ -87,14 +89,13 @@ | |
* @file wait_queue.h | ||
* @brief Linux-like wait queue for condition signaling | ||
* | ||
* @author Mihai Renea <mihairenea@gmail.com> | ||
* @author Mihai Renea <mihai.renea@ml-pa.com> | ||
*/ | ||
|
||
#ifndef WAIT_QUEUE_H | ||
#define WAIT_QUEUE_H | ||
|
||
#include "irq.h" | ||
#include "thread.h" | ||
#include "sched.h" | ||
|
||
/* Wait queue entry, which is always allocated on the stack. We can't use the | ||
* linked list node in thread_t because while evaluating the condition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
/* | ||
* Copyright (C) 2025 Mihai Renea <[email protected]> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup core_sync | ||
* @{ | ||
* | ||
* @file | ||
* @brief Wait queue implementation | ||
* | ||
* @author Mihai Renea <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include "irq.h" | ||
#include "wait_queue.h" | ||
|
||
#define ENABLE_DEBUG 0 | ||
|
@@ -48,8 +69,8 @@ void _wait_dequeue(wait_queue_t *wq, wait_queue_entry_t *entry) | |
if (*curr_pp == entry) { | ||
*curr_pp = (*curr_pp)->next; | ||
#ifndef NDEBUG | ||
/* Mark as not queued only for debugging, as the entry is going out | ||
* of scope immediately anyway. */ | ||
/* Mark as not queued only for debugging, as the entry is about to | ||
* go out of scope anyway. */ | ||
entry->next = NULL; | ||
#endif | ||
break; | ||
|
@@ -91,7 +112,7 @@ void _queue_wake_common(wait_queue_t *wq, bool all) | |
{ | ||
int irq_state = irq_disable(); | ||
|
||
int highest_prio = THREAD_PRIORITY_MIN + 1; | ||
uint16_t highest_prio = THREAD_PRIORITY_MIN + 1; | ||
|
||
wait_queue_entry_t *head; | ||
while ((head = wq->list) != WAIT_QUEUE_TAIL) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ USEMODULE += sema | |
|
||
DEVELHELP ?= 0 | ||
ASSERT_VERBOSE ?= 0 | ||
# CFLAGS_OPT += -Og -g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2025 Mihai Renea | ||
* Copyright (C) 2025 Mihai Renea <[email protected]> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
|
@@ -13,7 +13,7 @@ | |
* @file | ||
* @brief Test application for wait queues | ||
* | ||
* @author Mihai Renea <mihairenea@gmail.com> | ||
* @author Mihai Renea <mihai.renea@ml-pa.com> | ||
* @} | ||
*/ | ||
|
||
|
@@ -243,8 +243,9 @@ static uint64_t nested_cond_val = 0; | |
|
||
static bool cond_fn_wq(unsigned waiter_no) | ||
{ | ||
QUEUE_WAIT(&nested_wq, COUNTING_COND(nested_cond_iter_cnt, | ||
atomic_load_u64(&nested_cond_val) >= COND_VAL_THRESHOLD)); | ||
QUEUE_WAIT(&nested_wq, | ||
COUNTING_COND(nested_cond_iter_cnt, | ||
atomic_load_u64(&nested_cond_val) >= COND_VAL_THRESHOLD)); | ||
DEBUG("waiter %u: past inner wq\n", waiter_no); | ||
return atomic_load_u64(&cond_val) >= COND_VAL_THRESHOLD; | ||
} | ||
|
@@ -361,7 +362,6 @@ void test_waiters_blocking_wq(void) | |
nested_cond_val = 0; | ||
queue_wake(&nested_wq); | ||
|
||
|
||
nested_cond_iter_cnt_expected += WAITERS_CNT; | ||
expect(nested_wq.list != WAIT_QUEUE_TAIL); | ||
expect(atomic_load_u32(&nested_cond_iter_cnt) == nested_cond_iter_cnt_expected); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2025 Mihai Renea | ||
# Copyright (C) 2025 Mihai Renea <[email protected]> | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
|
||
# Author: Mihai Renea <mihairenea@gmail.com> | ||
# Author: Mihai Renea <mihai.renea@ml-pa.com> | ||
|
||
import sys | ||
from testrunner import run | ||
|