[SMP] SMP synchronization and scheduling

This commit is contained in:
2016-11-18 09:36:01 +01:00
parent 8961ae33eb
commit 474914ab1e
12 changed files with 69 additions and 18 deletions

View File

@@ -20,6 +20,7 @@
#include <gdt.h>
#include <process.h>
#include <thread.h>
#include <scheduler.h>
typedef struct cpu_t
{
@@ -51,6 +52,7 @@ void ap_init(cpu_t *cpu);
void trampoline();
void trampoline_GDT();
#endif

View File

@@ -1,9 +1,10 @@
#pragma once
#include <string.h>
#include <int.h>
#include <sync.h>
#ifndef NDEBUG
#define debug(...) debug_printf(__VA_ARGS__)
#define debug(...) ({spin_lock(&debug_lock);debug_printf(__VA_ARGS__);spin_unlock(&debug_lock);})
#else
#define debug(...) ((void)0)
#endif
@@ -12,6 +13,8 @@
#define debug_warning(...) do{debug("[WARNING] ");debug(__VA_ARGS__);}while(0)
#define debug_error(...) do{debug("[ERROR] ");debug(__VA_ARGS__);}while(0)
extern lock_t debug_lock;
void debug_init();
void debug_putch(char c);
void debug_putsn(char *s, size_t n);

View File

@@ -4,12 +4,14 @@ typedef struct process_st process_t;
#include <thread.h>
#include <mem.h>
#include <cpu.h>
#include <sync.h>
typedef struct process_st
{
uint64_t pid;
uint64_t state;
uint64_t status;
lock_t lock;
struct process_st *parent;
page_table *P4;
LIST(struct process_st, children);

6
kernel/include/sync.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
typedef uint64_t lock_t;
void spin_lock(lock_t *lock);
void spin_unlock(lock_t *lock);