Tweaks to scheduling (priority) and fixes for the shell
This commit is contained in:
parent
07328a4267
commit
c2bb04a56e
44
gui.c
44
gui.c
@ -77,6 +77,23 @@ int wallpaper_lock = 0;
|
|||||||
|
|
||||||
struct ModeInfoBlock *modeinfo = (void *)0;
|
struct ModeInfoBlock *modeinfo = (void *)0;
|
||||||
|
|
||||||
|
static void gui_window_set_focus(struct window_t *win) {
|
||||||
|
if (win->focused) return;
|
||||||
|
|
||||||
|
for (int i = 0;i < window_count; i++) {
|
||||||
|
if (windows[i]->focused) {
|
||||||
|
windows[i]->focused = 0;
|
||||||
|
windows[i]->mytask->priority -= 10;
|
||||||
|
if (windows[i]->mytask->priority < 1) {
|
||||||
|
windows[i]->mytask->priority = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
win->mytask->priority += 10;
|
||||||
|
win->focused = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void init_gui(multiboot_info_t *mbinfo) {
|
void init_gui(multiboot_info_t *mbinfo) {
|
||||||
if (mbinfo->flags & 1 << 11) {
|
if (mbinfo->flags & 1 << 11) {
|
||||||
serialnos = 0;
|
serialnos = 0;
|
||||||
@ -333,7 +350,6 @@ extern int gui_change_window_caption(int serialno, char *cap) {
|
|||||||
|
|
||||||
int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int h, unsigned char *icon, unsigned int flags, void (*keyboard_d)(unsigned char c, unsigned char state)) {
|
int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int h, unsigned char *icon, unsigned int flags, void (*keyboard_d)(unsigned char c, unsigned char state)) {
|
||||||
struct window_t *new_window;
|
struct window_t *new_window;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (window_count == 0) {
|
if (window_count == 0) {
|
||||||
windows = (struct window_t **)dbmalloc(sizeof(struct window_t *), "gui: add window (malloc)");
|
windows = (struct window_t **)dbmalloc(sizeof(struct window_t *), "gui: add window (malloc)");
|
||||||
@ -356,7 +372,7 @@ int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int
|
|||||||
new_window->mclick = 0;
|
new_window->mclick = 0;
|
||||||
new_window->flags = flags;
|
new_window->flags = flags;
|
||||||
new_window->event_msg_count = 0;
|
new_window->event_msg_count = 0;
|
||||||
|
new_window->focused = 0;
|
||||||
|
|
||||||
if (contents == (void *)0) {
|
if (contents == (void *)0) {
|
||||||
new_window->contents = (unsigned char *)malloc(w * h * depth);
|
new_window->contents = (unsigned char *)malloc(w * h * depth);
|
||||||
@ -380,15 +396,12 @@ int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int
|
|||||||
|
|
||||||
strncpy(new_window->name, name, 128);
|
strncpy(new_window->name, name, 128);
|
||||||
new_window->zorder = window_count;
|
new_window->zorder = window_count;
|
||||||
new_window->focused = 1;
|
|
||||||
|
|
||||||
for (i = 0;i < window_count; i++) {
|
|
||||||
windows[i]->focused = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
windows[window_count] = new_window;
|
windows[window_count] = new_window;
|
||||||
window_count++;
|
window_count++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
keyboard_set_handler(new_window->keyboard_dest);
|
keyboard_set_handler(new_window->keyboard_dest);
|
||||||
|
|
||||||
if (current_task != (void *)0) {
|
if (current_task != (void *)0) {
|
||||||
@ -402,6 +415,10 @@ int gui_add_window(unsigned char *contents, char *name, int x, int y, int w, int
|
|||||||
current_task->window_count++;
|
current_task->window_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_window->mytask = current_task;
|
||||||
|
|
||||||
|
gui_window_set_focus(new_window);
|
||||||
|
|
||||||
return new_window->serialno;
|
return new_window->serialno;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +450,7 @@ void gui_destroy_window(int serialno, struct task_t *task) {
|
|||||||
window_count--;
|
window_count--;
|
||||||
|
|
||||||
if (win->focused && window_count > 0) {
|
if (win->focused && window_count > 0) {
|
||||||
windows[window_count - 1]->focused = 1;
|
gui_window_set_focus(windows[window_count - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
windows = (struct window_t **)realloc(windows, sizeof(struct window_t *) * window_count);
|
windows = (struct window_t **)realloc(windows, sizeof(struct window_t *) * window_count);
|
||||||
@ -556,14 +573,12 @@ void gui_sink_to_bottom(int wh) {
|
|||||||
|
|
||||||
for (int i = wh; i >= 1; i--) {
|
for (int i = wh; i >= 1; i--) {
|
||||||
windows[i] = windows[i - 1];
|
windows[i] = windows[i - 1];
|
||||||
windows[i]->focused = 0;
|
|
||||||
windows[i]->zorder++;
|
windows[i]->zorder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
windows[0] = win;
|
windows[0] = win;
|
||||||
windows[0]->zorder = 0;
|
windows[0]->zorder = 0;
|
||||||
windows[0]->focused = 0;
|
gui_window_set_focus(windows[window_count - 1]);
|
||||||
windows[window_count-1]->focused = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int gui_raise_to_icon_top(int wh) {
|
int gui_raise_to_icon_top(int wh) {
|
||||||
@ -594,18 +609,13 @@ void gui_raise_to_top(int wh) {
|
|||||||
struct window_t *win;
|
struct window_t *win;
|
||||||
win = windows[wh];
|
win = windows[wh];
|
||||||
|
|
||||||
for (int i = 0; i < wh; i++) {
|
|
||||||
windows[i]->focused = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = wh; i < window_count - 1; i++) {
|
for (int i = wh; i < window_count - 1; i++) {
|
||||||
windows[i] = windows[i+1];
|
windows[i] = windows[i+1];
|
||||||
windows[i]->zorder--;
|
windows[i]->zorder--;
|
||||||
windows[i]->focused = 0;
|
|
||||||
}
|
}
|
||||||
windows[window_count - 1] = win;
|
windows[window_count - 1] = win;
|
||||||
windows[window_count - 1]->zorder = window_count - 1;
|
windows[window_count - 1]->zorder = window_count - 1;
|
||||||
windows[window_count - 1]->focused = 1;
|
gui_window_set_focus(windows[window_count - 1]);
|
||||||
keyboard_set_handler(windows[window_count - 1]->keyboard_dest);
|
keyboard_set_handler(windows[window_count - 1]->keyboard_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
gui.h
1
gui.h
@ -45,6 +45,7 @@ struct window_t {
|
|||||||
unsigned char lclick;
|
unsigned char lclick;
|
||||||
unsigned char rclick;
|
unsigned char rclick;
|
||||||
unsigned char mclick;
|
unsigned char mclick;
|
||||||
|
struct task_t *mytask;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void init_gui(multiboot_info_t *mbinfo);
|
extern void init_gui(multiboot_info_t *mbinfo);
|
||||||
|
@ -486,7 +486,15 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
free(porig);
|
free(porig);
|
||||||
}
|
}
|
||||||
|
if (!found) {
|
||||||
|
// try cwd
|
||||||
|
sprintf(buffer, "%s:%s%s", current_drive, cwd, argv_s[0]);
|
||||||
|
if (!stat(buffer, &s)) {
|
||||||
|
if (S_ISREG(s.st_mode)) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (argv_s[0][0] == '/') {
|
if (argv_s[0][0] == '/') {
|
||||||
strcpy(buffer2, argv_s[0]);
|
strcpy(buffer2, argv_s[0]);
|
||||||
|
13
schedule.c
13
schedule.c
@ -111,6 +111,7 @@ void init_scheduler(void) {
|
|||||||
current_task->cr3 = page_directory;
|
current_task->cr3 = page_directory;
|
||||||
current_task->kstack = _sys_stack + KRNL_STACK_SIZE;
|
current_task->kstack = _sys_stack + KRNL_STACK_SIZE;
|
||||||
current_task->state = TASK_RUNNING;
|
current_task->state = TASK_RUNNING;
|
||||||
|
current_task->priority = 1;
|
||||||
first_task = current_task;
|
first_task = current_task;
|
||||||
last_task = current_task;
|
last_task = current_task;
|
||||||
strcpy(current_task->name, "KERNEL");
|
strcpy(current_task->name, "KERNEL");
|
||||||
@ -157,7 +158,6 @@ void sched_free_task(struct task_t *this_task) {
|
|||||||
// free stack virt space
|
// free stack virt space
|
||||||
|
|
||||||
for (i=0;i<this_task->window_count;i++) {
|
for (i=0;i<this_task->window_count;i++) {
|
||||||
|
|
||||||
gui_destroy_window(this_task->window_list[i]->serialno, this_task);
|
gui_destroy_window(this_task->window_list[i]->serialno, this_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ void schedule(struct regs *r) {
|
|||||||
unsigned int *status;
|
unsigned int *status;
|
||||||
unsigned int *wait_return;
|
unsigned int *wait_return;
|
||||||
|
|
||||||
if (block_buffer_trim_timer == 20) {
|
if (block_buffer_trim_timer == 200) {
|
||||||
hd_buffer_trim();
|
hd_buffer_trim();
|
||||||
block_buffer_trim_timer = 0;
|
block_buffer_trim_timer = 0;
|
||||||
}
|
}
|
||||||
@ -294,11 +294,8 @@ void schedule(struct regs *r) {
|
|||||||
}
|
}
|
||||||
if (previous_task != current_task) {
|
if (previous_task != current_task) {
|
||||||
// do switch
|
// do switch
|
||||||
if (current_task == first_task) {
|
current_task->timetorun = current_task->priority;
|
||||||
current_task->timetorun = 1;
|
|
||||||
} else {
|
|
||||||
current_task->timetorun = 5;
|
|
||||||
}
|
|
||||||
fpu_disable();
|
fpu_disable();
|
||||||
|
|
||||||
if (r->int_no == 0x30) {
|
if (r->int_no == 0x30) {
|
||||||
@ -309,7 +306,6 @@ void schedule(struct regs *r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct task_t *sched_new_task() {
|
struct task_t *sched_new_task() {
|
||||||
struct task_t *new_task = (struct task_t *)malloc(sizeof(struct task_t));
|
struct task_t *new_task = (struct task_t *)malloc(sizeof(struct task_t));
|
||||||
memset(new_task, 0, sizeof(struct task_t));
|
memset(new_task, 0, sizeof(struct task_t));
|
||||||
@ -338,6 +334,7 @@ struct task_t *sched_new_task() {
|
|||||||
new_task->waiting_socket_count = 0;
|
new_task->waiting_socket_count = 0;
|
||||||
new_task->sem_count = 0;
|
new_task->sem_count = 0;
|
||||||
new_task->cwd = (char *)malloc(strlen(current_task->cwd) + 1);
|
new_task->cwd = (char *)malloc(strlen(current_task->cwd) + 1);
|
||||||
|
new_task->priority = 5;
|
||||||
strcpy(new_task->cwd, current_task->cwd);
|
strcpy(new_task->cwd, current_task->cwd);
|
||||||
strcpy(new_task->name, current_task->name);
|
strcpy(new_task->name, current_task->name);
|
||||||
int i;
|
int i;
|
||||||
|
@ -59,6 +59,7 @@ struct task_t {
|
|||||||
unsigned int *user_pages_virt;
|
unsigned int *user_pages_virt;
|
||||||
unsigned int user_stack_pages[USER_STACK_SIZE / 0x1000];
|
unsigned int user_stack_pages[USER_STACK_SIZE / 0x1000];
|
||||||
unsigned int user_env_pages[64];
|
unsigned int user_env_pages[64];
|
||||||
|
unsigned int priority;
|
||||||
struct vfs_device_t *selected_device;
|
struct vfs_device_t *selected_device;
|
||||||
char *cwd;
|
char *cwd;
|
||||||
struct window_t **window_list;
|
struct window_t **window_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user