Compare commits
10 Commits
9ffd22e941
...
6951311c9c
| Author | SHA1 | Date |
|---|---|---|
|
|
6951311c9c | 4 months ago |
|
|
9d525a9602 | 4 months ago |
|
|
42f2dd6028 | 4 months ago |
|
|
68cb30210f | 4 months ago |
|
|
370e76bfc4 | 4 months ago |
|
|
fd021c98a7 | 4 months ago |
|
|
5611b7f886 | 4 months ago |
|
|
c175c49945 | 4 months ago |
|
|
9023944e92 | 4 months ago |
|
|
cc412f4902 | 4 months ago |
@ -1,16 +1,38 @@
|
||||
#include "./bellringer.h"
|
||||
|
||||
#include "../interrupt/guard.h"
|
||||
|
||||
// check: Checks whether bells are running out of time and rings them if
|
||||
// necessary
|
||||
void Bellringer::check(Vault &vault) { (void)vault; }
|
||||
void Bellringer::check(Vault &vault) {
|
||||
auto first = vault.bellringer.bells.dequeue();
|
||||
first->counter--;
|
||||
if (vault.bellringer.bellPending()){
|
||||
vault.bellringer.bells.insertFirst(*first);
|
||||
}
|
||||
if (vault.bellringer.bellPending()){
|
||||
if (first->counter < 1) {
|
||||
vault.sch.ready(vault.bellringer.bells.dequeue()->thread);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// job: Give a bell to the bellringer & ring it when the specified time ran out.
|
||||
void Bellringer::sleep(Vault &vault, unsigned int ms) {
|
||||
(void)vault;
|
||||
(void)ms;
|
||||
Bell bell;
|
||||
bell.thread = vault.sch.dispatcher.active();
|
||||
auto tmp = vault.bellringer.bells.dequeue();
|
||||
vault.bellringer.bells.insertFirst(*tmp);
|
||||
do{
|
||||
ms-=tmp->counter;
|
||||
} while ((tmp=vault.bellringer.bells.next(*tmp)) != nullptr );
|
||||
bell.counter = ms;
|
||||
vault.sch.resume(false);
|
||||
}
|
||||
|
||||
// Are there bells in the queue?
|
||||
bool Bellringer::bellPending() const { return false; }
|
||||
bool Bellringer::bellPending() const {
|
||||
if (bells.is_empty())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue