fifo

Does an optimistic lock-free FIFO queue implementation exist?

Deadly 提交于 2019-11-30 14:56:46
问题 Is there any C++ implementation (source codes) of "optmistic approach to lock-free FIFO queues" algorithm? 回答1: Herb Sutter covered just such a queue as part of his Effective Concurency column in Dr. Dobbs Journal. Writing Lock-Free Code: A Corrected Queue 回答2: I want to conclude the answer given by greyfade , which is based on http://www.drdobbs.com/high-performance-computing/212201163 (the last part of the article), the optimized code would be (with some modification to suit my naming and

https://blog.csdn.net/xiaohe511/article/details/51385779

≡放荡痞女 提交于 2019-11-30 13:19:08
Slave FIFO 固件需要设置的相关寄存器 IFCONFIG EPxFIFOPFH/L PINFLAGSAB PORTACFG PINFLAGSCD INPKTEND FIFORESET FIFOPINPOLAR EPxCFG EPxFIFOBCH:L EPxFIFOCFG EPxAUTOINLENH:L EPxBCH:L REVCTL (bits 0 and 1 must be initialized to 1 for operation as described in this chapter) 一. CPUCS(E600)CPU控制和状态寄存器 bit b7 b6 b5 b4 b3 b2 b1 b0 name 0 0 PORTCSTB CLKSPD1 CLKSPD0 CLKINV CLKOE 8051RES r/w r r rw rw rw rw rw r default 0 0 0 0 0 0 1 0 PORTCSTB : 128 脚或 100 脚的 RD , WR 输出使能; CLKSPD[1:0] : 8051CPU 频率选择, CLKSPD[1:0] 00 01 10 11 CPU 频率 12MHz 24MHz 48MHz Reserved CLKINV : CLKOUT 反相; CLKOE : CLKOUT 输出使能; 8051RES: 位为 1 来复位 EZ

Does an optimistic lock-free FIFO queue implementation exist?

人盡茶涼 提交于 2019-11-30 13:08:48
Is there any C++ implementation (source codes) of " optmistic approach to lock-free FIFO queues" algorithm ? Herb Sutter covered just such a queue as part of his Effective Concurency column in Dr. Dobbs Journal. Writing Lock-Free Code: A Corrected Queue I want to conclude the answer given by greyfade , which is based on http://www.drdobbs.com/high-performance-computing/212201163 (the last part of the article), the optimized code would be (with some modification to suit my naming and coding convention) : ` template <typename T> class LFQueue { private: struct LFQNode { LFQNode( T* val ) : value

RT-Thread中的串口DMA分析

丶灬走出姿态 提交于 2019-11-30 11:49:35
这里分析一下RT-Thread中串口DMA方式的实现,以供做新处理器串口支持时的参考。 背景 在如今的芯片性能和外设强大功能的情况下,串口不实现DMA/中断方式操作,我认为在实际项目中基本是不可接受的,但遗憾的是,rt-thread现有支持的实现中,基本上没有支持串口的DMA,文档也没有关于串口DMA支持相关的说明,这里以STM32实现为背景,梳理一下串口DMA的实现流程,以供新处理器实现时以作参考。 DMA接收准备 启用DMA接收,需要在打开设备的时候做一些处理,入口函数为rt_device_open()。主体实现是: rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag) { ...... result = device_init(dev); ...... result = device_open(dev, oflag); ...... } device_init()就是rt_serial_init()函数,其主要是调用configure()函数, static rt_err_t rt_serial_init(struct rt_device *dev) { ...... if (serial->ops->configure) result = serial->ops->configure(serial,

How do I read a FIFO/named pipe line by line from a C++/Qt Linux app?

青春壹個敷衍的年華 提交于 2019-11-30 09:42:03
How do I read a FIFO/named pipe line by line from a C++/Qt Linux app? Today I can open and read from a fifo from a Qt program, but I can't get the program to read the data line by line. Qt reads the entire file, meaning he waits until the "sender" closes his session. Let's take a example with some shell commands to show what I would like the app to do. First create a fifo mkfifo MyPipe Then we can use cat to read from the fifo cat MyPipe And then we send some data in with another cat cat > MyPipe And then start to type something, and every time you hit enter it arrives at the reader. And then

Is there a FIFO stream in Scala?

99封情书 提交于 2019-11-30 08:45:42
I'm looking for a FIFO stream in Scala, i.e., something that provides the functionality of immutable.Stream (a stream that can be finite and memorizes the elements that have already been read) mutable.Queue (which allows for added elements to the FIFO) The stream should be closable and should block access to the next element until the element has been added or the stream has been closed. Actually I'm a bit surprised that the collection library does not (seem to) include such a data structure, since it is IMO a quite classical one. My questions: 1) Did I overlook something? Is there already a

FIFO

主宰稳场 提交于 2019-11-30 07:01:20
FIFO是一种先入先出的数据缓存器,他与普通存储器的区别是没有外部读写地址线,这样使用起来非常方便,但缺点是只能顺序的写入数据、读出数据,其内部地址是由内部读写指针自动加1完成,不能像普通存储器那样由地址线读取或者写入某个地址。 FIFO一般用于不同时钟域之间的数据传输,比如FIFO的一端是AD数据采集,另一端是计算机的PCI总线,假设AD采集的速率是16位100K sps,那么每秒的数据量为100K x 16bit=1.6Mbps,而PCI总线的速度为33MHZ,总线宽度是32bit,其最大传输速率为1056Mbps,在两个不同的时钟域间采用FIFO作为数据缓冲。另外对于不同宽度的数据接口也可以用FIFO,例如单片机的8位数据输出。 FIFO的分类根据FIFO工作的时钟域,分为同步FIFO和异步FIFO。同步FIFO是指读写时钟为同一时钟。在时钟沿来临时同时发生读写操作。异步FIFO是指读写时钟不一致,读写时钟相互独立。 FIFO设计的难点在于怎么判断FIFO的空满状态。为了保证数据正确的写入和读出,而不发生溢出或读空的状态出现,必须保证FIFO在满的情况下,不能进行写操作。在空的状态下不能进行读操作。 同步FIFO的实现代码: 1 module fifo( //信号定义---读、写、data_in,data_out,clk,复位,空,满 2 input [7:0] datain

同步FIFO design and IP level verification

爱⌒轻易说出口 提交于 2019-11-30 05:51:05
一、前言    应聘IC前端相关岗位时,FIFO是最常考也是最基本的题目。FIFO经常用于数据缓存、位宽转换、异步时钟域处理。随着芯片规模的快速增长,灵活的system verilog成为设计/验证人员的基本功。本文从简易版的同步FIFO开始,熟悉IP设计与验证的基础技能。 二、IP设计    FIFO这一IP核已经相当成熟,因此网上资料也是一抓一大把。其中笔者认为较好的一个在文末附录中,需要详细了解FIFO工作原理的朋友可以仔细看看。这里简单介绍下本文设计FIFO的原理与结构。 FIFO的内部存储单元是常见的双口RAM,这个IP的精髓在于读写地址的对外屏蔽与自动管理。避免写满、读空至关重要。 本文设计的FIFO顶层例化双口RAM和FIFO控制两大模块:前者仅作为存储单元响应读写信号,后者根据读写计数器产生读写指针和重要的空满指示信号。   代码如下: 存储模块: 1 `timescale 1ns/1ps 2 module dpram 3 #(parameter D_W=8, 4 A_W=8) 5 ( 6 input clk, 7 input rst_n, 8 //write ports 9 input wr_en, 10 input [D_W-1:0] wr_data, 11 input [A_W-1:0] wr_addr, 12 //read ports 13 input rd

Are there repercussions to having many processes write to a single reader on a named pipe in posix?

笑着哭i 提交于 2019-11-30 03:32:29
问题 I am writing a program for POSIX (OSX) where I will have many processes sending messages to one listener, who is essentially a logging thread. All of the processes are running in seperate programs, and using a single named pipe (FIFO) that many processes write to, but only a single process reads from is very tempting. Questions: 1) Will this work? - I can make this work using bash to setup a fifo with multiple processes writing to it, so I know in theory this works. But in practice, are there

Adding opencv processing to gstreamer application

会有一股神秘感。 提交于 2019-11-29 22:36:48
I'm trying to do the following: receive video stream using gstreamer and process it with opencv. I've found few solutions, and one of them is to write video into (from gstreamer) fifo and then read it using opencv. (OPTION3 here MJPEG streaming and decoding ). The problem is I cant open pipe. cvCreateFileCapture just never returns. Here is a part code I wrote: if(mkfifo("fifo.avi", S_IRUSR| S_IWUSR) == -1) { cout<<"Cant create fifo"<<endl; cout<<errno<<endl; } loop = g_main_loop_new(NULL, false); fsink = gst_element_factory_make("filesink", "fsink"); g_object_set(G_OBJECT(fsink), "location",