The Wayback Machine - https://web.archive.org/web/20201213052931/https://github.com/codyd51/axle/pull/39
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup tasking #39

Open
wants to merge 40 commits into
base: master
from
Open

Fixup tasking #39

wants to merge 40 commits into from

Conversation

@codyd51
Copy link
Owner

@codyd51 codyd51 commented Jun 27, 2018

Major changes:

  • Deprecate existing multitasking code, and implement a new tasking system. task_t has been superseded by task_small_t. I have not removed existing task_t code so that it can be present for reference while enabling more preexisting kernel features, but all functions have been explicitly marked deprecated.

  • Added a new system for invoking a callback when a specified interrupt vector is ran. Importantly, the callbacks are ran after the kernel's interrupt handling has completed. As a result of this, it is safe for these callbacks to do significant work: as the interrupt has been processed and the end-of-interrupt has been sent, it is safe for these callbacks to perform actions such as forcing a context switch. This system is mostly a copy of the timer callback system, with a hook into the global interrupt handler instead of into the PIT interrupt handler.

  • Thanks to the above, the timer system has been split from the PIT interrupt handler.

  • Mouse driver reenabled.

codyd51 added 30 commits Jun 27, 2018
…is from the PIT (bad, I should have a system for post-EOI-signal interrupt callbacks)
…e their parent's VMM. new VMMs are not actually created for tasks yet.

also, add a round robin scheduler, and refactor function to context switch to a provided task
@@ -104,7 +108,6 @@ void fill_screen(Screen* screen, Color color) {
if (screen->vmem) {
write_screen(screen);
}
reset_cursor_pos();

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

No reason for this to be here.

@@ -119,19 +119,15 @@ void blit_layer_filled(ca_layer* dest, ca_layer* src, Rect dest_frame, Rect src_

//figure out how many px we can actually transfer over,
//in case src_frame exceeds dest
int transferabble_px = src_frame.size.width * gfx_bpp();
int overhang = (uint32_t)dest_row_start + (uint32_t)row_start + transferabble_px - rect_max_x(dest_frame);

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

The math here pretty much makes no sense. dest_row_start and row_start point to two different malloc'd blocks. I have no idea what I was trying to achieve by adding them.
Additionally, blit_layer already handles sanity-checking the frames to try to prevent against any writes outside of the provided layers, so there should be no reason for this check at all.

@@ -69,35 +69,46 @@ uint8_t mouse_events() {
return mouse_state;
}

void update_mouse_position(int x, int y) {
void mouse_reset_cursorpos() {

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

Lets try to keep to name spacing functions in the future.

running_y = MAX(running_y, 0);
running_y = MIN(running_y, dimensions.height - 5);
_mouse_constrain_to_screen_size();
printk_dbg("mouse: (%d, %d)", running_x, running_y);

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

Refactored some work in this method. I'm not sure what kind of sign it is that a lot of axle's code I'm seeing (that I myself wrote) is pretty clearly bad.

@@ -2,12 +2,16 @@
#define PIT_H

#include <std/common.h>
#include <kernel/interrupts/interrupts.h>

#define PIT_INT_VECTOR INT_VECOR_IRQ0

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

We should start defining the interrupt vectors that drivers subscribe to.

static void context_switch(register_state_t* regs);
static int tick_callback(register_state_t* regs) {
tick++;
_timer_handle_pit_tick(regs);

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

The timer system is no longer coupled to the PIT driver.

static timer_callback_t* pit_callback = 0;
const uint32_t _task_context_offset = offsetof(struct task_small, machine_state);

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

We record the offset of the machine_state field as it's the simplest way to be able to reference the offset from context_switch (which is in assembly)

}
panic("couldn't find runnable task");
}

This comment has been minimized.

@codyd51

codyd51 Jul 12, 2018
Author Owner

Simple round-robin scheduler. The MLFQ scheduler should be reenabled in the future once the responsiveness of the system would benefit from it.

@codyd51 codyd51 requested review from uroboro and inoahdev and removed request for inoahdev Jul 12, 2018
running_y = s->resolution.height / 2;
running_x = 400;
running_y = 100;
}

This comment has been minimized.

@uroboro

uroboro Jul 13, 2018
Collaborator

What's going on here?

running_x = MIN(running_x, dimensions.width - 5);
running_y = MAX(running_y, 0);
running_y = MIN(running_y, dimensions.height - 5);
}

This comment has been minimized.

@uroboro

uroboro Jul 13, 2018
Collaborator

These macros could be fit into a single one, usually named clamp.

if (!found) {
panic("tried to delete nonexistant interrupt callback. investigate!");
}
memset(callback, 0, sizeof(int_notify_callback_t));

This comment has been minimized.

@uroboro

uroboro Jul 13, 2018
Collaborator

It's a bit odd that callback is the one being cleared instead of callback_table[i] (even if they're the same).

if ((iter)->next == NULL) {
return iter;
}
iter = (iter)->next;
}
panic("more than 16 tasks in runlist. increase me?");
panic("more than MAX_TASKS tasks in runlist. increase me?");

This comment has been minimized.

@uroboro

uroboro Jul 13, 2018
Collaborator

Does panic take varargs to be able to print the value of MAX_TASKS?

This comment has been minimized.

@codyd51

codyd51 Jul 13, 2018
Author Owner

Unfortunately not, though it should in the future.

This comment has been minimized.

@uroboro

uroboro Jul 13, 2018
Collaborator

How about panic("more than MAX_TASKS(" STR(MAX_TASKS) ") tasks in runlist. increase me?"); where STR expands the value of MAX_TASKS and then stringifies that with #?

codyd51 added 2 commits Aug 30, 2018
also, when a frame for a new page table is allocated, it is immediately memset to 0 prevent garbage page mappings
return new_task;
}
}

This comment has been minimized.

@filfat

filfat Jan 3, 2019
Contributor

Double '}'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.