In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. IO reuse function of linux
IO operations with multiple descriptors in the same thread can be performed concurrently and sequentially.
Epoll provides only three functions:
Int epoll_create (int size); # create an epoll handle
Int epoll_ctl (int epfd, int op, int fd, struct epoll_event * event)
Associate listening events with epool handles (you can add, delete, and modify associations through the op parameter)
The first parameter, epfd, is the return value of epoll_create ()
The second parameter, op, indicates the association: EPOLL_CTL_ADD (add) EPOLL_CTL_MOD (change) EPOLL_CTL_DEL (delete)
The third parameter, fd, is the fd to be listened to.
The fourth parameter, event, tells the kernel what specific events to listen for: EPOLLIN (readable) EPOLLOUT (writable) EPOLLPRI (emergency readable) EPOLLERR (error) EPOLLHUP (hang up) EPOLLET (trigger mode ET or LT) EPOLLONESHOT (listen only once)
You can set the callback function corresponding to the event here.
Int epoll_wait (int epfd, struct epoll_event * events, int maxevents, int timeout)
If no listening event is generated in epoll_ctl, it will block here until the listening event occurs, or until the timeout occurs.
If there is an event listening in the epoll_ctl, the specific event handling callback function is executed.
Epoll ensures that each fd is copied only once throughout the process, from kernel space to user space.
2. IO Multiplexing of redis
Redis uses epoll to achieve IO multiplexing, putting connection information and events into a queue, then putting them into a file event dispatcher, which distributes events to event handlers.
Event handlers handle different events.
Main-> aeMain-> while {aeProcessEvents-> aeApiPoll-> epoll_wait}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.