操作系统学习笔记(29)--初始化Trap
2010-06-01 22:30
274 查看
和中断处理类似
1 写Trap处理函数
2 在Trap号中添加该函数地址
在中断处理号中添加Trap处理函数地址即可。
Trap Gate和中断Gate是一样的。
Interrupt 12—Stack Fault Exception(#SS)
Interrupt 13—General Protection Exception (#GP)
下面的是个简单实例
1 写Trap处理函数
2 在Trap号中添加该函数地址
在中断处理号中添加Trap处理函数地址即可。
Trap Gate和中断Gate是一样的。
Interrupt 12—Stack Fault Exception(#SS)
Interrupt 13—General Protection Exception (#GP)
下面的是个简单实例
/* * Handler for general protection faults and other bad errors. * Kill the current thread (which caused the fault). */ static void GPF_Handler(struct Interrupt_State* state) { /* Send the thread to the reaper... */ Print("Exception %d received, killing thread %p/n", state->intNum, g_currentThread); Dump_Interrupt_State(state); Exit(-1); /* We will never get here */ KASSERT(false); } /* * Initialize handlers for processor traps. */ void Init_Traps(void) { Install_Interrupt_Handler(12, &GPF_Handler); /* stack exception */ Install_Interrupt_Handler(13, &GPF_Handler); /* general protection fault */ }
相关文章推荐
- 操作系统学习笔记(26)--TSS初始化
- 操作系统学习笔记(27)--初始化中断
- 操作系统学习笔记(28)--初始化进程调度
- 操作系统学习笔记(31)--初始化键盘
- Linux学习笔记29——IPC状态命令
- IOS学习笔记29—提示框第三方库之MBProgressHUD
- 操作系统学习笔记:保护
- 操作系统学习笔记-引论
- 操作系统学习笔记
- 32位汇编语言学习笔记(29)--在NASM中使用宏
- snmp学习笔记之一——配置使用trap
- 操作系统学习笔记(二) --操作系统结构
- linux内核分析学习笔记:操作系统的进程切换
- IOS学习笔记29—提示框第三方库之MBProgressHUD
- 操作系统概念学习笔记 1 加电引导过程
- 【C++】 string学习笔记1——定义和初始化string对象
- Java 学习笔记 5 - 初始化与清理
- oracle 11g 学习笔记 10_29
- oracle 11g 学习笔记10_29(2)
- Objective-C 学习笔记(二) 类声明,定义,实例,初始化