Browse Source

将进程同步原语移动到common文件夹下

fslongjin 2 years ago
parent
commit
a02acbdbe6

+ 1 - 1
docs/kernel/core_api/atomic.md

@@ -2,7 +2,7 @@
 
 ## 简介
 
-  DragonOS实现了原子变量,类型为atomic_t. 原子变量是基于具体体系结构的原子操作指令实现的。具体实现在`kernel/process/atomic.h`中。
+  DragonOS实现了原子变量,类型为atomic_t. 原子变量是基于具体体系结构的原子操作指令实现的。具体实现在`kernel/common/atomic.h`中。
 
 ## API
 

+ 4 - 1
kernel/common/Makefile

@@ -3,7 +3,7 @@ CFLAGS += -I .
 
 kernel_common_subdirs:=libELF math
 
-all: glib.o printk.o cpu.o bitree.o kfifo.o
+all: glib.o printk.o cpu.o bitree.o kfifo.o wait_queue.o
 	@list='$(kernel_common_subdirs)'; for subdir in $$list; do \
     		echo "make all in $$subdir";\
     		cd $$subdir;\
@@ -25,3 +25,6 @@ bitree.o: bitree.c
 
 kfifo.o: kfifo.c
 	gcc $(CFLAGS) -c kfifo.c -o kfifo.o
+
+wait_queue.o: wait_queue.c
+	gcc $(CFLAGS) -c wait_queue.c -o wait_queue.o

+ 0 - 0
kernel/process/atomic.h → kernel/common/atomic.h


+ 1 - 1
kernel/common/printk.c

@@ -5,7 +5,7 @@
 #include "kprint.h"
 #include <driver/multiboot2/multiboot2.h>
 #include <mm/mm.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 #include <driver/uart/uart.h>
 #include <driver/video/video.h>

+ 1 - 1
kernel/process/semaphore.h → kernel/common/semaphore.h

@@ -10,7 +10,7 @@
  */
 
 #pragma once
-#include <process/atomic.h>
+#include <common/atomic.h>
 
 #include <process/process.h>
 #include <sched/sched.h>

+ 0 - 0
kernel/process/spinlock.h → kernel/common/spinlock.h


+ 0 - 0
kernel/process/wait_queue.c → kernel/common/wait_queue.c


+ 0 - 0
kernel/process/wait_queue.h → kernel/common/wait_queue.h


+ 1 - 1
kernel/driver/disk/block_device.h

@@ -2,7 +2,7 @@
 
 #include <common/glib.h>
 #include "stdint.h"
-#include <process/semaphore.h>
+#include <common/semaphore.h>
 
 #define BLK_TYPE_AHCI 0
 struct block_device_operation

+ 2 - 2
kernel/driver/keyboard/ps2_keyboard.c

@@ -4,8 +4,8 @@
 #include <mm/slab.h>
 #include <common/printk.h>
 #include <filesystem/VFS/VFS.h>
-#include <process/wait_queue.h>
-#include <process/spinlock.h>
+#include <common/wait_queue.h>
+#include <common/spinlock.h>
 #include <common/kfifo.h>
 
 // 键盘输入缓冲区

+ 1 - 1
kernel/driver/timers/HPET/HPET.c

@@ -10,7 +10,7 @@
 #include <smp/ipi.h>
 #include <driver/video/video.h>
 #include <driver/interrupt/apic/apic_timer.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 static struct acpi_HPET_description_table_t *hpet_table;
 static uint64_t HPET_REG_BASE = 0;

+ 1 - 1
kernel/driver/usb/usb.c

@@ -3,7 +3,7 @@
 #include <common/kprint.h>
 #include <driver/pci/pci.h>
 #include <debug/bug.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 extern spinlock_t xhci_controller_init_lock; // xhci控制器初始化锁
 

+ 1 - 1
kernel/driver/usb/xhci/xhci.c

@@ -1,7 +1,7 @@
 #include "xhci.h"
 #include <common/kprint.h>
 #include <debug/bug.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 #include <mm/mm.h>
 #include <mm/slab.h>
 #include <debug/traceback/traceback.h>

+ 1 - 1
kernel/driver/video/video.c

@@ -6,7 +6,7 @@
 #include <common/kprint.h>
 #include <mm/mm.h>
 #include <mm/slab.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 #include <exception/softirq.h>
 
 // 每个时刻只能有1个进程新增定时任务

+ 1 - 1
kernel/exception/softirq.c

@@ -2,7 +2,7 @@
 #include <common/kprint.h>
 #include <process/process.h>
 #include <driver/video/video.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 static spinlock_t softirq_modify_lock; // 软中断状态(status)
 static volatile uint64_t softirq_pending = 0;

+ 1 - 1
kernel/filesystem/fat32/fat32.c

@@ -2,7 +2,7 @@
 #include <common/kprint.h>
 #include <driver/disk/ahci/ahci.h>
 #include <filesystem/MBR.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 #include <mm/slab.h>
 #include <common/errno.h>
 #include <common/stdio.h>

+ 2 - 3
kernel/process/Makefile

@@ -1,5 +1,5 @@
 
-all: procs.o process.o wait_queue.o
+all: procs.o process.o
 
 CFLAGS += -I .
 
@@ -12,8 +12,7 @@ procs.o: proc.S
 process.o: process.c
 	gcc $(CFLAGS) -c process.c -o process.o
 
-wait_queue.o: wait_queue.c
-	gcc $(CFLAGS) -c wait_queue.c -o wait_queue.o
+
 
 clean:
 	echo "Done."

+ 1 - 1
kernel/process/process.c

@@ -11,7 +11,7 @@
 #include <exception/gate.h>
 #include <filesystem/fat32/fat32.h>
 #include <mm/slab.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 #include <syscall/syscall.h>
 #include <syscall/syscall_num.h>
 #include <sched/sched.h>

+ 1 - 1
kernel/process/process.h

@@ -17,7 +17,7 @@
 #include "ptrace.h"
 #include <common/errno.h>
 #include <filesystem/VFS/VFS.h>
-#include <process/wait_queue.h>
+#include <common/wait_queue.h>
 
 // 进程最大可拥有的文件描述符数量
 #define PROC_MAX_FD_NUM 16

+ 1 - 1
kernel/sched/sched.c

@@ -1,7 +1,7 @@
 #include "sched.h"
 #include <common/kprint.h>
 #include <driver/video/video.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 struct sched_queue_t sched_cfs_ready_queue[MAX_CPU_NUM]; // 就绪队列
 

+ 1 - 1
kernel/smp/smp.c

@@ -5,7 +5,7 @@
 #include <common/cpu.h>
 #include <mm/slab.h>
 #include <process/process.h>
-#include <process/spinlock.h>
+#include <common/spinlock.h>
 
 #include <sched/sched.h>