1 #pragma once
2 #include <common/glib.h>
3 
4 #pragma GCC push_options
5 #pragma GCC optimize("O0")
6 struct process_control_block;
7 // 获取当前的pcb
get_current_pcb()8 struct process_control_block *get_current_pcb()
9 {
10 	struct process_control_block *current = NULL;
11 	// 利用了当前pcb和栈空间总大小为32k大小对齐,将rsp低15位清空,即可获得pcb的起始地址
12 	barrier();
13 	__asm__ __volatile__("andq %%rsp, %0   \n\t"
14 						 : "=r"(current)
15 						 : "0"(~32767UL));
16 	barrier();
17 	return current;
18 };
19 #define current_pcb get_current_pcb()
20 #pragma GCC pop_options