⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel_struct.h

📁 国内一位牛人自己开发的操作系统
💻 H
字号:
#ifndef OS_KERNEL_STRUCT
#define OS_KERNEL_STRUCT

struct semaphore{
	int value;
	int process;
	int thread_id,thread_ring;
	int front,back;
	struct capability capability;

	int heap,v_value;
	struct kernel_time first,step;
};

struct thread ;
struct return_stack ;

struct thread_environment{
	int system_call,system_call_arg1;	/*ax,bx*/
	int system_call_arg2,system_call_arg3;	/*cx,dx*/
	int system_call_arg4,system_call_arg5;	/*si,di*/
	int system_call_arg6,system_call_arg7;	/*bp,r7*/	
	run_point point;			/*ip,cs,flag,sp,ss */
};

#define COPY_THREAD_ENVIRONMENT(s,d)			\
{							\
	(d).system_call=(s).system_call;		\
	(d).system_call_arg1=(s).system_call_arg1;	\
	(d).system_call_arg2=(s).system_call_arg2;	\
	(d).system_call_arg3=(s).system_call_arg3;	\
	(d).system_call_arg4=(s).system_call_arg4;	\
	(d).system_call_arg5=(s).system_call_arg5;	\
	(d).system_call_arg6=(s).system_call_arg6;	\
	(d).system_call_arg7=(s).system_call_arg7;	\
}

#define RESET_THREAD_PARAMETER(env)			\
{							\
	(env).point.function=(int (*)(void))0;		\
}

#define RESET_THREAD_ENVIRONMENT(env)			\
{							\
	RESET_RUN_POINT((env).point);			\
	RESET_THREAD_PARAMETER(env);			\
}

struct exception_item{
	int flag;
};

#define COPY_EXCEPTION_ITEM(s,d)	{(d).flag=(s).flag;}
#define RESET_EXCEPTION_ITEM(x)		{(x).flag=FALSE;}

struct return_stack{
	struct thread_environment environment;
	int current_process,process_id,process_p_flag;
	struct exception_item exception;
	struct thread_physical_block physical_block;
};

struct thread{
	enum {SLEEP,RUN,READY} state;
	int priority;
	int set_v_operation_result_flag;
	int heap,process,pro_front,pro_back;
	int semaphore,sleep_semaphore,sem_front,sem_back;
	int cpu_id;
	struct return_stack return_stack[RETURN_BLOCK_NUMBER];
	int return_stack_top;
	struct user_file_information file[USER_FILE_NUMBER];
};

struct thread_heap{
	int thread;
};

#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -