随笔分类 -  Linux 应用编程

记录应用方面的一些知识点~
摘要:NPTL在Linux操作系统中,本地POSIX线程库(NPTL)是一种软件特性,它可让Linux的内核 ,高效地运行那些使用POSIX风格的线程所编写的程序。 测试中,NPTL在一个IA-32处理器上,成功地同时跑了10万个线程,启动这些线程只用了不到2秒。比较起来,在不支持NPTL的内核上,这个测试花费了大约15分钟。 以前(也就是在2.6内核以前),Linux把进程当作其调度实体 ,内核并不真正支持线程。可是,它提供了一个clone()系统调用 ——创建一个调用进程的拷贝 ,这个拷贝与调用者共享地址空间。LinuxThreads项目就是利用这个系统调用,完全在用户级模拟了线程;不幸的是.. 阅读全文
posted @ 2011-10-09 13:41 夏大王 阅读(1432) 评论(0) 推荐(0)
摘要:进程还是线程?是一个问题! 就像莎士比亚的“To be, or not to be, that is the question”始终困扰着哈姆雷特,对于“进程还是线程?”这个问题,也经常困扰着那些进行软件架构设计的家伙。所以今天打算聊一下我对这个问题的体会。假如你还搞不清楚线程和进程的区别,请先找本操作系统原理的书好好拜读一下,再回来看帖。 由于这个问题很容易引发口水战,事先声明如下:多进程和多线程,无法一概而论地说谁比谁好。因此本帖主要描述特定场景(与我所负责的产品相关)下,进程和线程的权衡经验,仅供大伙儿参考。 由于特定场景是本帖讨论的前提,先说说我目前负责的产品的特点:业务逻辑比较... 阅读全文
posted @ 2011-10-09 13:40 夏大王 阅读(356) 评论(1) 推荐(0)
摘要:摘自桃源谷的blog: http://www.cppblog.com/lymons准则4: 请不要做线程的异步撤消的设计线程的异步撤销是指:某个线程的执行立刻被其他线程给强制终止了请不要单单为了让“设计更简单”或者“看起了更简单”而使用线程的异步撤消咋一看还是挺简单的。但是搞不好可能会引起各种各样的问题。请不要在不能把握问题的实质就做出使用线程的异步撤消的设计!在pthread的规格说明中,允许一个线程可以强制中断某个线程的执行。这就是所说的异步撤消。线程的撤消有下面的两种方式。方式1: 异步撤消(PTHREAD_CANCEL_ASYNCHRONOUS)撤销动作是马上进行的方式2: 延迟撤销( 阅读全文
posted @ 2011-09-28 20:20 夏大王 阅读(246) 评论(0) 推荐(0)
摘要:Low Level CAN FrameworkApplication Programmers InterfaceVersion 1.0.02006-02-20ContentsIntroductionLegal NoticesExtended DisclaimerLogoLinux Module LicenseTransport protocolsGeneral information on the socket API in LLCFTimestampRAW SocketsTest programmsSockets for Broadcast-ManagerCommunication with 阅读全文
posted @ 2011-09-09 19:25 夏大王 阅读(2815) 评论(0) 推荐(0)
摘要:atmel9260上LinuxsocketcanMCP2515调试笔记来源:Linux社区作者:reille前段时间调试了linux下的MCP2515驱动,驱动基本上调试通过,这两天调试另外几块板时又出现了一些问题。1.linux启动的时候probeMCP2515有时候失败,有时候成功,而有的板则是一直可以probe成功。probe失败时提示“MCP251xdidn'tenterinconfmodeafterreset”。调试分析:由于probe的时候,驱动复位MCP2515采用SPI命令复位形式,同时MCP2515复位引脚接了ATMEIL9260的GPIO引脚(驱动中没用GPIO复位 阅读全文
posted @ 2011-09-01 19:05 夏大王 阅读(2047) 评论(0) 推荐(0)
摘要:Socket CAN整体工作流程It would register itself with the network stack, and the network stack will expect to send and receive packets. The CAN driver then needs to send these packets to the chip over a SPI bus. So it uses the SPI infrastructure to send these packets to the actual MCP2510. Every system has 阅读全文
posted @ 2011-06-28 17:02 夏大王 阅读(2357) 评论(0) 推荐(0)
摘要:Neal Probert wrote:> I'm using PCAN-USB 6.7 with latest Socket-CAN from Subversion.>> Can anybody tell me what this means, and how to I get around it?>> "write: No buffer space available">> I don't get this with vcan0, but I do with can0. Happens with cangen &g 阅读全文
posted @ 2011-05-24 19:20 夏大王 阅读(5281) 评论(0) 推荐(0)
摘要:linux上定时函数 setitimer 的使用介绍(转) setitimer()为Linux的API,并非C语言的Standard Library,setitimer()有两个功能,一是指定一段时间后,才执行某个function,二是每间格一段时间就执行某个function,以下程序demo如何使用setitimer()。view plaincopy to clipboardprint?/* Filename:timer.cpp Compiler:gcc4.1.0onFedoraCore5 Description:setitimer()settheintervaltorunfunction 阅读全文
posted @ 2011-05-09 17:45 夏大王 阅读(532) 评论(0) 推荐(0)
摘要:xxg 标签: SPI testing utility,spidev driver,Linux spi 1 /* 2 * SPI testing utility (using spidev driver) 3 * 4 * Copyright (c) 2007 MontaVista Software, Inc. 5 * Copyright (c) 2007 Anton Vorontsov <avor... 阅读全文
posted @ 2011-03-31 18:13 夏大王 阅读(1007) 评论(0) 推荐(0)
摘要:可以通过改变进程的优先级来保证进程优先运行。在 Linux下,通过系统调用 nice()可以改变进程的优先级。nice()系统调用用来改变调用进程的优先级。函数声明如下:引用#include <unistd.h>int nice( int increment );getpriority() 和 setpriority() 两函数的声明:引用#include <sys/resource.h>int getpriority( int which, int two );int setpriority( int which, int who, int prio );getpri 阅读全文
posted @ 2011-03-15 23:10 夏大王 阅读(937) 评论(0) 推荐(0)