Linux IO模式及 select、poll、epoll详解

同步IO和异步IO,阻塞IO和非阻塞IO分别是什么,到底有什么区别?不同的人在不同的上下文下给出的答案是不同的。所以先限定一下本文的上下文

本文讨论的背景是Linux环境下的network IO。        

概念说明

在进行解释之前,首先要说明几个概念:

  • 用户空间和内核空间
  • 进程切换
  • 进程的阻塞
  • 文件描述符
  • 缓存 I/O

Linux下的I/O复用与epoll详解

前言

I/O多路复用有很多种实现。在linux上,2.4内核前主要是select和poll,自Linux 2.6内核正式引入epoll以来,epoll已经成为了目前实现高性能网络服务器的必备技术。尽管他们的使用方法不尽相同,但是本质上却没有什么区别。本文将重点探讨将放在EPOLL的实现与使用详解。

vim-文件编码

打开文件乱码是非常让人头痛的事件.不过好在linux系统本身提供的一些工具可以方便我们查看文件的编码,并将文件转换为目标的编码方式.vim就是一个这样的工具.vim几乎是每个Linux发行版都自带的编辑工具. 它的功能是非常强大的(搭配插件更强大). 在Linux系统上如果打开一个文本文件显示乱码,不好着急,此时只需要

Fibers-and-Threads-in-node

I like node.js, and I’m not the only one, obviously! I like it primarily for two things: it is simple and it is very fast. I already said it many times but one more won’t hurt.Before working with node, I had spent many years working with threaded application servers. This was fun sometimes but it was also often frustrating: so many APIs to learn, so much code to write, so many risks with critical sections and deadlocks, such a waste of costly system resources (stacks, locks), etc. Node came as a breath of fresh air: a simple event loop and callbacks. You can do a lot with so little, and it really flies!But it does not look like we managed to eradicate threads. They keep coming back. At the beginning of last year Marcel Laverdet opened Pandora’s box by releasing node-fibers: his threads are a little greener than our old ones but they have some similarities with them. And this week the box got wide open as Jorge Chamorro Bieling released threads_a_gogo, an implementation of real threads for node.js.Isn’t that awful? We were perfectly happy with the event loop and callbacks, and now we have to deal with threads and all their complexities again. Why on earth? Can’t we stop the thread cancer before it kills us!Well. First, things aren’t so bad because fibers and threads did not make it into node’s core. The core is still relying only on the event loop and callbacks. And it is probably better this way.And then maybe we need to overcome our natural aversion for threads and their complexities. Maybe these new threads aren’t so complex after all. And maybe they solve real problems. This is what I’m going to explore in this post.

nodejs模块之querystring

该模块提供了一些工具方法用来处理查询字符串,具体的方法如下所示:

querystring.escape

解码查询字符串

querystring.parse(str[, sep][, eq][, options])

将一个查询字符串转为一个JS对象。可以覆盖默认的分隔符&=

|