一种Linux系统下的线程通信方法  被引量:2

A METHOD OF COMMUNICATION BETWEEN THREADS UNDER LINUX SYSTEM

在线阅读下载全文

作  者:王天伟 

机构地区:[1]天津通博视源技术有限公司,天津300000

出  处:《计算机应用与软件》2017年第10期330-333,共4页Computer Applications and Software

摘  要:提出一种结合数据和资源管理的线程通信方法,从数据结构上对消息进行定义和描述,并在此基础上设计和实现具备消息供给/回收策略的消息工厂。每个消息的内部会维护一个栈式数据结构,用于存放需要传递给其他线程的数据;然后基于POSIX消息队列实现用于传递消息的邮箱。发送线程从消息工厂取出一条消息并通过对数据栈进行压栈操作将待发送数据提交给消息,然后将消息邮递到邮箱里,接收线程从邮箱中取出消息并将数据依次从消息的数据栈中弹出,并在数据处理完成后将消息返还给消息工厂。A multi-thread communication method based on data and resource management is proposed. The concept of message is defined by a data structure,on the basis of which a message factory with supply/recycling strategy is designed and realized. First,each message maintained a stack of data structure,which was used to store the data that need to be passed to other threads. Afterwards,the mailbox based on POSIX message queue was implemented for passing messages.The sending thread took a message from the message factory and the data was submitted to the message by pushing onto a data stack. Then the message would be sent to a mailbox. The receiving thread fetched a message from the mailbox and popped the data sequentially from the message stack. At last the message would be returned to the message factory after the data had been processed.

关 键 词:多线程通信 消息工厂 邮箱 

分 类 号:TP3[自动化与计算机技术—计算机科学与技术]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象