Fix braces + init_paging args
This commit is contained in:
@@ -34,8 +34,7 @@ void process_display_list(struct process_t* processes_list)
|
||||
{
|
||||
int process_view_id = 0;
|
||||
struct process_t* tmp = processes_list;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
while (tmp != NULL) {
|
||||
DEBUG("{%d: %p} -> ", process_view_id, tmp);
|
||||
tmp = tmp->next;
|
||||
process_view_id++;
|
||||
@@ -47,7 +46,6 @@ struct process_t* process_create(char* name, void(*function)(void*), void* arg)
|
||||
{
|
||||
CLEAR_INTERRUPTS;
|
||||
struct process_t* proc = (struct process_t*)kmalloc(sizeof(struct process_t));
|
||||
|
||||
struct cpu_status_t* ctx = (struct cpu_status_t*)kmalloc(sizeof(struct cpu_status_t));
|
||||
|
||||
// No more memory?
|
||||
@@ -88,29 +86,25 @@ void process_add(struct process_t** processes_list, struct process_t* process)
|
||||
if (!process) return;
|
||||
process->next = NULL;
|
||||
|
||||
if (*processes_list == NULL)
|
||||
{
|
||||
if (*processes_list == NULL) {
|
||||
// List is empty
|
||||
*processes_list = process;
|
||||
return;
|
||||
}
|
||||
|
||||
struct process_t* tmp = *processes_list;
|
||||
while (tmp->next != NULL)
|
||||
{
|
||||
while (tmp->next != NULL) {
|
||||
tmp = tmp->next;
|
||||
}
|
||||
// We're at last process before NULL
|
||||
tmp->next = process;
|
||||
// process->next = NULL;
|
||||
}
|
||||
|
||||
void process_delete(struct process_t** processes_list, struct process_t* process)
|
||||
{
|
||||
if (!processes_list || !*processes_list || !process) return;
|
||||
|
||||
if (*processes_list == process)
|
||||
{
|
||||
if (*processes_list == process) {
|
||||
// process to delete is at head
|
||||
*processes_list = process->next;
|
||||
process->next = NULL;
|
||||
@@ -119,13 +113,11 @@ void process_delete(struct process_t** processes_list, struct process_t* process
|
||||
}
|
||||
|
||||
struct process_t* tmp = *processes_list;
|
||||
while (tmp->next && tmp->next != process)
|
||||
{
|
||||
while (tmp->next && tmp->next != process) {
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
if (tmp->next == NULL)
|
||||
{
|
||||
if (tmp->next == NULL) {
|
||||
// Didn't find the process
|
||||
return;
|
||||
}
|
||||
@@ -148,15 +140,12 @@ void process_exit()
|
||||
{
|
||||
DEBUG("Exiting from process '%s'", current_process->name);
|
||||
CLEAR_INTERRUPTS;
|
||||
if (current_process)
|
||||
{
|
||||
if (current_process) {
|
||||
current_process->status = DEAD;
|
||||
}
|
||||
SET_INTERRUPTS;
|
||||
|
||||
//outb(0x20, 0x20);
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
asm("hlt");
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,13 @@
|
||||
#include "config.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
READY,
|
||||
RUNNING,
|
||||
DEAD
|
||||
} status_t;
|
||||
|
||||
struct process_t
|
||||
{
|
||||
struct process_t {
|
||||
size_t pid;
|
||||
char name[PROCESS_NAME_MAX];
|
||||
|
||||
|
||||
@@ -22,13 +22,11 @@ void scheduler_init()
|
||||
|
||||
struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
|
||||
{
|
||||
if (context == NULL)
|
||||
{
|
||||
if (context == NULL) {
|
||||
panic(NULL, "Scheduler called with NULL context");
|
||||
}
|
||||
|
||||
if (current_process == NULL)
|
||||
{
|
||||
if (current_process == NULL) {
|
||||
// If no more processes, then set IDLE as the current process, that's it.
|
||||
current_process = idle_proc;
|
||||
}
|
||||
@@ -38,21 +36,17 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
|
||||
|
||||
for (;;) {
|
||||
struct process_t* prev_process = current_process;
|
||||
if (current_process->next != NULL)
|
||||
{
|
||||
if (current_process->next != NULL) {
|
||||
current_process = current_process->next;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
current_process = processes_list;
|
||||
}
|
||||
|
||||
if (current_process != NULL && current_process->status == DEAD)
|
||||
{
|
||||
if (current_process != NULL && current_process->status == DEAD) {
|
||||
process_delete(&prev_process, current_process);
|
||||
current_process = NULL;
|
||||
return idle_proc->context;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
current_process->status = RUNNING;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user