ZYNQ QNX开发——资源管理器对close()的处理

本文探讨了QNX操作系统中资源管理器在处理close()时涉及的close_ocb和close_dup函数。close_ocb用于销毁OCB并释放内存,而close_dup处理_IO_CLOSE消息。在dup()产生的文件描述符复制场景下,多个close()调用会先执行close_dup(),当引用计数归零时,close_ocb()才会销毁OCB。建议在需要做收尾工作时重写close_ocb()函数。
摘要由CSDN通过智能技术生成

在写资源管理器的时候,一般会用到处理close()来进行一些收尾工作,比如释放内存等等,查看QNX代码resmgr_io_funcs_t结构体对close()的处理有两个相关函数

typedef struct _resmgr_io_funcs {
    unsigned    nfuncs;
    int         (*read)(resmgr_context_t *ctp, io_read_t *msg, RESMGR_OCB_T *ocb);
    int         (*write)(resmgr_context_t *ctp, io_write_t *msg, RESMGR_OCB_T *ocb);
    int         (*close_ocb)(resmgr_context_t *ctp, void *reserved, RESMGR_OCB_T *ocb);
    int         (*stat)(resmgr_context_t *ctp, io_stat_t *msg, RESMGR_OCB_T *ocb);
    int         (*notify)(resmgr_context_t *ctp, io_notify_t *msg, RESMGR_OCB_T *ocb);
    int         (*devctl)(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb);
    int         (*unblock)(resmgr_context_t *ctp, io_pulse_t *msg, RESMGR_OCB_T *ocb);
    int         (*pathconf)(resmgr_context_t *ctp, io_pathconf_t *msg, RESMGR_OCB_T *ocb);
    int         (*lseek)(resmgr_context_t *ctp, io_lseek_t *msg, RESMGR_OCB_T *ocb);
    int         (*chmod)(resmgr_context_t *ctp, io_chmod_t *msg, RESMGR_OCB_T *ocb);
    int         (*chown)(resmgr_context_t *ctp, io_chown_t *msg, RESMGR_OCB_T *ocb);
    int         (*utime)(resmgr_context_t *ctp, io_utime_t *msg, RESMGR_OCB_T *ocb);
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值