[SMP] SMP synchronization and scheduling
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
6
kernel/include/sync.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
typedef uint64_t lock_t;
|
||||
|
||||
void spin_lock(lock_t *lock);
|
||||
void spin_unlock(lock_t *lock);
|
||||
Reference in New Issue
Block a user