simplify Qeue, update some comments and include paths

This commit is contained in:
Niklas Gollenstede
2025-05-26 18:21:22 +02:00
committed by Eggert Jung
parent 68e11c9793
commit d9978ddc37
13 changed files with 55 additions and 93 deletions

View File

@@ -1,19 +1,6 @@
#include "bellringer.h"
#include "./bellringer.h"
#include "../interrupt/guard.h"
#include "../thread/thread.h"
struct Bell {
// link pointer to the next bell in the bellringers bell list
Bell *queue_link[1] = {nullptr};
Thread *thread;
size_t counter;
};
Bell **Bellringer::bell_link(Bell &obj, unsigned link_index) {
return &obj.queue_link[link_index];
}
// check: Checks whether bells are running out of time and rings them if
// necessary

View File

@@ -4,10 +4,10 @@
#pragma once
#include "../object/queue.h"
#include "../thread/thread.h"
#include "../types.h"
struct Vault;
struct Bell;
/*! \brief Manages and activates time-triggered activities.
* \ingroup ipc
@@ -24,6 +24,14 @@ class Bellringer {
Bellringer(const Bellringer&) = delete;
Bellringer& operator=(const Bellringer&) = delete;
struct Bell {
// link pointer to the next bell in the bellringers bell list
Bell* queue_link = nullptr;
Thread* thread;
size_t counter;
};
/*! \brief List of bells currently managed.
*
* This list contains non-expired bells enqueued by job().
@@ -34,26 +42,26 @@ class Bellringer {
*/
Queue<Bell> bells;
//! Link pointer for bells
static Bell** bell_link(Bell& obj, unsigned link_index);
public:
// constructor
Bellringer() : bells(0, bell_link) {}
Bellringer() : bells() {}
/*! \brief Checks whether there are bells to be rung.
*
* Every call to check elapses a tick. Once such a tick reduces a bells
* remaining time to zero, the bell will be rung.
*
* \param vault The vault containing the bellringer instance
*
* \todo(16) Implement Method
*/
void check(Vault& vault);
/*! \brief Passes a `bell` to the bellringer to be rung after `ms`
* milliseconds.
* \param bell Bell that should be rung after `ms` milliseconds
* \param ms number of milliseconds that should be waited before
*
* \param vault The vault containing the bellringer instance
* \param ms Number of milliseconds that should be waited before
* ringing the bell
*
* \todo(16) Implement Method

View File

@@ -1,16 +1,7 @@
#include "./semaphore.h"
#include "../interrupt/guard.h"
#include "../thread/thread.h"
Semaphore::Semaphore(unsigned c) { (void)c; }
Thread **Semaphore::thread_link(Thread &obj, unsigned link_index) {
(void)obj;
(void)link_index;
return nullptr;
}
void Semaphore::p(Vault &vault) { (void)vault; }
void Semaphore::v(Vault &vault) { (void)vault; }

View File

@@ -26,8 +26,6 @@ class Semaphore {
Semaphore(const Semaphore&) = delete;
Semaphore& operator=(const Semaphore&) = delete;
static Thread** thread_link(Thread& obj, unsigned link_index);
public:
/*! \brief Constructor; initialized the counter with provided value `c`
* \param c Initial counter value

View File

@@ -3,6 +3,7 @@
*/
#pragma once
#include "../types.h"
#include "../arch/core.h"
#include "../arch/cache.h"