io

create array of pointers to files

那年仲夏 提交于 2020-04-08 06:40:21
问题 How would I go about making an array of file pointers in C? I would like to create an array of file pointers to the arguments of main... like a1.txt, a2.txt, etc... So I would run ./prog arg1.txt arg2.txt arg3.txt to have the program use these files. Then the argument for main is char **argv From argv, I would like to create the array of files/file pointers. This is what I have so far. FILE *inputFiles[argc - 1]; int i; for (i = 1; i < argc; i++) inputFiles[i] = fopen(argv[i], "r"); 回答1: The

GPU - System memory mapping

谁说胖子不能爱 提交于 2020-04-07 15:44:09
问题 How system memory (RAM) is mapped for GPU access? I am clear about how virtual memory works for cpu but am not sure how would that work when GPU accesses GPU-mapped system memory (host). Basically something related to how Data is copied from system-memory to host-memory and vice versa. Can you provide explanations backed by reference articles please? 回答1: I found the following slideset quite useful: http://developer.amd.com/afds/assets/presentations/1004_final.pdf MEMORY SYSTEM ON FUSION APUS

GPU - System memory mapping

最后都变了- 提交于 2020-04-07 15:43:29
问题 How system memory (RAM) is mapped for GPU access? I am clear about how virtual memory works for cpu but am not sure how would that work when GPU accesses GPU-mapped system memory (host). Basically something related to how Data is copied from system-memory to host-memory and vice versa. Can you provide explanations backed by reference articles please? 回答1: I found the following slideset quite useful: http://developer.amd.com/afds/assets/presentations/1004_final.pdf MEMORY SYSTEM ON FUSION APUS

IO

时光怂恿深爱的人放手 提交于 2020-04-07 08:39:32
当你发现自己最受欢迎的一篇blog其实大错特错时,这绝对不是一件让人愉悦的事。 《 IO - 同步,异步,阻塞,非阻塞 》是我在开始学习epoll和libevent的时候写的,主要的思路来自于文中的那篇 link 。写完之后发现很多人都很喜欢,我还是非常开心的,也说明这个问题确实困扰了很多人。随着学习的深入,渐渐的感觉原来的理解有些偏差,但是还是没引起自己的重视,觉着都是一些小错误,无伤大雅。直到有位博友问了一个问题,我重新查阅了一些更权威的资料,才发现原来的文章中有很大的理论错误。我不知道有多少人已经看过这篇blog并受到了我的误导,鄙人在此表示抱歉。俺以后写技术blog会更加严谨的。 一度想把原文删了,最后还是没舍得。毕竟每篇blog都花费了不少心血,另外放在那里也可以引以为戒。所以这里新补一篇。算是亡羊补牢吧。 言归正传。 同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问题其实不同的人给出的答案都可能不同,比如wiki,就认为asynchronous IO和non-blocking IO是一个东西。这其实是因为不同的人的知识背景不同,并且在讨论这个问题的时候上下文(context)也不相同。所以,为了更好的回答这个问题,我先限定一下本文的上下文

io 一不小心 关闭不住的偶

流过昼夜 提交于 2020-03-31 02:53:39
try { for (String file : files) { String result=backupPath + File.separator + file; Files.createParentDirs(new File(result)); fos = new FileOutputStream(result); ftpClient.setBufferSize(1024); ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); ftpClient.retrieveFile(file, fos); ftpClient.dele(file); Closeables.close(fos, false);// 上面出现异常,则链接关闭不掉 ---1 } } finally { Closeables.close(fos, false); // 并不重复,如果for 循环中出现异常,则调用这个 ----2 ftpClient.disconnect(); } 一个循环惹得祸,如果不小心,会导致资源关闭不住的啊,看看注释1和2 ,是不是有这样的问题 以后要小心了啊 来源: https://www.cnblogs.com/bbsno1/p/3271280.html

基于S3C2410的通用IO编程

前提是你 提交于 2020-03-30 01:52:48
一、通用IO的定义 GPIO(General-Purpose IO ports),通用的IO口。一般的微控制芯片都提供通用的可编程接口。按照它们的功能分成: ● 通用IO控制寄存器 ● 通过IO数据寄存器 很多MCU的GPIO接口出去了标准的寄存器必须外,还会提供上拉寄存器,可以设置IO的输出模式为高阻。 二、S3C2410A的通用IO寄存器 S3C2410A共有117个复用的输入/输出端口,分别是端口A~H,共8组。按照其位数不同不同可分为: ● 端口A(GPA),23位输出口 ● 端口B(GPB),11位输出口 ● 端口C(GPC),16位输出口 ● 端口D(GPD),16位输出口 ● 端口E(GPE),16位输出口 ● 端口F(GPF),8位输出口 ● 端口G(GPG),16位输出口 ● 端口H(GPH),11位输出口 为了满足不同设计要求,每个IO口可以设置成不同的工作模式,其中又可以将IO口分成如下3类: ● 端口控制寄存器(GPACON~CPHCON) 设置引脚工作模式,例如:输入、输出、外部中断和保留。 ● 端口数据寄存器(GPADAT~CPHDAT) 当端口被设置成输入模式,可以向GPxDAT的相应位写入数据;当端口被设置成输出模式,可以从GPxDAT的相应位读出数据 ● 端口上拉寄存器(GPAUP~CPHUP) 控制某一端口的响应位的上拉电阻状态(允许/禁止)。

Java-Redis JdkSerializationRedisSerializer和StringRedisSerializer

天涯浪子 提交于 2020-03-26 08:58:52
在将redis中存储的数据进行减一操作时出现: io.lettuce.core.RedisCommandExecutionException: ERR value is not a valid float at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:118) ~[lettuce-core-5.0.4.RELEASE.jar:na] at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:109) ~[lettuce-core-5.0.4.RELEASE.jar:na] at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:57) ~[lettuce-core-5.0.4.RELEASE.jar:na] at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:598) ~[lettuce-core-5.0.4.RELEASE.jar:na] at io.lettuce.core.protocol.CommandHandler

java序列化和反序列化

烂漫一生 提交于 2020-03-22 19:05:42
原文地址:http://www.blogjava.net/sxyx2008/ 首先解释两个概念 , 何为序列化 ? 何为反序列化 ? 序列化 : 将对象转化成流的过程称为序列化 反序列化 : 将流转化成对象的过程称之为反序列化 序列化与反序列化必须遵守的原则 a) Java对象 在java中要想使一个java对象可以实现序列化与反序列化,必须让该类实现java.io.Serializable接口 java.io.Serializable接口定义如下: public interface Serializable { } 从上述定义中可以看到该接口中未定义任何方法,这大大的简化了开发者 b) 序列化主要依赖java.io.ObjectOutputStream类,该类对java.io.FileOutputStream进一步做了封装,这里主要使用ObjectOutputStream类的writeObject()方法实现序列化功能 Demo: /** *将对象序列化到磁盘文件中 * @param o * @throws Exception */ public static void writeObject(Object o) throws Exception{ File f= new File("d:""user.tmp"); if (f.exists()){ f.delete(); }

Zip file is created with windows path separator

北城余情 提交于 2020-03-21 02:08:32
问题 I create a zip file using below code. Zip is created properly, then later in my program I try to get a zip entry from this file. And if I print a zip entry name I get windows path separators(Eg \a\b\c ). But I need this like a/b/c . I have not posted reading zip entry code. public static void zipFolder(File subdirs, String ZipName) throws FileNotFoundException, IOException { try (FileOutputStream fileWriter = new FileOutputStream(location+File.seperator+ ZipName); ZipOutputStream zip = new