Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Five kinds of IO Model under Linux     - Linux system security knowledge (Linux)

- Understanding the type in C ++ bitset (Programming)

- iSCSI + multipath achieve DM multipath storage (Server)

- FastDFS installation and deployment (Server)

- Linux - EXT2 file system is described in detail (Linux)

- Oracle 10g, 11g database silent installation of small differences (Database)

- Ubuntu under Spark development environment to build (Server)

- See Linux kernel, CPU, memory, and various versions of the command module and means (Linux)

- Install Debian Linux with R on the Android system (Linux)

- Linux server is how to do after the invasion (Linux)

- Bash common several configuration files (Linux)

- CentOS directory structure Explanation (Linux)

- MySQL & NoSQL - Memcached widget (Database)

- Swift acquaintance of values and references, the circular reference, Agent Precautions (Programming)

- APT-mirror using a four-step configuration Ubuntu local depot (Linux)

- Element content of Java HashSet change issues (Programming)

- MySQL master recovery from failure using binlog (Database)

- Between the two to achieve the main MySQL database synchronization from (Database)

- CentOS 5.3 under broadcom NIC dual activation issues (Linux)

- Getting Started with Linux: CentOS7 Install Mono with the yum command (Server)

  Five kinds of IO Model under Linux
  Add Date : 2017-04-13      
    The contact network programming, we often associated with various concepts dealing with IO: Synchronous (Synchronous), asynchronous (ASynchronous), obstruction (blocking) and non-blocking (non-blocking). See the distinction between the concept of a friend (link) to play a more vivid metaphor:

You call to ask Bookseller there is no "Distributed Systems" This book, if it is synchronous communication mechanism, bookstore owner would say, you wait, "I'll check," and then began to check ah check, check and other good (possible 5 seconds, it may be one day) tell you the result (return results).
The asynchronous communication mechanism, the bookstore owner to tell you my check ah, call you a good check, and then directly to hang up (does not return a result). Well then check, he will take the initiative to call you. Here the boss through the "back" this way to the callback.

You call to ask Bookseller there is no "Distributed Systems" This book, if you are blocking call, you will always be yourself "hang" until you get this book there is no result. If the call is non-blocking, you have no boss to tell you regardless of your own first side to play, of course, you have a few minutes to check your boss occasionally have returned no results.

Here nothing to do with blocking and non-blocking asynchronous are synchronized. With the boss what way to answer your extraneous results.

    The main difference between synchronous and asynchronous is that: will not lead to the requesting process (or thread) blocked. Synchronization will request process (or thread) will not be blocked and asynchronous.

    There are five common IO model linux, asynchronous model of which only one, the rest are all synchronization model.

Blocking IO Model

    Blocking IO IO model is the most common model, and for all the "slow devices" (socket, pipe, fifo, terminal) of the IO default mode are blocking the way. Blocking is the process give up cpu, give other processes cpu. The process of blocking the most significant manifestation is the "process of sleep." Obstruction usually depends on whether the "data" soon.

Non-blocking IO Model

     Is to set non-blocking IO IO system calls related to non-blocaking, IO operations subsequent data is available with or without return immediately, and set errno to EWOULDBLOCK or EAGAIN. We can ensure that through active check IO effective manner (polling, polling) when, along with the related IO operations. Of course, this approach looks not seem tricky, wasted too much CPU time, with the valuable CPU time to do polling too shy child.

Multiplexed IO model

     Multiplexing is blocking occurs in the system so that we call the above multiplexed IO operation, rather than what we really to execute IO system calls. The benefits of using this approach is the ability to simultaneously monitor multiple file descriptors for the IO.

Signal driving IO Model

     The so-called drive signal, is the use of signaling mechanisms, install signal handler for SIGIO (IO perform related operations), by monitoring the file descriptors, when it is ready, notifies the target processes IO operation (signal handler).

Asynchronous IO Model

    Linux asynchronous IO on a predetermined set of POSIX interfaces have aio first few SYSCALL. as follows:

int aio_read (struct aiocb * aiocbp);

int aio_write (struct aiocb * aiocbp);

ssize_t aio_return (struct aiocb * aiocbp);

                                  Remember Link with -lrt use.
Parameter look gives a very simple illusion. In fact, compared to the parameters of a model to other no less, just put inside the structure. Prototype struct aiocb look at the structure of it, the header file is "aio.h".
 struct aiocb
   int aio_fildes; / * File desriptor * /.
   int aio_lio_opcode; / * Operation to be performed * /.
   int aio_reqprio; / * Request priority offset * /.
   volatile void * aio_buf; / * Location of buffer * /.
   size_t aio_nbytes; / * Length of transfer * /.
   struct sigevent aio_sigevent; / * Signal number and value * /.

   / * Internal members. * /
   struct aiocb * __ next_prio;
   int __abs_prio;
   int __policy;
   int __error_code;
   __ssize_t __return_value;
#ifndef __USE_FILE_OFFSET64
   __off_t aio_offset; / * File offset * /.
   char __pad [sizeof (__off64_t) - sizeof (__off_t)];
   __off64_t aio_offset; / * File offset * /.
   char __unused [32];
   In fact, although the structure is long enough, in fact, the real use of it in front of a few parameters, is not so complicated.
- About redis in Replication (Database)
- Python pickle module for simple use notes (Programming)
- Unix system security configuration (Linux)
- Java implementation of stacks and queues (Programming)
- Redis Design and Implementation study notes (Database)
- Linux text processing tool of sed (Linux)
- Let's Encrypt with semiautomatic into Nginx configuration https (Server)
- Android source code compiled fatal error solutions (Programming)
- Wine 1.7 is installed on a system based on RedHat or Debian (Linux)
- OpenGL Superb Learning Notes - Vertex Shader example (Programming)
- xCAT deployment (Linux)
- Linux the best download manager uGet (Linux)
- Nginx multi-domain certificate HTTPS (Server)
- Introduction to thread pooling and simple implementation (Programming)
- Terminal multiplexing tool tmux use (Linux)
- How to compare PDF files on Ubuntu (Linux)
- Bug tracking library after FastJson omitted the decimal point 0 (Programming)
- RabbitMQ tutorial examples: the Hello RabbitMQ World Java realization (Linux)
- MongoDB3.0.6 wiredtiger MMAPv1 (Database)
- Understand ASP.NET 5 running the command: DNVM, DNX, and DNU (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.