op_ici_create()
摘要
创建一个新 ICI,其预定义结构由指定的 ICI 格式描述。
语法
op_ici_create (fmt_name)
| 参数 | 类型 | 说明 |
|---|---|---|
fmt_name |
const char * |
用作所创建 ICI 基础的 ICI 格式名称 [该值必须是一个已定义的 ICI 格式的名称,否则会发生错误。] |
返回类型
Ici *
指向新创建 ICI 的指针。如果发生任何可恢复错误,将返回常量 OPC_NIL。
示例
摘自:示例模型(models\std\x25);进程模型(x25_dce_ch);函数块过程(x25_dce_handle_ack)。
/* Loop through saved packets that have been acked, discarding them. */
for (i = send_window_low; i != rcv_seq; INC(i))
{
if (window [i].format & x25C_GFI_D_BIT)
{
/* The D bit was set on this packet when we sent it, so this represents and */
/* end-to-end confirmation; notify the higher layer. */
iciptr = op_ici_create ("x25_data");
op_ici_attr_set (iciptr, "primitive", OSIC_N_DATA_ACK_INDICATION);
op_ici_attr_set (iciptr, "src address", chan_vars->local_addr);
op_ici_attr_set (iciptr, "dest address", chan_vars->remote_addr);
op_ici_attr_set (iciptr, "confirmation request", 1);
op_ici_attr_set (iciptr, "confirmation tag", window[i].tag);
op_ici_install (iciptr);
op_pk_send (op_pk_create (0), chan_vars->application);
x25_dce_trace_msg ("Notifying higher layer of end-to-end confirmation");
window [i].format = 0;
}
}
详情
新 ICI 由仿真内核分配,其指针由该内核过程返回,以便在发起进程中为 ICI 属性赋值。该 ICI 具有基于 ICI 格式的预定且固定的结构,由属性名称与类型的有序列表构成。新创建的 ICI 不会自动影响将来安排的中断;这只能通过使用内核过程 op_ici_install() 进行安装来实现。
用途
为进程模型提供了一种引入新 ICI 以与相邻进程通信的机制。如果一个进程模型在每次安排中断时都会改变 ICI 属性,并且在某些先前安排的中断被投递之前又安排了额外的中断,那么它应为每个安排的中断创建一个新 ICI。反之,如果两个进程模型通过一系列无延迟的携带 ICI 的中断进行通信,则单向通信只需在仿真开始时创建一个 ICI(双向通信则创建两个)。
错误
- 程序中止:内存分配失败。(由于内存不足以保存新 ICI 或其属性)
- 程序中止:内核过程需要进程上下文。
- 可恢复错误:ICI 格式(
<fmt_name>)无法识别。
参考
- 使用内核过程 op_ici_destroy() 执行相反操作,释放 ICI 的内存
- 使用内核过程 op_ici_attr_set_dbl()、op_ici_attr_set_int32()、op_ici_attr_set_int64() 和 op_ici_attr_set_ptr() 为 ICI 属性赋值
- 使用内核过程 op_ici_install() 安装 ICI 以与传出中断关联
- 使用内核过程 op_ici_format_print_proc_set() 为具有给定格式的 ICI 的命名结构字段指定自定义打印过程