Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问我对RBN的理解对吗? #6

Open
2731381914 opened this issue Jul 24, 2019 · 1 comment
Open

请问我对RBN的理解对吗? #6

2731381914 opened this issue Jul 24, 2019 · 1 comment

Comments

@2731381914
Copy link

2731381914 commented Jul 24, 2019

struct epitem {
	RB_ENTRY(epitem) rbn;
	/*  RB_ENTRY相当如定义了如下的一个结构成员变量
	struct {											
	struct type *rbe_left;		//指向左子树
	struct type *rbe_right;		//指向右子树
	struct type *rbe_parent;  	//指向父节点 正常的红黑树没有父节点,这里为什么需要?
	int rbe_color;			       //该红黑树节点颜色
	} rbn*/
};

epoll add 是向红黑树中添加节点
epoll wait 是将红黑树中就续的文件节点, 添加到双向链表中, 返回给应用,这个添加到链表中的操作,是内核完成,还是自己实现呢?
将一个fd添加到epoll中,底层的epoll是如何判断这个fd是否有数据可读,是否可以写数据,请问这样的判断是否消耗很大呢?
请问我理解的正确吗?

@wangbojing
Copy link
Owner

你好,关于epoll与红黑树的关系,epoll数据可读可写的实现。
https://zhuanlan.zhihu.com/p/50984245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants