Skip to content

Commit

Permalink
fixes for_all_behind and compiling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anthongretter committed Oct 12, 2024
1 parent 95fe8a0 commit 2960e7a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.idea
# Gitignore personalizado
# Binários
app/*/*
Expand All @@ -20,5 +19,6 @@ img/*
eposcfg
eposmkbi

# VSCode
.vscode
# IDEs
.vscode
.idea
16 changes: 11 additions & 5 deletions include/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,18 @@ class Thread
// Tiramos o event da lista de argumentos pois ele pode receber o trigger no CREATE também
// não faz sentido passarmos CREATE para as outras threads, o EVENT é sempre um UPDATE

// Usado para atualizar os elementos partir de current para tras, da atual fila
static void for_all_behind(Queue::Iterator current) {
int queue = current->object()->criterion().queue();
for (; current != _scheduler.end(queue); current++)
// Mas para deixar extensivel acho melhor deixar como parametro,
// pq ai podemos passar evento personalizado, como, no nosso caso, o ASSURE_BEHIND

// fiz esta logica para que ele percorra todos os anteriores a sua subfila, revisem:

void for_all_behind(Criterion::Event event) {
for (Queue::Iterator behind = _link.prev();; behind--)
{
current->object()->criterion().handle(Criterion::UPDATE);
behind->object()->criterion().handle(event);
if (behind->prev() == nullptr || behind->rank() > behind->prev()->rank()) {
break;
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions include/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ class EAMQ: public RT_Common
Tick job_enter_time; // tempo que começa executar tarefa
Tick job_execution_time; // tempo de execução real da tarefa
Tick average_et; // tempo de execução média ponderada
Tick prev_execution_time; // tempo de execução da tarefa anterior
};
// global
struct Global_Statistics {
Criterion last_modification_record[QUEUES];
Priority last_modification_record[QUEUES];
bool occ_queues[QUEUES];
};
// struct Optimal_Case {
// int queue;
Expand All @@ -327,7 +327,7 @@ class EAMQ: public RT_Common
int rank_eamq(Microsecond p, Microsecond d, Microsecond c);

static void next_queue() { ++_current_queue %= QUEUES; CPU::clock(frequency_within(_current_queue)); }; // points to next global queue
static Hertz frequency_within(unsigned int queue) { CPU::max_clock() - (((CPU::max_clock() * 125) / 1000) * (queue % QUEUES)); };
static Hertz frequency_within(unsigned int queue) { return CPU::max_clock() - (((CPU::max_clock() * 125) / 1000) * (queue % QUEUES)); };

protected:
volatile unsigned int _queue;
Expand Down Expand Up @@ -358,7 +358,7 @@ int EAMQ::estimate_rp_waiting_time(unsigned int eet_profile, unsigned int lookin
int oc = 0;
for (unsigned int i = 0; i < QUEUES; i++)
{
if (i == looking_queue && !Thread::scheduler()->empty(looking_queue)) {
if (i == looking_queue && !_global_statistics.occ_queues[i]) {
continue;
}
// oc += int(_global_statistics.occ_queue[i]);
Expand Down
24 changes: 14 additions & 10 deletions src/api/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ LLF::LLF(Microsecond p, Microsecond d, Microsecond c): RT_Common(int(elapsed() +
void LLF::handle(Event event) {
if(periodic() && ((event & UPDATE) | (event & JOB_RELEASE) | (event & JOB_FINISH))) {
_priority = elapsed() + _deadline - _capacity + _statistics.job_utilization;
// tempo atual + deadline = ponto real de deadline
// capacidade (restante do job executar) + o que ja foi executado = total a executar
// ponto real de deadline - total a executar = slack
}
RT_Common::handle(event);

Expand Down Expand Up @@ -138,11 +135,15 @@ void EAMQ::handle(Event event) {
// }
// }
if (periodic() && (event & LEAVE)) {
Tick this_quantum = elapsed() - _personal_statistics.job_enter_time
Tick this_quantum = elapsed() - _personal_statistics.job_enter_time;
_personal_statistics.job_execution_time += this_quantum;
for (unsigned int q = 0; i < QUEUES; q++)
for (unsigned int q = 0; q < QUEUES; q++)
{
_personal_statistics.remaining_et[q] -= Timer_Common::time(this_quantum, frequency_within(q))
// nojo
// TODO: fazer operator -= em Microsecond
_personal_statistics.remaining_et[q] =
Time_Base(_personal_statistics.remaining_et[q])
- Time_Base(Timer_Common::time(this_quantum, frequency_within(q)));
}
}
if (periodic() && (event & JOB_FINISH)) {
Expand All @@ -156,9 +157,9 @@ void EAMQ::handle(Event event) {
_personal_statistics.average_et = (_personal_statistics.average_et + _personal_statistics.job_execution_time) / 2;
_personal_statistics.job_execution_time = 0;

for (unsigned int q = 0; i < QUEUES; q++)
for (unsigned int q = 0; q < QUEUES; q++)
{
_personal_statistics.job_estimated_et[q] = Timer_Common::time(_personal_statistics.average_et, frequency_within(q))
_personal_statistics.job_estimated_et[q] = Timer_Common::time(_personal_statistics.average_et, frequency_within(q));
}
}
// if ((periodic() && ((event & JOB_RELEASE) || (event & ENTER)))) {
Expand All @@ -169,7 +170,10 @@ void EAMQ::handle(Event event) {
_personal_statistics.job_enter_time = elapsed();
}
if (periodic() && (event & JOB_RELEASE)) {
_personal_statistics.remaining_et = _personal_statistics.job_estimated_et;
for (unsigned int q = 0; q < QUEUES; q++)
{
_personal_statistics.remaining_et[q] = _personal_statistics.job_estimated_et[q];
}
}

/* a = new Job() -> JOB_RELEASE, CREATE
Expand Down Expand Up @@ -207,7 +211,7 @@ int EAMQ::rank_eamq(Microsecond p, Microsecond d, Microsecond c) {
Thread * thread_in_queue = it->object();
// Thread da frente -> Tf
// Thread que será inserido -> Ti
int thread_capacity_remaining = thread_in_queue->criterion()->personal_statistics().remaining_et[i];
int thread_capacity_remaining = thread_in_queue->criterion().personal_statistics().remaining_et[i];
int total_time_execution = thread_in_queue->priority() //tempo de espera da (Tf)
+ static_cast<int>(thread_capacity_remaining*1.15) //tempo de execução da (Tf)
+ eet_remaining //tempo de execução (Ti)
Expand Down

0 comments on commit 2960e7a

Please sign in to comment.