op_pro_self()
摘要
获取当前正在执行的进程的过程句柄。
语法
op_pro_self ()
| 参数 | 类型 | 说明 |
|---|---|---|
| 无参数 |
返回类型
Prohandle
当前正在执行的进程的过程句柄。该句柄可用于其他内核过程的调用,以执行与该进程相关的操作。
示例
/* Get the pointer to the module wide variables. */
mod_vars = (TP_Global_State *) op_pro_modmem_access ();
/* Obtain a process handle for the current session process. */
local_process_handle = op_pro_self ();
/* Register new process in module-wide data structure and initialize */
/* parent-to-child communication memory. */
tp_sess_init (sess_config_ptr, mod_vars, op_pro_id (local_process_handle);
详情
当前执行的进程常常需要把自身的句柄作为 Process 包和 Interrupt 包中其他内核过程的参数。例如,该句柄可作为获取父进程句柄的参照点。其他典型用途包括获取进程的唯一 id,以及让进程在不再有用时销毁自身。
用途
为调用该内核过程的进程提供过程句柄。该句柄是 Process 包和 Interrupt 包中许多其他内核过程的必需参数。
错误
- 程序中止:内核过程需要进程上下文。
参考
- 使用内核过程 op_pro_id() 获取进程的唯一整数 ID
- 使用内核过程 op_pro_destroy() 销毁进程
- 使用内核过程 op_intrpt_port_register() 为进程注册特定的数据包流或统计量中断
- 使用内核过程 op_intrpt_type_register() 为进程注册特定类型的中断