io

iostat 命令

夙愿已清 提交于 2020-03-19 23:06:23
NAME iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS). SYNOPSIS iostat [ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j { ID | LABEL | PATH | UUID | ... } [ device [...] | ALL ] ] [ device [...] | ALL ] [ -p [ device [,...] | ALL ] ] [ interval [ count ] ]参数: -c 显示CPU使用情况 -d 显示磁盘使用情况 -k 以 KB 为单位显示 -m 以 M 为单位显示 -N 显示磁盘阵列(LVM) 信息 -n 显示NFS 使用情况 -p [磁盘] 显示磁盘和分区的情况 -t 显示终端和CPU的信息 -x 显示详细信息 -V 显示版本信息 cpu和磁盘使用信息 iostat -x cpu属性值: %user:CPU处在用户模式下的时间百分比。 %nice

浅谈I/O模型

…衆ロ難τιáo~ 提交于 2020-03-19 02:40:01
在学习线程,NIO等知识时都需要知道一些基础知识。 一、什么是同步或异步 同步:个人通俗理解多个人排队打饭一个窗口,只有前面一个人打完了,后面的人才能打。如果前面人因为什么原因一直站在那里不走,后面的人就一直需要等待。 如果有多个任务或事件要发生,多个任务或事件要逐个去执行,如果其中有一个事件或任务出现问题都会影响整个流程,其他任务都需要进行等待 异步:多个人排队打发多个窗口,每个人选择一个窗口不需要等待,一个人出现窗口占用,其他人不受影响。 多个任务或事件并发执行,一个任务或事件不会影响整个流程的暂时等待 示例1 典型的同步操作 方法在调用是从上到下依次执行, 只有fun1执行完成后,fun2才会被执行 void fun1(){ } void fun2(){ } main(){   fun1(); fun2(); } 示例2 主线程开启两个子线程 两个子线程调用互不影响 两个方法的调用也互不影响 fun1() 与 fun2()之间不需要等待 fun1(){} fun2(){} main(){   new Thread(){ public void run(){    fun1();  } }.start();    new Thread(){ public void run(){    fun2();  } }.start();     } 二、什么是阻塞 和非阻塞 阻塞

IO读取数据标准步骤

让人想犯罪 __ 提交于 2020-03-17 13:50:36
package cn . text . one ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; /** * @author pc *操作步骤 1.创建源 2.选择流 3.操作 4.释放资源 */ public class Text01 { public static void main ( String [ ] args ) { InputStream in = null ; File file = new File ( "src\\cn\\text\\one\\abc.txt" ) ; try { in = new FileInputStream ( file ) ; int temp ; while ( ( temp = in . read ( ) ) != - 1 ) { System . out . print ( ( char ) temp + "," ) ; } //释放资源 } catch ( FileNotFoundException e ) { e .

图解 Java IO : 一、File源码

三世轮回 提交于 2020-03-10 06:05:27
Writer :BYSocket(泥沙砖瓦浆木匠) 微 博: BYSocket 豆 瓣: BYSocket FaceBook: BYSocket Twitter : BYSocket 记得Java源码是 集合 开始看的,写了一 系列集合 相关的文章,受到不错的评价。感谢各位读者。我依旧会 读到老写到老 ,并生动形象的写出来心得体会。 这次依旧是 图解 ,我研究IO这块。 Java IO – File的 要点 ,应该是 1、跨平台问题的解决 2、文件的安全 3、文件的检索方法 一、代码小引入 代请看一个简单的小demo:(ps:开源项目 java-core-learning 地址 : https://github.com/JeffLi1993 ) ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 import java.io.File; import java.util.Arrays; /* * Copyright [2015] [Jeff Lee] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use

6.02_IO(字节流)

核能气质少年 提交于 2020-03-08 08:08:40
一、IO流概述及其分类   * 1.概念     * IO流用来处理设备之间的数据传输     * Java对数据的操作是通过流的方式     * Java用于操作流的类都在IO包中     * 流按流向分为两种:输入流,输出流。     * 流按操作类型分为两种:     * 字节流 : 字节流可以操作任何数据,因为在计算机中任何数据都是以字节的形式存储的     * 字符流 : 字符流只能操作纯字符数据,比较方便。 二、IO流常用父类   * 字节流的抽象父类:     * InputStream     * OutputStream   * 字符流的抽象父类:     * Reader     * Writer 三、IO程序书写   * 使用前,导入IO包中的类   * 使用时,进行IO异常处理   * 使用后,释放资源 四、IO流(FileInputStream)   * read()一次读取一个字节   *    FileInputStream fis = new FileInputStream("aaa.txt"); //创建一个文件输入流对象,并关联aaa.txt     int b; //定义变量,记录每次读到的字节     while((b = fis.read()) != -1) { //将每次读到的字节赋值给b并判断是否是-1     System.out

伪异步IO理解

让人想犯罪 __ 提交于 2020-03-07 08:44:26
伪异步IO实在堵塞IO的基础上将每个client发送过来的请求由新创建的线程来处理改进为用线程池来处理。因此避免了为每个client请求创建一个新线程造成的资源耗尽问题。 来看一下伪异步IO的服务端代码: 线程池类 import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** * @author zhouxuejun * * @date 2014年10月21日 上午10:05:43 */ public class TimerServerHandlerExecutePool { private ExecutorService executor; public TimerServerHandlerExecutePool(int maxPoolSize, int queueSize) { executor = new ThreadPoolExecutor(Runtime.getRuntime() .availableProcessors(), maxPoolSize, 120L,

Multiple WriteFile after ERROR_IO_PENDING

寵の児 提交于 2020-03-05 04:55:06
问题 In my application, I am testing the behaviour of WriteFile when another Write operation is pending over the named pipe. Pipe is in message mode (not in byte mode). To make write operation pending, I kept the buffer of named pipe quite small and client sends the more data than buffer size. By this way, I am getting write operation pending at the client end. I am facing the following problem at the server end: ReadFile is failed with ERROR_MORE_DATA . It changes the content of the buffer, but

使用QueueUserAPC线程注入,

回眸只為那壹抹淺笑 提交于 2020-03-03 18:48:04
代码1 #define _WIN32_WINNT 0x0400 #define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料 #include < iostream > #include < windows.h > #include < Winbase.h > using namespace std; DWORD WINAPI WorkThread(LPVOID pParam) { HANDLE Event = (HANDLE)pParam; for (;;) { DWORD dwRet = WaitForSingleObjectEx(Event, INFINITE, TRUE); if (dwRet == WAIT_OBJECT_0) break ; else if (dwRet == WAIT_IO_COMPLETION) printf( " WAIT_IO_COMPLETION\n " ); return 0 ; } } VOID WINAPI APCProc(LPVOID dwParam) { printf( " %s " , (PVOID)dwParam); } void TestAPC(BOOL bFast) { HANDLE QuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

[转帖]分享一个来自国外的bench.sh测速脚本

我是研究僧i 提交于 2020-03-02 08:05:55
分享一个来自国外的bench.sh测速脚本 https://cikeblog.com/bench-sh.html 很多时候,我们购买了VPS第一件事就是第一时间跑一下配置,测一下网络、IO、内存、磁盘、这些看一下有没有什么问题。所以如果是基本操作,秋水的bench.sh已经够用了,但是有时候我们需要更加详细的测试,所以接下来这个脚本非常适合我们使用。 一、安装 wget git.io/bench.sh 详细使用参数: Arguments: -info - Check basic system information -io - Run I/O test with or w/ cache -cdn - Check download speed from CDN -northamercia - Download speed from North America -europe - Download speed from Europe -asia - Download speed from asia -a - Test and check all above things at once -b - System info, CDN speedtest and I/O test -ispeed - Install speedtest-cli (python 2.4-3.4 required

C++中流的基本概念

拥有回忆 提交于 2020-03-01 07:19:05
文章目录 1 C++中流的基本概念 1.1 IO流的基本概念 1.2 C++中的IO类库 1 C++中流的基本概念 1.1 IO流的基本概念 C++中的IO流图示如下: 设备包括如下: 文件。 控制台。 特定的数据类型(stringstream)。 1.2 C++中的IO类库 在C++中,必须通过特定的已经定义好的类,来处理IO(输入输出)。 参考资料: C/C++从入门到精通-高级程序员之路【奇牛学院】 来源: CSDN 作者: SlowIsFastLemon 链接: https://blog.csdn.net/SlowIsFastLemon/article/details/104575755